]> Git Repo - linux.git/commitdiff
perf tools: Fix maps__find_symbol_by_name()
authorAdrian Hunter <[email protected]>
Fri, 7 Sep 2018 08:51:16 +0000 (11:51 +0300)
committerArnaldo Carvalho de Melo <[email protected]>
Tue, 11 Sep 2018 17:12:51 +0000 (14:12 -0300)
Commit 1c5aae7710bb ("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: 1c5aae7710bb ("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]>
tools/perf/util/map.c

index 36d0763311efccec1adfb498cd39154266997f26..6a6929f208b4da042eeece3006f9c53740002289 100644 (file)
@@ -576,6 +576,13 @@ struct symbol *map_groups__find_symbol(struct map_groups *mg,
        return NULL;
 }
 
+static bool map__contains_symbol(struct map *map, struct symbol *sym)
+{
+       u64 ip = map->unmap_ip(map, sym->start);
+
+       return ip >= map->start && ip < map->end;
+}
+
 struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
                                         struct map **mapp)
 {
@@ -591,6 +598,10 @@ struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
 
                if (sym == NULL)
                        continue;
+               if (!map__contains_symbol(pos, sym)) {
+                       sym = NULL;
+                       continue;
+               }
                if (mapp != NULL)
                        *mapp = pos;
                goto out;
This page took 0.06204 seconds and 4 git commands to generate.