Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1485900 > unrolled thread

[PATCH 1/2] perf, tools, list: Print aliases with --raw-dump

Started byAndi Kleen <andi@firstfloor.org>
First post2016-09-18 20:20 +0200
Last post2016-09-19 18:10 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Andi Kleen <andi@firstfloor.org> - 2016-09-18 20:20 +0200
    Re: [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Jiri Olsa <jolsa@redhat.com> - 2016-09-19 10:20 +0200
      Re: [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Andi Kleen <ak@linux.intel.com> - 2016-09-19 18:10 +0200

#1485900 — [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump

FromAndi Kleen <andi@firstfloor.org>
Date2016-09-18 20:20 +0200
Subject[PATCH 1/2] perf, tools, list: Print aliases with --raw-dump
Message-ID<siOR3-35Q-7@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1486241

FromJiri Olsa <jolsa@redhat.com>
Date2016-09-19 10:20 +0200
Message-ID<sj1XX-2Zs-17@gated-at.bofh.it>
In reply to#1485900
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
> 

[toc] | [prev] | [next] | [standalone]


#1486634

FromAndi Kleen <ak@linux.intel.com>
Date2016-09-19 18:10 +0200
Message-ID<sj9iN-7Bu-5@gated-at.bofh.it>
In reply to#1486241
> 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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web