perf list: Fix --raw-dump option
PATCH 1/1 perf list: Fix --raw-dump option
Currently, 'perf list --raw-dump' requires extra arguments (e.g., hw) to invoke, which breaks bash/zsh completion (perf-completion.sh).
$ perf list --raw-dump
Error: unknown option `raw-dump'usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
After,
$ perf list --raw-dump cpu-cycles instructions cache-references cache-misses ...
Signed-off-by Taesoo Kim <[email protected]>
--- tools/perf/builtin-list.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
tools/perf/builtin-list.c +11 -3
@@ -16,10 +16,13 @@#include "util/pmu.h" #include "util/parse-options.h" +static bool raw_dump = false; +int cmd_list (int argc,const char **argv,const char *prefix__maybe_unused ) {int i; -const struct option list_options[] = { +struct option list_options[] = { +OPT_BOOLEAN (0 ,"raw-dump" , &raw_dump,"Dump raw events" ),OPT_END () };const char *const list_usage[] = {
@@ -27,11 +30,18 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) NULL }; +set_option_flag (list_options,0 ,"raw-dump" ,PARSE_OPT_HIDDEN ); + argc =parse_options (argc, argv, list_options, list_usage,PARSE_OPT_STOP_AT_NON_OPTION );setup_pager (); +if (raw_dump) { +print_events (NULL , true); +return 0 ; + } +if (argc ==0 ) {print_events (NULL , false);return 0 ;
@@ -53,8 +63,6 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)print_hwcache_events (NULL , false); else if (strcmp(argv[i], "pmu") == 0) print_pmu_events(NULL, false); - else if (strcmp(argv[i], "--raw-dump") == 0) - print_events(NULL , true); else {char *sep =strchr (argv[i],':' ), *s;int sep_idx;
Signature · 1 line
2.1.3
Arnaldo Carvalho de Melo
maintainerEm Mon, Dec 29, 2014 at 12:02:50PM -0500, Taesoo Kim escreveu:
Quoted 24 lines
Currently, 'perf list --raw-dump' requires extra arguments (e.g., hw) to invoke, which breaks bash/zsh completion (
perf-completion.sh).$ perf list --raw-dump Error: unknown option `raw-dump'usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
After,
$ perf list --raw-dump cpu-cycles instructions cache-references cache-misses ...Signed-off-by Taesoo Kim <[email protected]>--- tools/perf/builtin-list.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)tools/perf/builtin-list.c +0
-0
tools/perf/builtin-list.c line 20
Quoted 5 lines
tools/perf/builtin-list.c +2
-0@@ -16,10 +16,13 @@#include "util/pmu.h" #include "util/parse-options.h" +static bool raw_dump = false; +
Why does this need to be a global static variable? Can't it be moved to...
tools/perf/builtin-list.c line 23
Quoted 3 lines
tools/perf/builtin-list.c +0
-0int cmd_list (int argc,const char **argv,const char *prefix__maybe_unused ) {int i;
... here?
+ bool raw_dump = false;
Quoted 36 lines
tools/perf/builtin-list.c +9
-3-const struct option list_options[] = { +struct option list_options[] = { +OPT_BOOLEAN (0 ,"raw-dump" , &raw_dump,"Dump raw events" ),OPT_END () };const char *const list_usage[] = {@@ -27,11 +30,18 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) NULL }; +set_option_flag (list_options,0 ,"raw-dump" ,PARSE_OPT_HIDDEN ); + argc =parse_options (argc, argv, list_options, list_usage,PARSE_OPT_STOP_AT_NON_OPTION );setup_pager (); +if (raw_dump) { +print_events (NULL , true); +return 0 ; + } +if (argc ==0 ) {print_events (NULL , false);return 0 ;@@ -53,8 +63,6 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)print_hwcache_events (NULL , false); else if (strcmp(argv[i], "pmu") == 0) print_pmu_events(NULL, false); - else if (strcmp(argv[i], "--raw-dump") == 0) - print_events(NULL , true); else {char *sep =strchr (argv[i],':' ), *s;int sep_idx;Signature · 1 line
2.1.3