Skip to content

Commit d2bedb7

Browse files
Stephane Eranianacmel
authored andcommitted
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 <[email protected]> Reviewed-by: Ian Rogers <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 376c3c2 commit d2bedb7

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

tools/perf/util/event.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,23 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
617617
al->sym = map__find_symbol(al->map, al->addr);
618618
}
619619

620-
if (symbol_conf.sym_list &&
621-
(!al->sym || !strlist__has_entry(symbol_conf.sym_list,
622-
al->sym->name))) {
623-
al->filtered |= (1 << HIST_FILTER__SYMBOL);
620+
if (symbol_conf.sym_list) {
621+
int ret = 0;
622+
char al_addr_str[32];
623+
size_t sz = sizeof(al_addr_str);
624+
625+
if (al->sym) {
626+
ret = strlist__has_entry(symbol_conf.sym_list,
627+
al->sym->name);
628+
}
629+
if (!(ret && al->sym)) {
630+
snprintf(al_addr_str, sz, "0x%"PRIx64,
631+
al->map->unmap_ip(al->map, al->sym->start));
632+
ret = strlist__has_entry(symbol_conf.sym_list,
633+
al_addr_str);
634+
}
635+
if (!ret)
636+
al->filtered |= (1 << HIST_FILTER__SYMBOL);
624637
}
625638

626639
return 0;

0 commit comments

Comments
 (0)