aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2015-04-01 06:25:39 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-04-10 09:19:53 -0400
commit7afb3fab390871b1d20b1dbb94e03b8a3861cb0d (patch)
tree4bfc7c1255b27510159a6af4f09e7ae7c23c4089 /tools
parent5e78c69b72276853ac64070a010e6df64723dba9 (diff)
perf probe: Support multiple probes on different binaries
Support multiple probes on different binaries with just one command. In the result, this example sets up the probes on icmp_rcv in kernel, on main and set_target in perf, and on pcspkr_event in pcspker.ko driver. ----- # perf probe -a icmp_rcv -x ./perf -a main -a set_target \ -m /lib/modules/4.0.0-rc5+/kernel/drivers/input/misc/pcspkr.ko \ -a pcspkr_event Added new event: probe:icmp_rcv (on icmp_rcv) You can now use it in all perf tools, such as: perf record -e probe:icmp_rcv -aR sleep 1 Added new event: probe_perf:main (on main in /home/mhiramat/ksrc/linux-3/tools/perf/perf) You can now use it in all perf tools, such as: perf record -e probe_perf:main -aR sleep 1 Added new event: probe_perf:set_target (on set_target in /home/mhiramat/ksrc/linux-3/tools/perf/perf) You can now use it in all perf tools, such as: perf record -e probe_perf:set_target -aR sleep 1 Added new event: probe:pcspkr_event (on pcspkr_event in pcspkr) You can now use it in all perf tools, such as: perf record -e probe:pcspkr_event -aR sleep 1 ----- Reported-by: Arnaldo Carvalho de Melo <acme@infradead.org> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20150401102539.17137.46454.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-probe.c9
-rw-r--r--tools/perf/util/probe-event.c5
-rw-r--r--tools/perf/util/probe-event.h6
3 files changed, 13 insertions, 7 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 921bb6942503..2df23e177da5 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -78,6 +78,11 @@ static int parse_probe_event(const char *str)
78 } 78 }
79 79
80 pev->uprobes = params.uprobes; 80 pev->uprobes = params.uprobes;
81 if (params.target) {
82 pev->target = strdup(params.target);
83 if (!pev->target)
84 return -ENOMEM;
85 }
81 86
82 /* Parse a perf-probe command into event */ 87 /* Parse a perf-probe command into event */
83 ret = parse_perf_probe_command(str, pev); 88 ret = parse_perf_probe_command(str, pev);
@@ -178,7 +183,7 @@ static int opt_set_target(const struct option *opt, const char *str,
178 int ret = -ENOENT; 183 int ret = -ENOENT;
179 char *tmp; 184 char *tmp;
180 185
181 if (str && !params.target) { 186 if (str) {
182 if (!strcmp(opt->long_name, "exec")) 187 if (!strcmp(opt->long_name, "exec"))
183 params.uprobes = true; 188 params.uprobes = true;
184#ifdef HAVE_DWARF_SUPPORT 189#ifdef HAVE_DWARF_SUPPORT
@@ -200,6 +205,7 @@ static int opt_set_target(const struct option *opt, const char *str,
200 if (!tmp) 205 if (!tmp)
201 return -ENOMEM; 206 return -ENOMEM;
202 } 207 }
208 free(params.target);
203 params.target = tmp; 209 params.target = tmp;
204 ret = 0; 210 ret = 0;
205 } 211 }
@@ -487,7 +493,6 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
487 if (params.nevents) { 493 if (params.nevents) {
488 ret = add_perf_probe_events(params.events, params.nevents, 494 ret = add_perf_probe_events(params.events, params.nevents,
489 params.max_probe_points, 495 params.max_probe_points,
490 params.target,
491 params.force_add); 496 params.force_add);
492 if (ret < 0) { 497 if (ret < 0) {
493 pr_err_with_code(" Error: Failed to add events.", ret); 498 pr_err_with_code(" Error: Failed to add events.", ret);
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b78851732a71..30545ce2c712 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1906,6 +1906,7 @@ void clear_perf_probe_event(struct perf_probe_event *pev)
1906 1906
1907 free(pev->event); 1907 free(pev->event);
1908 free(pev->group); 1908 free(pev->group);
1909 free(pev->target);
1909 clear_perf_probe_point(&pev->point); 1910 clear_perf_probe_point(&pev->point);
1910 1911
1911 for (i = 0; i < pev->nargs; i++) { 1912 for (i = 0; i < pev->nargs; i++) {
@@ -2654,7 +2655,7 @@ struct __event_package {
2654}; 2655};
2655 2656
2656int add_perf_probe_events(struct perf_probe_event *pevs, int npevs, 2657int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
2657 int max_tevs, const char *target, bool force_add) 2658 int max_tevs, bool force_add)
2658{ 2659{
2659 int i, j, ret; 2660 int i, j, ret;
2660 struct __event_package *pkgs; 2661 struct __event_package *pkgs;
@@ -2678,7 +2679,7 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
2678 ret = convert_to_probe_trace_events(pkgs[i].pev, 2679 ret = convert_to_probe_trace_events(pkgs[i].pev,
2679 &pkgs[i].tevs, 2680 &pkgs[i].tevs,
2680 max_tevs, 2681 max_tevs,
2681 target); 2682 pkgs[i].pev->target);
2682 if (ret < 0) 2683 if (ret < 0)
2683 goto end; 2684 goto end;
2684 pkgs[i].ntevs = ret; 2685 pkgs[i].ntevs = ret;
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index e01e9943139f..d6b783447be9 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -73,7 +73,8 @@ struct perf_probe_event {
73 char *group; /* Group name */ 73 char *group; /* Group name */
74 struct perf_probe_point point; /* Probe point */ 74 struct perf_probe_point point; /* Probe point */
75 int nargs; /* Number of arguments */ 75 int nargs; /* Number of arguments */
76 bool uprobes; 76 bool uprobes; /* Uprobe event flag */
77 char *target; /* Target binary */
77 struct perf_probe_arg *args; /* Arguments */ 78 struct perf_probe_arg *args; /* Arguments */
78}; 79};
79 80
@@ -124,8 +125,7 @@ extern int line_range__init(struct line_range *lr);
124extern const char *kernel_get_module_path(const char *module); 125extern const char *kernel_get_module_path(const char *module);
125 126
126extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs, 127extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
127 int max_probe_points, const char *module, 128 int max_probe_points, bool force_add);
128 bool force_add);
129extern int del_perf_probe_events(struct strlist *dellist); 129extern int del_perf_probe_events(struct strlist *dellist);
130extern int show_perf_probe_events(void); 130extern int show_perf_probe_events(void);
131extern int show_line_range(struct line_range *lr, const char *module, 131extern int show_line_range(struct line_range *lr, const char *module,