perf/script: allow --symbol to accept hexadecimal addresses
Ian Rogers
reviewerPATCH 1/1 perf/script: allow --symbol to accept hexadecimal addresses
From: Stephane Eranian <[email protected]>
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
--- tools/perf/util/event.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
tools/perf/util/event.c +17 -4
@@ -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 ;
Signature · 1 line
2.25.1.696.g5e7596f4ac-goog
Arnaldo Carvalho de Melo
AppliedEm Wed, Mar 25, 2020 at 03:08:02PM -0700, Ian Rogers escreveu:
Quoted 10 lines
From: Stephane Eranian <[email protected]>
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
Quoted 41 lines
Reviewed-by Ian Rogers <[email protected]>Signed-off-by Stephane Eranian <[email protected]>--- tools/perf/util/event.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)tools/perf/util/event.c +17
-4@@ -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 ;Signature · 1 line
2.25.1.696.g5e7596f4ac-goog
Signature · 1 line
- Arnaldo
Ian Rogers
reviewerQuoted 8 lines · Arnaldo Carvalho de Melo
Em Wed, Mar 25, 2020 at 03:08:02PM -0700, Ian Rogers escreveu:
Quoted 6 lines
From: Stephane Eranian <[email protected]>
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.
Quoted 7 lines
Quoted 4 lines
With this patch, it is possible to mix and match symbols and hexadecimal addresses using the --symbols option.
$ perf script --symbols=noploop,0x4007a0Applied, 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/[email protected]/T/#u
Ian
Quoted 49 lines
Thanks,
- Arnaldo
Quoted 39 lines
Reviewed-by Ian Rogers <[email protected]>Signed-off-by Stephane Eranian <[email protected]>--- tools/perf/util/event.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)tools/perf/util/event.c +17
-5@@ -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 ; --Quoted 2 lines
2.25.1.696.g5e7596f4ac-goog
--
- Arnaldo
[tip: perf/urgent] perf script: Allow --symbol to accept hexadecimal addresses
In reply to Ian RogersThe following commit has been merged into the perf/urgent branch of tip:
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 <[email protected]> AuthorDate: Wed, 25 Mar 2020 15:08:02 -07:00 Committer: Arnaldo Carvalho de Melo <[email protected]> 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
--- tools/perf/util/event.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
tools/perf/util/event.c +17 -4
@@ -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 ;