From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: "Frank Ch. Eigler" <fche@redhat.com>,
Mark Wielaard <mjw@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Milian Wolff <milian.wolff@kdab.com>,
John Levon <levon@movementarian.org>,
Namhyung Kim <namhyung@kernel.org>,
linux-perf-users@vger.kernel.org
Subject: Re: libdw dwarf unwind issue
Date: Sun, 22 Nov 2020 23:27:51 +0100 [thread overview]
Message-ID: <20201122222751.GA1362915@host1.jankratochvil.net> (raw)
In-Reply-To: <20201103221709.GL3597846@krava>
[-- Attachment #1: Type: text/plain, Size: 2237 bytes --]
On Tue, 03 Nov 2020 23:17:09 +0100, Jiri Olsa wrote:
> When you compiled perf with libunwind, you get:
>
> $ make VF=1
> $ perf report -i perf.data --stdio
>
> # Children Self Trace output
> # ........ ........ ..............
> #
> 100.00% 100.00% (5640789cdf50)
> |
> |--98.85%--0x7fc8eca0f554
> | main
> | main_loop_wait
> | qemu_poll_ns
> |
> --1.15%--0x7fc8ecdc2ea4
> iothread_run
> aio_poll
> qemu_poll_ns
>
>
> When you compile perf with libdw, you get:
>
> $ make VF=1 NO_LIBUNWIND=1
> $ perf report -i perf.data --stdio
>
> # Children Self Trace output
> # ........ ........ ..............
> #
> 100.00% 100.00% (5640789cdf50)
> |
> |--98.85%--0x45260879
> | qemu_poll_ns
> |
> --1.15%--qemu_poll_ns
I get after the attached fix:
# Children Self Trace output
# ........ ........ ..............
#
100.00% 100.00% (5640789cdf50)
|
|--98.85%--main
| main_loop_wait
| qemu_poll_ns
|
--1.15%--iothread_run
aio_poll
qemu_poll_ns
> any idea why libdw is doing that? ;-)
Because libdw was reporting separate debuginfo file as the main file:
(lldb) p thread->process->dwfl->modulelist->main.name
(char *) $1 = 0x0000000000b52490 "/home/jkratoch/.debug/.build-id/fc/d0111443729957fa8ef9511ff5dc3e9a5ccf9d/debug"
(lldb) p thread->process->dwfl->modulelist->debug.name
(char *) $2 = 0x0000000000000000
The correct way is to report the main ELF file as the main file:
(lldb) p thread->process->dwfl->modulelist->main.name
(char *) $1 = 0x0000000000b52490 "/home/jkratoch/.debug/.build-id/fc/d0111443729957fa8ef9511ff5dc3e9a5ccf9d/elf"
(lldb) p thread->process->dwfl->modulelist->debug.name
(char *) $2 = 0x0000000000000000
In some cases it may later fill-in even the ->debug.name with "/debug" filename.
Jan Kratochvil
[-- Attachment #2: libdw-unwind.patch --]
[-- Type: text/plain, Size: 2120 bytes --]
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 7a3dbc259cec..5d66cafccde5 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -20,10 +20,28 @@
static char *debuginfo_path;
+static int __find_debuginfo(Dwfl_Module *mod __maybe_unused, void **userdata,
+ const char *modname __maybe_unused, Dwarf_Addr base __maybe_unused,
+ const char *file_name __maybe_unused,
+ const char *debuglink_file __maybe_unused,
+ GElf_Word debuglink_crc __maybe_unused, char **debuginfo_file_name)
+{
+ const struct dso *dso = *userdata;
+ char filename[PATH_MAX];
+
+ assert(dso);
+
+ // We could also use dso->symsrc_filename but it may not be set yet.
+ if (dso__build_id_filename(dso, filename, sizeof(filename), true))
+ *debuginfo_file_name = strdup(filename);
+ return -1;
+}
+
static const Dwfl_Callbacks offline_callbacks = {
- .find_debuginfo = dwfl_standard_find_debuginfo,
+ .find_debuginfo = __find_debuginfo,
.debuginfo_path = &debuginfo_path,
.section_address = dwfl_offline_section_address,
+ // .find_elf is not set as we use dwfl_report_elf() instead.
};
static int __report_module(struct addr_location *al, u64 ip,
@@ -46,16 +64,21 @@ static int __report_module(struct addr_location *al, u64 ip,
mod = dwfl_addrmodule(ui->dwfl, ip);
if (mod) {
Dwarf_Addr s;
+ void **userdatap;
- dwfl_module_info(mod, NULL, &s, NULL, NULL, NULL, NULL, NULL);
+ dwfl_module_info(mod, &userdatap, &s, NULL, NULL, NULL, NULL, NULL);
+ *userdatap = dso;
if (s != al->map->start - al->map->pgoff)
mod = 0;
}
- if (!mod)
- mod = dwfl_report_elf(ui->dwfl, dso->short_name,
- (dso->symsrc_filename ? dso->symsrc_filename : dso->long_name), -1, al->map->start - al->map->pgoff,
- false);
+ if (!mod) {
+ char filename[PATH_MAX];
+
+ if (dso__build_id_filename(dso, filename, sizeof(filename), false))
+ mod = dwfl_report_elf(ui->dwfl, dso->short_name, filename, -1,
+ al->map->start - al->map->pgoff, false);
+ }
return mod && dwfl_addrmodule(ui->dwfl, ip) == mod ? 0 : -1;
}
next parent reply other threads:[~2020-11-22 22:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20201103221709.GL3597846@krava>
2020-11-22 22:27 ` Jan Kratochvil [this message]
2020-11-23 22:12 ` libdw dwarf unwind issue Jiri Olsa
2020-11-28 4:07 ` Jan Kratochvil
2020-12-01 19:41 ` Jiri Olsa
2020-12-02 10:06 ` Jan Kratochvil
2020-12-02 10:56 ` Jiri Olsa
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=20201122222751.GA1362915@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=acme@kernel.org \
--cc=fche@redhat.com \
--cc=jolsa@redhat.com \
--cc=levon@movementarian.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=milian.wolff@kdab.com \
--cc=mjw@redhat.com \
--cc=namhyung@kernel.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;
as well as URLs for NNTP newsgroup(s).