diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-10-22 11:15:49 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-10-29 08:32:47 -0400 |
commit | 13dcbbc0222f9768394b0a58ab84adcd630f48d6 (patch) | |
tree | 22087d69660c02c3c09e24614473e606a5a237be /tools/perf/builtin-probe.c | |
parent | 42bd71d0812ecd955cf65a14375ebe6a3195d979 (diff) |
perf probe: Use PARSE_OPT_EXCLUSIVE flag
The perf probe command has some exclusive options. Use new PARSE_OPT_EXCLUSIVE
flag to simplify the code and show more compact usage.
$ perf probe -l -a foo
Error: switch `a' cannot be used with switch `l'
usage: perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]
or: perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]
or: perf probe [<options>] --del '[GROUP:]EVENT' ...
or: perf probe --list
or: perf probe [<options>] --line 'LINEDESC'
or: perf probe [<options>] --vars 'PROBEPOINT'
-a, --add <[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT [[NAME=]ARG ...]>
probe point definition, where
GROUP: Group name (optional)
EVENT: Event name
FUNC: Function name
OFF: Offset from function entry (in byte)
%return: Put the probe at function return
SRC: Source code path
RL: Relative line number from function entry.
AL: Absolute line number in file.
PT: Lazy expression of line code.
ARG: Probe argument (local variable name or
kprobe-tracer argument format.)
-l, --list list up current probe events
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1413990949-13953-6-git-send-email-namhyung@kernel.org
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 | 54 |
1 files changed, 9 insertions, 45 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 7af26acf06d9..2d3577d1009d 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -312,7 +312,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
312 | #endif | 312 | #endif |
313 | NULL | 313 | NULL |
314 | }; | 314 | }; |
315 | const struct option options[] = { | 315 | struct option options[] = { |
316 | OPT_INCR('v', "verbose", &verbose, | 316 | OPT_INCR('v', "verbose", &verbose, |
317 | "be more verbose (show parsed arguments, etc)"), | 317 | "be more verbose (show parsed arguments, etc)"), |
318 | OPT_BOOLEAN('l', "list", ¶ms.list_events, | 318 | OPT_BOOLEAN('l', "list", ¶ms.list_events, |
@@ -382,6 +382,14 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
382 | }; | 382 | }; |
383 | int ret; | 383 | int ret; |
384 | 384 | ||
385 | set_option_flag(options, 'a', "add", PARSE_OPT_EXCLUSIVE); | ||
386 | set_option_flag(options, 'd', "del", PARSE_OPT_EXCLUSIVE); | ||
387 | set_option_flag(options, 'l', "list", PARSE_OPT_EXCLUSIVE); | ||
388 | #ifdef HAVE_DWARF_SUPPORT | ||
389 | set_option_flag(options, 'L', "line", PARSE_OPT_EXCLUSIVE); | ||
390 | set_option_flag(options, 'V', "vars", PARSE_OPT_EXCLUSIVE); | ||
391 | #endif | ||
392 | |||
385 | argc = parse_options(argc, argv, options, probe_usage, | 393 | argc = parse_options(argc, argv, options, probe_usage, |
386 | PARSE_OPT_STOP_AT_NON_OPTION); | 394 | PARSE_OPT_STOP_AT_NON_OPTION); |
387 | if (argc > 0) { | 395 | if (argc > 0) { |
@@ -409,22 +417,6 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
409 | symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL); | 417 | symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL); |
410 | 418 | ||
411 | if (params.list_events) { | 419 | if (params.list_events) { |
412 | if (params.mod_events) { | ||
413 | pr_err(" Error: Don't use --list with --add/--del.\n"); | ||
414 | usage_with_options(probe_usage, options); | ||
415 | } | ||
416 | if (params.show_lines) { | ||
417 | pr_err(" Error: Don't use --list with --line.\n"); | ||
418 | usage_with_options(probe_usage, options); | ||
419 | } | ||
420 | if (params.show_vars) { | ||
421 | pr_err(" Error: Don't use --list with --vars.\n"); | ||
422 | usage_with_options(probe_usage, options); | ||
423 | } | ||
424 | if (params.show_funcs) { | ||
425 | pr_err(" Error: Don't use --list with --funcs.\n"); | ||
426 | usage_with_options(probe_usage, options); | ||
427 | } | ||
428 | if (params.uprobes) { | 420 | if (params.uprobes) { |
429 | pr_warning(" Error: Don't use --list with --exec.\n"); | 421 | pr_warning(" Error: Don't use --list with --exec.\n"); |
430 | usage_with_options(probe_usage, options); | 422 | usage_with_options(probe_usage, options); |
@@ -435,19 +427,6 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
435 | return ret; | 427 | return ret; |
436 | } | 428 | } |
437 | if (params.show_funcs) { | 429 | if (params.show_funcs) { |
438 | if (params.nevents != 0 || params.dellist) { | ||
439 | pr_err(" Error: Don't use --funcs with" | ||
440 | " --add/--del.\n"); | ||
441 | usage_with_options(probe_usage, options); | ||
442 | } | ||
443 | if (params.show_lines) { | ||
444 | pr_err(" Error: Don't use --funcs with --line.\n"); | ||
445 | usage_with_options(probe_usage, options); | ||
446 | } | ||
447 | if (params.show_vars) { | ||
448 | pr_err(" Error: Don't use --funcs with --vars.\n"); | ||
449 | usage_with_options(probe_usage, options); | ||
450 | } | ||
451 | if (!params.filter) | 430 | if (!params.filter) |
452 | params.filter = strfilter__new(DEFAULT_FUNC_FILTER, | 431 | params.filter = strfilter__new(DEFAULT_FUNC_FILTER, |
453 | NULL); | 432 | NULL); |
@@ -462,16 +441,6 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
462 | 441 | ||
463 | #ifdef HAVE_DWARF_SUPPORT | 442 | #ifdef HAVE_DWARF_SUPPORT |
464 | if (params.show_lines) { | 443 | if (params.show_lines) { |
465 | if (params.mod_events) { | ||
466 | pr_err(" Error: Don't use --line with" | ||
467 | " --add/--del.\n"); | ||
468 | usage_with_options(probe_usage, options); | ||
469 | } | ||
470 | if (params.show_vars) { | ||
471 | pr_err(" Error: Don't use --line with --vars.\n"); | ||
472 | usage_with_options(probe_usage, options); | ||
473 | } | ||
474 | |||
475 | ret = show_line_range(¶ms.line_range, params.target, | 444 | ret = show_line_range(¶ms.line_range, params.target, |
476 | params.uprobes); | 445 | params.uprobes); |
477 | if (ret < 0) | 446 | if (ret < 0) |
@@ -479,11 +448,6 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | |||
479 | return ret; | 448 | return ret; |
480 | } | 449 | } |
481 | if (params.show_vars) { | 450 | if (params.show_vars) { |
482 | if (params.mod_events) { | ||
483 | pr_err(" Error: Don't use --vars with" | ||
484 | " --add/--del.\n"); | ||
485 | usage_with_options(probe_usage, options); | ||
486 | } | ||
487 | if (!params.filter) | 451 | if (!params.filter) |
488 | params.filter = strfilter__new(DEFAULT_VAR_FILTER, | 452 | params.filter = strfilter__new(DEFAULT_VAR_FILTER, |
489 | NULL); | 453 | NULL); |