linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/script: allow --symbol to accept hexadecimal addresses
@ 2020-03-25 22:08 Ian Rogers
  2020-03-31 19:11 ` Arnaldo Carvalho de Melo
  2020-04-04  8:41 ` [tip: perf/urgent] perf script: Allow " tip-bot2 for Stephane Eranian
  0 siblings, 2 replies; 4+ messages in thread
From: Ian Rogers @ 2020-03-25 22:08 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-kernel
  Cc: Stephane Eranian, Ian Rogers

From: Stephane Eranian <eranian@google.com>

This patch extends the perf script --symbols option to filter
on hexadecimal addresses in addition to symbol names. This makes
it easier to handle cases where symbols are aliased.

With this patch, it is possible to mix and match symbols and hexadecimal
addresses using the --symbols option.

$ perf script --symbols=noploop,0x4007a0

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/event.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index c5447ff516a2..c978a73fe475 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -599,10 +599,23 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
 		al->sym = map__find_symbol(al->map, al->addr);
 	}
 
-	if (symbol_conf.sym_list &&
-		(!al->sym || !strlist__has_entry(symbol_conf.sym_list,
-						al->sym->name))) {
-		al->filtered |= (1 << HIST_FILTER__SYMBOL);
+	if (symbol_conf.sym_list) {
+		int ret = 0;
+		char al_addr_str[32];
+		size_t sz = sizeof(al_addr_str);
+
+		if (al->sym) {
+			ret = strlist__has_entry(symbol_conf.sym_list,
+						al->sym->name);
+		}
+		if (!(ret && al->sym)) {
+			snprintf(al_addr_str, sz, "0x%"PRIx64,
+				al->map->unmap_ip(al->map, al->sym->start));
+			ret = strlist__has_entry(symbol_conf.sym_list,
+						al_addr_str);
+		}
+		if (!ret)
+			al->filtered |= (1 << HIST_FILTER__SYMBOL);
 	}
 
 	return 0;
-- 
2.25.1.696.g5e7596f4ac-goog


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

* Re: [PATCH] perf/script: allow --symbol to accept hexadecimal addresses
  2020-03-25 22:08 [PATCH] perf/script: allow --symbol to accept hexadecimal addresses Ian Rogers
@ 2020-03-31 19:11 ` Arnaldo Carvalho de Melo
  2020-04-02 17:43   ` Ian Rogers
  2020-04-04  8:41 ` [tip: perf/urgent] perf script: Allow " tip-bot2 for Stephane Eranian
  1 sibling, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-03-31 19:11 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, linux-kernel, Stephane Eranian

Em Wed, Mar 25, 2020 at 03:08:02PM -0700, Ian Rogers escreveu:
> From: Stephane Eranian <eranian@google.com>
> 
> This patch extends the perf script --symbols option to filter
> on hexadecimal addresses in addition to symbol names. This makes
> it easier to handle cases where symbols are aliased.
> 
> With this patch, it is possible to mix and match symbols and hexadecimal
> addresses using the --symbols option.
> 
> $ perf script --symbols=noploop,0x4007a0

Applied, can you please send a followup patch to the man page stating
that this is supported?

Thanks,

- Arnaldo
 
> Reviewed-by: Ian Rogers <irogers@google.com>
> Signed-off-by: Stephane Eranian <eranian@google.com>
> ---
>  tools/perf/util/event.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> index c5447ff516a2..c978a73fe475 100644
> --- a/tools/perf/util/event.c
> +++ b/tools/perf/util/event.c
> @@ -599,10 +599,23 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
>  		al->sym = map__find_symbol(al->map, al->addr);
>  	}
>  
> -	if (symbol_conf.sym_list &&
> -		(!al->sym || !strlist__has_entry(symbol_conf.sym_list,
> -						al->sym->name))) {
> -		al->filtered |= (1 << HIST_FILTER__SYMBOL);
> +	if (symbol_conf.sym_list) {
> +		int ret = 0;
> +		char al_addr_str[32];
> +		size_t sz = sizeof(al_addr_str);
> +
> +		if (al->sym) {
> +			ret = strlist__has_entry(symbol_conf.sym_list,
> +						al->sym->name);
> +		}
> +		if (!(ret && al->sym)) {
> +			snprintf(al_addr_str, sz, "0x%"PRIx64,
> +				al->map->unmap_ip(al->map, al->sym->start));
> +			ret = strlist__has_entry(symbol_conf.sym_list,
> +						al_addr_str);
> +		}
> +		if (!ret)
> +			al->filtered |= (1 << HIST_FILTER__SYMBOL);
>  	}
>  
>  	return 0;
> -- 
> 2.25.1.696.g5e7596f4ac-goog
> 

-- 

- Arnaldo

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

* Re: [PATCH] perf/script: allow --symbol to accept hexadecimal addresses
  2020-03-31 19:11 ` Arnaldo Carvalho de Melo
@ 2020-04-02 17:43   ` Ian Rogers
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Rogers @ 2020-04-02 17:43 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, LKML, Stephane Eranian

On Tue, Mar 31, 2020 at 12:11 PM Arnaldo Carvalho de Melo
<arnaldo.melo@gmail.com> wrote:
>
> Em Wed, Mar 25, 2020 at 03:08:02PM -0700, Ian Rogers escreveu:
> > From: Stephane Eranian <eranian@google.com>
> >
> > This patch extends the perf script --symbols option to filter
> > on hexadecimal addresses in addition to symbol names. This makes
> > it easier to handle cases where symbols are aliased.
> >
> > With this patch, it is possible to mix and match symbols and hexadecimal
> > addresses using the --symbols option.
> >
> > $ perf script --symbols=noploop,0x4007a0
>
> Applied, can you please send a followup patch to the man page stating
> that this is supported?

Many thanks! I've sent:
https://lore.kernel.org/lkml/20200402174130.140319-1-irogers@google.com/T/#u

Ian

> Thanks,
>
> - Arnaldo
>
> > Reviewed-by: Ian Rogers <irogers@google.com>
> > Signed-off-by: Stephane Eranian <eranian@google.com>
> > ---
> >  tools/perf/util/event.c | 21 +++++++++++++++++----
> >  1 file changed, 17 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> > index c5447ff516a2..c978a73fe475 100644
> > --- a/tools/perf/util/event.c
> > +++ b/tools/perf/util/event.c
> > @@ -599,10 +599,23 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
> >               al->sym = map__find_symbol(al->map, al->addr);
> >       }
> >
> > -     if (symbol_conf.sym_list &&
> > -             (!al->sym || !strlist__has_entry(symbol_conf.sym_list,
> > -                                             al->sym->name))) {
> > -             al->filtered |= (1 << HIST_FILTER__SYMBOL);
> > +     if (symbol_conf.sym_list) {
> > +             int ret = 0;
> > +             char al_addr_str[32];
> > +             size_t sz = sizeof(al_addr_str);
> > +
> > +             if (al->sym) {
> > +                     ret = strlist__has_entry(symbol_conf.sym_list,
> > +                                             al->sym->name);
> > +             }
> > +             if (!(ret && al->sym)) {
> > +                     snprintf(al_addr_str, sz, "0x%"PRIx64,
> > +                             al->map->unmap_ip(al->map, al->sym->start));
> > +                     ret = strlist__has_entry(symbol_conf.sym_list,
> > +                                             al_addr_str);
> > +             }
> > +             if (!ret)
> > +                     al->filtered |= (1 << HIST_FILTER__SYMBOL);
> >       }
> >
> >       return 0;
> > --
> > 2.25.1.696.g5e7596f4ac-goog
> >
>
> --
>
> - Arnaldo

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

* [tip: perf/urgent] perf script: Allow --symbol to accept hexadecimal addresses
  2020-03-25 22:08 [PATCH] perf/script: allow --symbol to accept hexadecimal addresses Ian Rogers
  2020-03-31 19:11 ` Arnaldo Carvalho de Melo
@ 2020-04-04  8:41 ` tip-bot2 for Stephane Eranian
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Stephane Eranian @ 2020-04-04  8:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Stephane Eranian, Ian Rogers, Alexander Shishkin, Jiri Olsa,
	Mark Rutland, Namhyung Kim, Peter Zijlstra,
	Arnaldo Carvalho de Melo, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     d2bedb7863e9817f71fe2332a85ecdbd0f264b4b
Gitweb:        https://git.kernel.org/tip/d2bedb7863e9817f71fe2332a85ecdbd0f264b4b
Author:        Stephane Eranian <eranian@google.com>
AuthorDate:    Wed, 25 Mar 2020 15:08:02 -07:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Fri, 03 Apr 2020 09:37:56 -03:00

perf script: Allow --symbol to accept hexadecimal addresses

This patch extends the perf script --symbols option to filter on
hexadecimal addresses in addition to symbol names. This makes it easier
to handle cases where symbols are aliased.

With this patch, it is possible to mix and match symbols and hexadecimal
addresses using the --symbols option.

  $ perf script --symbols=noploop,0x4007a0

Signed-off-by: Stephane Eranian <eranian@google.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200325220802.15039-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/event.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 824c038..dc0e112 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -617,10 +617,23 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
 		al->sym = map__find_symbol(al->map, al->addr);
 	}
 
-	if (symbol_conf.sym_list &&
-		(!al->sym || !strlist__has_entry(symbol_conf.sym_list,
-						al->sym->name))) {
-		al->filtered |= (1 << HIST_FILTER__SYMBOL);
+	if (symbol_conf.sym_list) {
+		int ret = 0;
+		char al_addr_str[32];
+		size_t sz = sizeof(al_addr_str);
+
+		if (al->sym) {
+			ret = strlist__has_entry(symbol_conf.sym_list,
+						al->sym->name);
+		}
+		if (!(ret && al->sym)) {
+			snprintf(al_addr_str, sz, "0x%"PRIx64,
+				al->map->unmap_ip(al->map, al->sym->start));
+			ret = strlist__has_entry(symbol_conf.sym_list,
+						al_addr_str);
+		}
+		if (!ret)
+			al->filtered |= (1 << HIST_FILTER__SYMBOL);
 	}
 
 	return 0;

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

end of thread, other threads:[~2020-04-04  8:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 22:08 [PATCH] perf/script: allow --symbol to accept hexadecimal addresses Ian Rogers
2020-03-31 19:11 ` Arnaldo Carvalho de Melo
2020-04-02 17:43   ` Ian Rogers
2020-04-04  8:41 ` [tip: perf/urgent] perf script: Allow " tip-bot2 for Stephane Eranian

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