Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf probe: Add helper function to check if probe with variable

Introduce helper function instead of inline code and replace hardcoded
strings "$vars" and "$params" with their corresponding macros.

perf_probe_with_var() is not declared as static since it will be called
from different file in subsequent patch.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1470214725-5023-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ravi Bangoria and committed by
Arnaldo Carvalho de Melo
b3f33f93 432746f8

+17 -7
+15 -7
tools/perf/util/probe-event.c
··· 1618 1618 return ret; 1619 1619 } 1620 1620 1621 + /* Returns true if *any* ARG is either C variable, $params or $vars. */ 1622 + bool perf_probe_with_var(struct perf_probe_event *pev) 1623 + { 1624 + int i = 0; 1625 + 1626 + for (i = 0; i < pev->nargs; i++) 1627 + if (is_c_varname(pev->args[i].var) || 1628 + !strcmp(pev->args[i].var, PROBE_ARG_PARAMS) || 1629 + !strcmp(pev->args[i].var, PROBE_ARG_VARS)) 1630 + return true; 1631 + return false; 1632 + } 1633 + 1621 1634 /* Return true if this perf_probe_event requires debuginfo */ 1622 1635 bool perf_probe_event_need_dwarf(struct perf_probe_event *pev) 1623 1636 { 1624 - int i; 1625 - 1626 1637 if (pev->point.file || pev->point.line || pev->point.lazy_line) 1627 1638 return true; 1628 1639 1629 - for (i = 0; i < pev->nargs; i++) 1630 - if (is_c_varname(pev->args[i].var) || 1631 - !strcmp(pev->args[i].var, "$params") || 1632 - !strcmp(pev->args[i].var, "$vars")) 1633 - return true; 1640 + if (perf_probe_with_var(pev)) 1641 + return true; 1634 1642 1635 1643 return false; 1636 1644 }
+2
tools/perf/util/probe-event.h
··· 128 128 int perf_probe_event__copy(struct perf_probe_event *dst, 129 129 struct perf_probe_event *src); 130 130 131 + bool perf_probe_with_var(struct perf_probe_event *pev); 132 + 131 133 /* Check the perf_probe_event needs debuginfo */ 132 134 bool perf_probe_event_need_dwarf(struct perf_probe_event *pev); 133 135