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

perf list: Add usage

Currently 'perf list' is not very helpful if you forget the syntax:

$ perf list -h

List of pre-defined events (to be used in -e):

After:
$ perf list -h

usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/527133AD.4030003@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

David Ahern and committed by
Arnaldo Carvalho de Melo
44d742e0 8e00ddc9

+14 -3
+14 -3
tools/perf/builtin-list.c
··· 14 14 #include "util/parse-events.h" 15 15 #include "util/cache.h" 16 16 #include "util/pmu.h" 17 + #include "util/parse-options.h" 17 18 18 19 int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) 19 20 { 20 21 int i; 22 + const struct option list_options[] = { 23 + OPT_END() 24 + }; 25 + const char * const list_usage[] = { 26 + "perf list [hw|sw|cache|tracepoint|pmu|event_glob]", 27 + NULL 28 + }; 29 + 30 + argc = parse_options(argc, argv, list_options, list_usage, 31 + PARSE_OPT_STOP_AT_NON_OPTION); 21 32 22 33 setup_pager(); 23 34 24 - if (argc == 1) { 35 + if (argc == 0) { 25 36 print_events(NULL, false); 26 37 return 0; 27 38 } 28 39 29 - for (i = 1; i < argc; ++i) { 30 - if (i > 2) 40 + for (i = 0; i < argc; ++i) { 41 + if (i) 31 42 putchar('\n'); 32 43 if (strncmp(argv[i], "tracepoint", 10) == 0) 33 44 print_tracepoint_events(NULL, NULL, false);