OSDN Git Service

perf tools: Fix maps__find_symbol_by_name()
authorAdrian Hunter <adrian.hunter@intel.com>
Fri, 7 Sep 2018 08:51:16 +0000 (11:51 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:39:34 +0000 (08:39 +0200)
commit1f3cb0604f0f5d1669d204cf610ffde3cfef17cc
tree05c8a7d18e0b8cacf34034294a6219879834bccb
parenta543f61a277501e1dbf4f059968f42fdc57e7c6b
perf tools: Fix maps__find_symbol_by_name()

commit 03db8b583d1c3c84963e08e2abf6c79081da5c31 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/perf/util/map.c