Skip to content

Commit 03db8b5

Browse files
ahunter6acmel
authored andcommitted
perf tools: Fix maps__find_symbol_by_name()
Commit 1c5aae7 ("perf machine: Create maps for x86 PTI entry trampolines") revealed a problem with maps__find_symbol_by_name() that resulted in probes not being found e.g. $ sudo perf probe xsk_mmap xsk_mmap is out of .text, skip it. Probe point 'xsk_mmap' not found. Error: Failed to add events. maps__find_symbol_by_name() can optionally return the map of the found symbol. It can get the map wrong because, in fact, the symbol is found on the map's dso, not allowing for the possibility that the dso has more than one map. Fix by always checking the map contains the symbol. Reported-by: Björn Töpel <[email protected]> Signed-off-by: Adrian Hunter <[email protected]> Tested-by: Björn Töpel <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: [email protected] Fixes: 1c5aae7 ("perf machine: Create maps for x86 PTI entry trampolines") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 5db48a8 commit 03db8b5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/perf/util/map.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,13 @@ struct symbol *map_groups__find_symbol(struct map_groups *mg,
576576
return NULL;
577577
}
578578

579+
static bool map__contains_symbol(struct map *map, struct symbol *sym)
580+
{
581+
u64 ip = map->unmap_ip(map, sym->start);
582+
583+
return ip >= map->start && ip < map->end;
584+
}
585+
579586
struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
580587
struct map **mapp)
581588
{
@@ -591,6 +598,10 @@ struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
591598

592599
if (sym == NULL)
593600
continue;
601+
if (!map__contains_symbol(pos, sym)) {
602+
sym = NULL;
603+
continue;
604+
}
594605
if (mapp != NULL)
595606
*mapp = pos;
596607
goto out;

0 commit comments

Comments
 (0)