linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf list: Fix --raw-dump argument
@ 2014-03-27 21:27 Ramkumar Ramachandra
  2014-04-09 12:58 ` Jiri Olsa
  0 siblings, 1 reply; 3+ messages in thread
From: Ramkumar Ramachandra @ 2014-03-27 21:27 UTC (permalink / raw)
  To: LKML; +Cc: David Ahern, Jiri Olsa, Arnaldo Carvalho de Melo

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

  $ perf list --raw-dump

Fix this by making raw-dump a proper argument.

Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 I sent this patch earlier, but it didn't get picked up due to some
 confusion.

 tools/perf/builtin-list.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 011195e..2629c24 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -19,7 +19,9 @@
 int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 {
 	int i;
+	bool raw_dump = false;
 	const struct option list_options[] = {
+		OPT_BOOLEAN(0, "raw-dump", &raw_dump, "raw dump for completion"),
 		OPT_END()
 	};
 	const char * const list_usage[] = {
@@ -32,6 +34,10 @@ 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 +59,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;
-- 
1.9.0.431.g014438b


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf list: Fix --raw-dump argument
  2014-03-27 21:27 [PATCH] perf list: Fix --raw-dump argument Ramkumar Ramachandra
@ 2014-04-09 12:58 ` Jiri Olsa
  2014-04-11  0:43   ` Ramkumar Ramachandra
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2014-04-09 12:58 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: LKML, David Ahern, Arnaldo Carvalho de Melo

On Thu, Mar 27, 2014 at 05:27:41PM -0400, Ramkumar Ramachandra wrote:
> While adding usage information, 44d742e (perf list: Add usage,
> 2013-10-30) broke
> 
>   $ perf list --raw-dump
> 
> Fix this by making raw-dump a proper argument.
> 
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  I sent this patch earlier, but it didn't get picked up due to some
>  confusion.
> 
>  tools/perf/builtin-list.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
> index 011195e..2629c24 100644
> --- a/tools/perf/builtin-list.c
> +++ b/tools/perf/builtin-list.c
> @@ -19,7 +19,9 @@
>  int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
>  {
>  	int i;
> +	bool raw_dump = false;
>  	const struct option list_options[] = {
> +		OPT_BOOLEAN(0, "raw-dump", &raw_dump, "raw dump for completion"),
>  		OPT_END()
>  	};
>  	const char * const list_usage[] = {
> @@ -32,6 +34,10 @@ 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 +59,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;
> -- 
> 1.9.0.431.g014438b
> 

hi,
I understand you're just fixing a bug, but if it's an --raw-dump
option (not command) shoudn't we use it for all commands? like:

  $ perf list --raw-dump      # all events via raw dump
  $ perf list --raw-dump pmu  # pmu event via raw dump
  ...

Please check attached change to your patch below (not completely working/tested).

Also.. the option is not mentioned in the man page (please do ;-)),
but looks like the usage is for bash completion only, so we probably
need only the first example functionality above.

If this is the case I think it should not be an option but another
command like 'raw-dump'.

thanks,
jirka


---
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 2629c24..a3b2da8 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -34,12 +34,8 @@ 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);
+		print_events(NULL, raw_dump);
 		return 0;
 	}
 
@@ -47,7 +43,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 		if (i)
 			putchar('\n');
 		if (strncmp(argv[i], "tracepoint", 10) == 0)
-			print_tracepoint_events(NULL, NULL, false);
+			print_tracepoint_events(NULL, NULL, raw_dump);
 		else if (strcmp(argv[i], "hw") == 0 ||
 			 strcmp(argv[i], "hardware") == 0)
 			print_events_type(PERF_TYPE_HARDWARE);
@@ -56,15 +52,15 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 			print_events_type(PERF_TYPE_SOFTWARE);
 		else if (strcmp(argv[i], "cache") == 0 ||
 			 strcmp(argv[i], "hwcache") == 0)
-			print_hwcache_events(NULL, false);
+			print_hwcache_events(NULL, raw_dump);
 		else if (strcmp(argv[i], "pmu") == 0)
-			print_pmu_events(NULL, false);
+			print_pmu_events(NULL, raw_dump);
 		else {
 			char *sep = strchr(argv[i], ':'), *s;
 			int sep_idx;
 
 			if (sep == NULL) {
-				print_events(argv[i], false);
+				print_events(argv[i], raw_dump);
 				continue;
 			}
 			sep_idx = sep - argv[i];
@@ -73,7 +69,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 				return -1;
 
 			s[sep_idx] = '\0';
-			print_tracepoint_events(s, s + sep_idx + 1, false);
+			print_tracepoint_events(s, s + sep_idx + 1, raw_dump);
 			free(s);
 		}
 	}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf list: Fix --raw-dump argument
  2014-04-09 12:58 ` Jiri Olsa
@ 2014-04-11  0:43   ` Ramkumar Ramachandra
  0 siblings, 0 replies; 3+ messages in thread
From: Ramkumar Ramachandra @ 2014-04-11  0:43 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: LKML, David Ahern, Arnaldo Carvalho de Melo

Jiri Olsa wrote:
> but looks like the usage is for bash completion only, so we probably
> need only the first example functionality above.
>
> If this is the case I think it should not be an option but another
> command like 'raw-dump'.

I decided that there's no point making it an option, so I've sent you
a patch making it a subcommand instead.

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-11  0:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-27 21:27 [PATCH] perf list: Fix --raw-dump argument Ramkumar Ramachandra
2014-04-09 12:58 ` Jiri Olsa
2014-04-11  0:43   ` Ramkumar Ramachandra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).