diff options
author | Masami Hiramatsu <mhiramat@redhat.com> | 2009-12-15 10:32:47 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-15 14:22:05 -0500 |
commit | 7ef17aafc98406d01ebbf7fe98ef1332b70d20bb (patch) | |
tree | 83211db3bb008b7d5a1224cf499f33591ced4708 /tools/perf | |
parent | 62bdc1b38e2abf3f500229c3bf4c82d33575d1ae (diff) |
perf probe: Fix to show which probe point is not found
Fix perf probe to show which probe point is not found.
With out this patch, it shows just "No probe point found."
This doesn't help users if they specify several probes.
e.g.
# perf probe -f --add schedule --add test
Fatal: No probe point found.
This patch makes error message more helpful as below.
# perf probe --add schedule --add test
Fatal: Probe point 'test' not found. - probe not added.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <20091215153247.17436.49068.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-probe.c | 7 | ||||
-rw-r--r-- | tools/perf/util/probe-event.c | 34 | ||||
-rw-r--r-- | tools/perf/util/probe-event.h | 1 |
3 files changed, 30 insertions, 12 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 6b0e4cf322d8..520b064b46d8 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -265,8 +265,11 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) | |||
265 | ret = find_probepoint(fd, pp); | 265 | ret = find_probepoint(fd, pp); |
266 | if (ret > 0) | 266 | if (ret > 0) |
267 | continue; | 267 | continue; |
268 | if (ret == 0) /* No error but failed to find probe point. */ | 268 | if (ret == 0) { /* No error but failed to find probe point. */ |
269 | die("No probe point found."); | 269 | synthesize_perf_probe_point(pp); |
270 | die("Probe point '%s' not found. - probe not added.", | ||
271 | pp->probes[0]); | ||
272 | } | ||
270 | /* Error path */ | 273 | /* Error path */ |
271 | if (session.need_dwarf) { | 274 | if (session.need_dwarf) { |
272 | if (ret == -ENOENT) | 275 | if (ret == -ENOENT) |
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index b05d532a4e4c..2ca62154f79b 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -249,11 +249,12 @@ void parse_trace_kprobe_event(const char *str, struct probe_point *pp) | |||
249 | argv_free(argv); | 249 | argv_free(argv); |
250 | } | 250 | } |
251 | 251 | ||
252 | int synthesize_perf_probe_event(struct probe_point *pp) | 252 | /* Synthesize only probe point (not argument) */ |
253 | int synthesize_perf_probe_point(struct probe_point *pp) | ||
253 | { | 254 | { |
254 | char *buf; | 255 | char *buf; |
255 | char offs[64] = "", line[64] = ""; | 256 | char offs[64] = "", line[64] = ""; |
256 | int i, len, ret; | 257 | int ret; |
257 | 258 | ||
258 | pp->probes[0] = buf = zalloc(MAX_CMDLEN); | 259 | pp->probes[0] = buf = zalloc(MAX_CMDLEN); |
259 | if (!buf) | 260 | if (!buf) |
@@ -274,10 +275,24 @@ int synthesize_perf_probe_event(struct probe_point *pp) | |||
274 | offs, pp->retprobe ? "%return" : "", line); | 275 | offs, pp->retprobe ? "%return" : "", line); |
275 | else | 276 | else |
276 | ret = e_snprintf(buf, MAX_CMDLEN, "%s%s", pp->file, line); | 277 | ret = e_snprintf(buf, MAX_CMDLEN, "%s%s", pp->file, line); |
277 | if (ret <= 0) | 278 | if (ret <= 0) { |
278 | goto error; | 279 | error: |
279 | len = ret; | 280 | free(pp->probes[0]); |
281 | pp->probes[0] = NULL; | ||
282 | } | ||
283 | return ret; | ||
284 | } | ||
285 | |||
286 | int synthesize_perf_probe_event(struct probe_point *pp) | ||
287 | { | ||
288 | char *buf; | ||
289 | int i, len, ret; | ||
280 | 290 | ||
291 | len = synthesize_perf_probe_point(pp); | ||
292 | if (len < 0) | ||
293 | return 0; | ||
294 | |||
295 | buf = pp->probes[0]; | ||
281 | for (i = 0; i < pp->nr_args; i++) { | 296 | for (i = 0; i < pp->nr_args; i++) { |
282 | ret = e_snprintf(&buf[len], MAX_CMDLEN - len, " %s", | 297 | ret = e_snprintf(&buf[len], MAX_CMDLEN - len, " %s", |
283 | pp->args[i]); | 298 | pp->args[i]); |
@@ -290,6 +305,7 @@ int synthesize_perf_probe_event(struct probe_point *pp) | |||
290 | return pp->found; | 305 | return pp->found; |
291 | error: | 306 | error: |
292 | free(pp->probes[0]); | 307 | free(pp->probes[0]); |
308 | pp->probes[0] = NULL; | ||
293 | 309 | ||
294 | return ret; | 310 | return ret; |
295 | } | 311 | } |
@@ -319,6 +335,7 @@ int synthesize_trace_kprobe_event(struct probe_point *pp) | |||
319 | return pp->found; | 335 | return pp->found; |
320 | error: | 336 | error: |
321 | free(pp->probes[0]); | 337 | free(pp->probes[0]); |
338 | pp->probes[0] = NULL; | ||
322 | 339 | ||
323 | return ret; | 340 | return ret; |
324 | } | 341 | } |
@@ -418,7 +435,7 @@ static void show_perf_probe_event(const char *event, const char *place, | |||
418 | /* List up current perf-probe events */ | 435 | /* List up current perf-probe events */ |
419 | void show_perf_probe_events(void) | 436 | void show_perf_probe_events(void) |
420 | { | 437 | { |
421 | int fd, nr; | 438 | int fd; |
422 | struct probe_point pp; | 439 | struct probe_point pp; |
423 | struct strlist *rawlist; | 440 | struct strlist *rawlist; |
424 | struct str_node *ent; | 441 | struct str_node *ent; |
@@ -430,10 +447,7 @@ void show_perf_probe_events(void) | |||
430 | strlist__for_each(ent, rawlist) { | 447 | strlist__for_each(ent, rawlist) { |
431 | parse_trace_kprobe_event(ent->s, &pp); | 448 | parse_trace_kprobe_event(ent->s, &pp); |
432 | /* Synthesize only event probe point */ | 449 | /* Synthesize only event probe point */ |
433 | nr = pp.nr_args; | 450 | synthesize_perf_probe_point(&pp); |
434 | pp.nr_args = 0; | ||
435 | synthesize_perf_probe_event(&pp); | ||
436 | pp.nr_args = nr; | ||
437 | /* Show an event */ | 451 | /* Show an event */ |
438 | show_perf_probe_event(pp.event, pp.probes[0], &pp); | 452 | show_perf_probe_event(pp.event, pp.probes[0], &pp); |
439 | clear_probe_point(&pp); | 453 | clear_probe_point(&pp); |
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h index 8fd30525100c..7f1d499118c0 100644 --- a/tools/perf/util/probe-event.h +++ b/tools/perf/util/probe-event.h | |||
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | extern void parse_perf_probe_event(const char *str, struct probe_point *pp, | 8 | extern void parse_perf_probe_event(const char *str, struct probe_point *pp, |
9 | bool *need_dwarf); | 9 | bool *need_dwarf); |
10 | extern int synthesize_perf_probe_point(struct probe_point *pp); | ||
10 | extern int synthesize_perf_probe_event(struct probe_point *pp); | 11 | extern int synthesize_perf_probe_event(struct probe_point *pp); |
11 | extern void parse_trace_kprobe_event(const char *str, struct probe_point *pp); | 12 | extern void parse_trace_kprobe_event(const char *str, struct probe_point *pp); |
12 | extern int synthesize_trace_kprobe_event(struct probe_point *pp); | 13 | extern int synthesize_trace_kprobe_event(struct probe_point *pp); |