Skip to contentSkip to conversation

perf list: Replace --raw-dump with parse_options_subcommand()

PATCH In review Ramkumar Ramachandra 1 participant 2 messages Mar 27, 2014 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf list: Replace --raw-dump with parse_options_subcommand()

While adding usage information, 44d742e (perf list: Add usage, 2013-10-30) broke

  $ perf list --raw-dump

Remove this option, and use parse_options_subcommand() to provide a '--list-cmds'. The argument to 'perf list' is now treated like a subcommand. Update the completion script to reflect this change.

Fixes 44d742e01e6d (perf list: Add usage)
Cc Jiri Olsa <[email protected]>
Cc David Ahern <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/builtin-list.c     | 13 +++++++------
 tools/perf/perf-completion.sh |  6 +++---
 2 files changed, 10 insertions(+), 9 deletions(-)
tools/perf/builtin-list.c +7 -6
index 011195e..4e9e4e3 100644
@@ -22,13 +22,16 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 	const struct option list_options[] = {
 		OPT_END()
 	};
-	const char * const list_usage[] = {
-		"perf list [hw|sw|cache|tracepoint|pmu|event_glob]",
+	const char *const list_subcommands[] = { "hw", "sw", "cache", "tracepoint",
+						 "pmu", NULL };
+
+	const char *list_usage[] = {
+		"perf list {hw|sw|cache|tracepoint|pmu|event_glob}",
 		NULL
 	};
 
-	argc = parse_options(argc, argv, list_options, list_usage,
-			     PARSE_OPT_STOP_AT_NON_OPTION);
+	argc = parse_options_subcommand(argc, argv, list_options, list_subcommands,
+					list_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 
 	setup_pager();
 
@@ -53,8 +56,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;
tools/perf/perf-completion.sh +3 -3
index ae3a576..a1f867b 100644
@@ -119,10 +119,10 @@ __perf_main ()
 		fi
 	# List possible events for -e option
 	elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
-		evts=$($cmd list --raw-dump)
+		evts=$($cmd list --list-cmds)
 		__perfcomp_colon "$evts" "$cur"
-	# List subcommands for 'perf kvm'
-	elif [[ $prev == "kvm" ]]; then
+	# List subcommands for perf commands
+	elif [[ $prev == @(kvm|list) ]]; then
 		subcmds=$($cmd $prev --list-cmds)
 		__perfcomp_colon "$subcmds" "$cur"
 	# List long option names
Signature · 1 line
1.9.0.431.g014438b
#1 lore raw
Quoted 3 lines · Ramkumar Ramachandra
 tools/perf/builtin-list.c     | 13 +++++++------
 tools/perf/perf-completion.sh |  6 +++---
 2 files changed, 10 insertions(+), 9 deletions(-)

Please ignore this patch. Major thinko on my part.