linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump
@ 2016-09-18 18:18 Andi Kleen
  2016-09-18 18:18 ` [PATCH 2/2] perf, tools: Fix completion script to handle comma list Andi Kleen
  2016-09-19  8:14 ` [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Jiri Olsa
  0 siblings, 2 replies; 4+ messages in thread
From: Andi Kleen @ 2016-09-18 18:18 UTC (permalink / raw)
  To: acme; +Cc: jolsa, linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Print aliases like 'cycles' with perf list --raw-dump, so that
they can be completed by perf-completion.sh

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/util/parse-events.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 94846271cb1c..9716c2bc6869 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2191,13 +2191,21 @@ restart:
 
 		if (!evt_num_known) {
 			evt_num++;
+			if (strlen(syms->alias))
+				evt_num++;
 			continue;
 		}
 
 		if (!name_only && strlen(syms->alias))
 			snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias);
-		else
+		else {
+			if (strlen(syms->alias)) {
+				evt_list[evt_i++] = strdup(syms->alias);
+				if (evt_list[evt_i - 1]  == NULL)
+					goto out_enomem;
+			}
 			strncpy(name, syms->symbol, MAX_NAME_LEN);
+		}
 
 		evt_list[evt_i] = strdup(name);
 		if (evt_list[evt_i] == NULL)
-- 
2.5.5

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

* [PATCH 2/2] perf, tools: Fix completion script to handle comma list
  2016-09-18 18:18 [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Andi Kleen
@ 2016-09-18 18:18 ` Andi Kleen
  2016-09-19  8:14 ` [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Jiri Olsa
  1 sibling, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2016-09-18 18:18 UTC (permalink / raw)
  To: acme; +Cc: jolsa, linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

The perf event completion script only handled a single event per
-e option. So for "perf stat -e cycles,branches" branches could
not be completed.

Fix that issue by always only using the last suffix.

For some reason it only works in bash currently, but zsh
is the same as before.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/perf-completion.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
index 3ba80b2359cc..14c2be73b6fd 100644
--- a/tools/perf/perf-completion.sh
+++ b/tools/perf/perf-completion.sh
@@ -162,7 +162,11 @@ __perf_main ()
 	elif [[ $prev == @("-e"|"--event") &&
 		$prev_skip_opts == @(record|stat|top) ]]; then
 		evts=$($cmd list --raw-dump)
+		old="$cur"
+		cur="${cur/*[,{]/}"
+		prefix=${old%$cur}
 		__perfcomp_colon "$evts" "$cur"
+		COMPREPLY=("${prefix}${COMPREPLY[0]}")
 	else
 		# List subcommands for perf commands
 		if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|
-- 
2.5.5

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

* Re: [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump
  2016-09-18 18:18 [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Andi Kleen
  2016-09-18 18:18 ` [PATCH 2/2] perf, tools: Fix completion script to handle comma list Andi Kleen
@ 2016-09-19  8:14 ` Jiri Olsa
  2016-09-19 16:07   ` Andi Kleen
  1 sibling, 1 reply; 4+ messages in thread
From: Jiri Olsa @ 2016-09-19  8:14 UTC (permalink / raw)
  To: Andi Kleen; +Cc: acme, jolsa, linux-kernel, Andi Kleen

On Sun, Sep 18, 2016 at 11:18:18AM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> Print aliases like 'cycles' with perf list --raw-dump, so that
> they can be completed by perf-completion.sh
> 
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  tools/perf/util/parse-events.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 94846271cb1c..9716c2bc6869 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -2191,13 +2191,21 @@ restart:
>  
>  		if (!evt_num_known) {
>  			evt_num++;
> +			if (strlen(syms->alias))
> +				evt_num++;
>  			continue;
>  		}
>  
>  		if (!name_only && strlen(syms->alias))
>  			snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias);
> -		else
> +		else {
> +			if (strlen(syms->alias)) {
> +				evt_list[evt_i++] = strdup(syms->alias);

why don't you copy syms->alias into name and let the code below do the queue?

thanks,
jirka

> +				if (evt_list[evt_i - 1]  == NULL)
> +					goto out_enomem;
> +			}
>  			strncpy(name, syms->symbol, MAX_NAME_LEN);
> +		}
>  
>  		evt_list[evt_i] = strdup(name);
>  		if (evt_list[evt_i] == NULL)
> -- 
> 2.5.5
> 

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

* Re: [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump
  2016-09-19  8:14 ` [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Jiri Olsa
@ 2016-09-19 16:07   ` Andi Kleen
  0 siblings, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2016-09-19 16:07 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: Andi Kleen, acme, jolsa, linux-kernel

> why don't you copy syms->alias into name and let the code below do the queue?

Because it needs to queue two entries, not just a single one.

-Andi

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

end of thread, other threads:[~2016-09-19 16:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-18 18:18 [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Andi Kleen
2016-09-18 18:18 ` [PATCH 2/2] perf, tools: Fix completion script to handle comma list Andi Kleen
2016-09-19  8:14 ` [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Jiri Olsa
2016-09-19 16:07   ` Andi Kleen

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).