aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2018-09-07 04:51:16 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-09-11 13:12:51 -0400
commit03db8b583d1c3c84963e08e2abf6c79081da5c31 (patch)
treebaf3600125c5b9937d9f5903b56e7e7651a0c2ec
parent5db48a8d01319620d390bf6d9da5410be14f98e3 (diff)
perf tools: Fix maps__find_symbol_by_name()
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 <bjorn.topel@intel.com> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Tested-by: Björn Töpel <bjorn.topel@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: stable@vger.kernel.org Fixes: 1c5aae7710bb ("perf machine: Create maps for x86 PTI entry trampolines") Link: http://lkml.kernel.org/r/20180907085116.25782-1-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/map.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 36d0763311ef..6a6929f208b4 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -576,6 +576,13 @@ struct symbol *map_groups__find_symbol(struct map_groups *mg,
576 return NULL; 576 return NULL;
577} 577}
578 578
579static 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
579struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, 586struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
580 struct map **mapp) 587 struct map **mapp)
581{ 588{
@@ -591,6 +598,10 @@ struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
591 598
592 if (sym == NULL) 599 if (sym == NULL)
593 continue; 600 continue;
601 if (!map__contains_symbol(pos, sym)) {
602 sym = NULL;
603 continue;
604 }
594 if (mapp != NULL) 605 if (mapp != NULL)
595 *mapp = pos; 606 *mapp = pos;
596 goto out; 607 goto out;