diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2014-06-06 03:13:52 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-06-09 13:34:09 -0400 |
commit | b4bf1130cdee7d5247bd3171530869809f5aca54 (patch) | |
tree | 3953290fe4598bc5557d5fe66f47f7519008e7f6 /tools/perf/builtin-probe.c | |
parent | 36d789a4d75f3826faa6e75b018942b63ffed1a0 (diff) |
perf probe: Show error code and description in verbose mode
Show error code and description only in verbose mode if 'perf probe'
command failed.
Current 'perf probe' shows error code with final error message, and that
is meaningless for many users.
This changes error messages to show the error code and its description
only in verbose mode (-v option).
Without this patch:
-----
# perf probe -a do_execve@hoge
Probe point 'do_execve@hoge' not found.
Error: Failed to add events. (-2)
-----
With this patch, normally the message doesn't show the misterious error
number:
-----
# perf probe -a do_execve@hoge
Probe point 'do_execve@hoge' not found.
Error: Failed to add events.
-----
And in verbose mode, it also shows additional error messages as below:
-----
# perf probe -va do_execve@hoge
probe-definition(0): do_execve@hoge
symbol:do_execve file:hoge line:0 offset:0 return:0 lazy:(null)
0 arguments
Looking at the vmlinux_path (6 entries long)
Using /lib/modules/3.15.0-rc8+/build/vmlinux for symbols
Open Debuginfo file: /lib/modules/3.15.0-rc8+/build/vmlinux
Try to find probe point from debuginfo.
Probe point 'do_execve@hoge' not found.
Error: Failed to add events. Reason: No such file or directory (Code: -2)
-----
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20140606071352.6788.76943.stgit@kbuild-fedora.novalocal
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-probe.c')
-rw-r--r-- | tools/perf/builtin-probe.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index cdcd4eb3a57d..c63fa2925075 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -288,6 +288,13 @@ static void cleanup_params(void) | |||
288 | memset(¶ms, 0, sizeof(params)); | 288 | memset(¶ms, 0, sizeof(params)); |
289 | } | 289 | } |
290 | 290 | ||
291 | static void pr_err_with_code(const char *msg, int err) | ||
292 | { | ||
293 | pr_err("%s", msg); | ||
294 | pr_debug(" Reason: %s (Code: %d)", strerror(-err), err); | ||
295 | pr_err("\n"); | ||
296 | } | ||
297 | |||
291 | static int | 298 | static int |
292 | __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | 299 | __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) |
293 | { | 300 | { |
@@ -379,7 +386,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
379 | } | 386 | } |
380 | ret = parse_probe_event_argv(argc, argv); | 387 | ret = parse_probe_event_argv(argc, argv); |
381 | if (ret < 0) { | 388 | if (ret < 0) { |
382 | pr_err(" Error: Parse Error. (%d)\n", ret); | 389 | pr_err_with_code(" Error: Command Parse Error.", ret); |
383 | return ret; | 390 | return ret; |
384 | } | 391 | } |
385 | } | 392 | } |
@@ -419,8 +426,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
419 | } | 426 | } |
420 | ret = show_perf_probe_events(); | 427 | ret = show_perf_probe_events(); |
421 | if (ret < 0) | 428 | if (ret < 0) |
422 | pr_err(" Error: Failed to show event list. (%d)\n", | 429 | pr_err_with_code(" Error: Failed to show event list.", ret); |
423 | ret); | ||
424 | return ret; | 430 | return ret; |
425 | } | 431 | } |
426 | if (params.show_funcs) { | 432 | if (params.show_funcs) { |
@@ -445,8 +451,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
445 | strfilter__delete(params.filter); | 451 | strfilter__delete(params.filter); |
446 | params.filter = NULL; | 452 | params.filter = NULL; |
447 | if (ret < 0) | 453 | if (ret < 0) |
448 | pr_err(" Error: Failed to show functions." | 454 | pr_err_with_code(" Error: Failed to show functions.", ret); |
449 | " (%d)\n", ret); | ||
450 | return ret; | 455 | return ret; |
451 | } | 456 | } |
452 | 457 | ||
@@ -464,7 +469,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
464 | 469 | ||
465 | ret = show_line_range(¶ms.line_range, params.target); | 470 | ret = show_line_range(¶ms.line_range, params.target); |
466 | if (ret < 0) | 471 | if (ret < 0) |
467 | pr_err(" Error: Failed to show lines. (%d)\n", ret); | 472 | pr_err_with_code(" Error: Failed to show lines.", ret); |
468 | return ret; | 473 | return ret; |
469 | } | 474 | } |
470 | if (params.show_vars) { | 475 | if (params.show_vars) { |
@@ -485,7 +490,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
485 | strfilter__delete(params.filter); | 490 | strfilter__delete(params.filter); |
486 | params.filter = NULL; | 491 | params.filter = NULL; |
487 | if (ret < 0) | 492 | if (ret < 0) |
488 | pr_err(" Error: Failed to show vars. (%d)\n", ret); | 493 | pr_err_with_code(" Error: Failed to show vars.", ret); |
489 | return ret; | 494 | return ret; |
490 | } | 495 | } |
491 | #endif | 496 | #endif |
@@ -493,7 +498,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
493 | if (params.dellist) { | 498 | if (params.dellist) { |
494 | ret = del_perf_probe_events(params.dellist); | 499 | ret = del_perf_probe_events(params.dellist); |
495 | if (ret < 0) { | 500 | if (ret < 0) { |
496 | pr_err(" Error: Failed to delete events. (%d)\n", ret); | 501 | pr_err_with_code(" Error: Failed to delete events.", ret); |
497 | return ret; | 502 | return ret; |
498 | } | 503 | } |
499 | } | 504 | } |
@@ -504,7 +509,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
504 | params.target, | 509 | params.target, |
505 | params.force_add); | 510 | params.force_add); |
506 | if (ret < 0) { | 511 | if (ret < 0) { |
507 | pr_err(" Error: Failed to add events. (%d)\n", ret); | 512 | pr_err_with_code(" Error: Failed to add events.", ret); |
508 | return ret; | 513 | return ret; |
509 | } | 514 | } |
510 | } | 515 | } |