[PATCH UEK5] perf symbols: Cannot disassemble some routines when debuginfo present
From: Eric Saint-Etienne
Date: Wed Dec 12 2018 - 11:11:57 EST
When the kernel is compiled with -ffunction-sections and perf uses the kernel
debuginfo, perf fails the very first symbol lookup and ends up with an offset
in [kernel.vmlinux]. It's due to how perf loads the .text map first then loads
the other maps in the kernel debuginfo image.
This issue is specific to the debuginfo when using -ffunction-sections and it
doesn't happen with kallsyms because there's not multiple stages of loading
/proc/kallsyms.
This patch makes sure that the event address we're looking up is indeed within
the map we've found, otherwise we look another map up again. Only one extra
lookup at most is required for the proper map to be found, if it exists.
Orabug: 28543586
Reviewed-by: Eric Saint-Etienne <eric.saint.etienne@xxxxxxxxxx>
---
tools/perf/util/event.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index fc690fe..1fbbaf1 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1447,6 +1447,19 @@ void thread__find_addr_map(struct thread *thread, u8 cpumode,
*/
if (load_map)
map__load(al->map);
+
+ /*
+ * Sometimes we find the wrong map: one whose end address is
+ * ~0ULL, in particular when map__load() set a proper end
+ * address for the map we're considering.
+ *
+ * So we make sure that it's actually the right map that we've
+ * found, and if not, we try again and within at most one
+ * attempt we'll get the right map, if it exists.
+ */
+ if (al->addr < al->map->start || al->addr >= al->map->end)
+ goto try_again;
+
al->addr = al->map->map_ip(al->map, al->addr);
}
}
--
1.8.3.1