From: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.co>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Namhyung Kim <namhyung@kernel.org>,
Darren Kenny <darren.kenny@oracle.com>,
Eric Saint-Etienne <eric.saintetienne@gmail.com>
Subject: [PATCH] perf symbols: Cannot disassemble some routines when debuginfo present
Date: Fri, 23 Nov 2018 02:25:26 -0800 [thread overview]
Message-ID: <1542968726-20910-1-git-send-email-eric.saint.etienne@oracle.com> (raw)
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 hex offset inside [kernel.vmlinux]. It's due to how perf loads the maps.
Indeed only .text gets loaded by map_groups__find() into al->map.
Consequently al->map address range encompass the whole code.
But map__load() has just loaded many function maps by splitting al->map,
which reduced al->map range drastically. Very likely the target address is
now in one of those newly created function maps, so we need to lookup the
map again to find that new map.
This issue is not specific to the kernel but to how the image is linked.
For the kernel, when we're not using the kernel debuginfo, perf will
fallback to using kallsyms and then the first lookup will work.
This patch makes sure that the event address we're looking-up is indeed
within the map we've found, otherwise we lookup another map again.
Only one extra lookup at most is required for the proper map to be found,
if it exists.
Signed-off-by: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
---
tools/perf/util/event.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index e9c108a..a69ef52 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1571,7 +1571,28 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
*/
if (load_map)
map__load(al->map);
- al->addr = al->map->map_ip(al->map, al->addr);
+
+ /*
+ * When using -ffunction-sections, only .text gets loaded by
+ * map_groups__find() into al->map. Consequently al->map address
+ * range encompass the whole code.
+ *
+ * But map__load() has just loaded many function maps by
+ * splitting al->map, which reduced al->map range drastically.
+ * Very likely the target address is now in one of those newly
+ * created function maps, so we need to lookup the map again
+ * to find that new map.
+ */
+ if (al->addr < al->map->start || al->addr >= al->map->end)
+ al->map = map_groups__find(mg, al->addr);
+
+ /*
+ * The new map *ought* to exist because the initial al->map
+ * contained that address and subsequently has been split into
+ * many *contiguous* maps.
+ */
+ if (al->map != NULL)
+ al->addr = al->map->map_ip(al->map, al->addr);
}
return al->map;
--
1.8.3.1
next reply other threads:[~2018-11-23 10:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-23 10:25 Eric Saint-Etienne [this message]
2018-11-23 16:03 ` Jiri Olsa
2018-11-23 18:24 ` Eric Saint Etienne
2018-11-26 8:39 ` Jiri Olsa
2018-11-26 18:53 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1542968726-20910-1-git-send-email-eric.saint.etienne@oracle.com \
--to=eric.saint.etienne@oracle.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.co \
--cc=darren.kenny@oracle.com \
--cc=eric.saintetienne@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®