Skip to contentSkip to conversation

perf list: Fix --raw-dump option

PATCH In review Taesoo Kim 2 participants 2 messages Dec 27, 2014 – Dec 29, 2014 perf events

lore
Share & tools
lore

Taesoo Kim

author
#0 lore raw

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 ...
---
 tools/perf/builtin-list.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/perf/builtin-list.c +9 -3
index 011195e..ec76bee 100644
@@ -16,14 +16,17 @@
 #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[] = {
+		OPT_BOOLEAN(0, "raw-dump", &raw_dump, "Dump raw events"),
 		OPT_END()
 	};
 	const char * const list_usage[] = {
-		"perf list [hw|sw|cache|tracepoint|pmu|event_glob]",
+		"perf list [hw|sw|cache|tracepoint|pmu|event_glob|--raw-dump]",
 		NULL
 	};
 
@@ -32,6 +35,11 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	setup_pager();
 
+	if (raw_dump) {
+		print_events(NULL, true);
+		return 0;
+	}
+
 	if (argc == 0) {
 		print_events(NULL, false);
 		return 0;
@@ -53,8 +61,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
maintainer Acked-by on v1 1/1
#1 lore raw

Hi Taesoo,

Quoted 7 lines · Taesoo Kim

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'
Quoted 8 lines

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

After,

  $ perf list --raw-dump
  cpu-cycles instructions cache-references cache-misses ...

Thanks for fixing this. Actually the --raw-dump option is intended to support shell completion and not to be used directly. I didn't update the completion script for a while so didn't notice it. It seems like recent updates of the option parsing code broke this.

Quoted 16 lines
---
 tools/perf/builtin-list.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/perf/builtin-list.c +2 -0
index 011195e..ec76bee 100644
@@ -16,14 +16,17 @@
 #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)
 {

tools/perf/builtin-list.c line 31

Quoted 10 lines
tools/perf/builtin-list.c +2 -1
 	int i;
 	const struct option list_options[] = {
+		OPT_BOOLEAN(0, "raw-dump", &raw_dump, "Dump raw events"),
 		OPT_END()
 	};
 	const char * const list_usage[] = {
-		"perf list [hw|sw|cache|tracepoint|pmu|event_glob]",
+		"perf list [hw|sw|cache|tracepoint|pmu|event_glob|--raw-dump]",
 		NULL
 	};

So I'd like to keep the usage string as is and mark the option as hidden - i.e. using set_option_flag(list_options, 0, "raw-dump", PARSE_OPT_HIDDEN) before calling to parse_options().

With that,

Thanks,
Namhyung

Quoted 30 lines
tools/perf/builtin-list.c +5 -2
@@ -32,6 +35,11 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	setup_pager();
 
+	if (raw_dump) {
+		print_events(NULL, true);
+		return 0;
+	}
+
 	if (argc == 0) {
 		print_events(NULL, false);
 		return 0;
@@ -53,8 +61,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 · 7 lines
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/