From: Mark Wielaard <mark@klomp.org>
To: Milian Wolff <mail@milianw.de>
Cc: elfutils-devel@sourceware.org
Subject: Re: How to associate Elf with Dwfl_Module returned by dwfl_report_module
Date: Wed, 21 Mar 2018 21:21:00 -0000 [thread overview]
Message-ID: <20180321212113.GJ6269@wildebeest.org> (raw)
In-Reply-To: <1946852.ajpeOdNFGP@agathebauer>
Hi Milian,
On Wed, Mar 21, 2018 at 02:01:41PM +0100, Milian Wolff wrote:
> Here's the code for the perf tools:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/
> perf/util/unwind-libdw.c?h=perf/core#n52
>
> Here's the code for the perfparser:
>
> http://code.qt.io/cgit/qt-creator/perfparser.git/tree/app/
> perfsymboltable.cpp#n479
>
> Let's concentrate on perf for now, but perfparser has similar logic:
>
> We parse the mmap events in the perf.data file and store that information.
> Note that the perf.data file does not contain events for munmap calls. Then
> while unwinding the callstack of a perf sample, we lookup the most recent mmap
> event for every given instruction pointer address, and ensure that the
> corresponding ELF was registered with libdw.
So, modules are never deregistered?
In that case, that might explain the issue.
But I see there is a check if there is already something at the address.
The interface to "remove" a module might not be immediately clear.
The idea is that if modules need to be remove you'll call
dwfl_report_begin, possibly dwfl_report_elf for any new module and then
dwfl_report_end has a callback that gets all old modules and decides
whether to re-report them, or they'll get removed. You might want to
experiment with doing that and not re-report any module that overlaps
with the new module. (See the libdwfl.h documentation for a hopefully
clearer description.)
> > Specifically are you using false for the add_p_vaddr argument?
>
> Yes, we are.
>
> > And could you provide some example where the reported address is
> > wrong/different from the start address of the Dwfl_Module?
>
> I don't think it's the start address that is wrong, rather it's the end
> address. But it's hard for me to come up with a small selfcontained example at
> this stage. I am regularly seeing broken backtraces for samples where I have
> the gut feeling that missing reported ELFs are to blame. But we report
> everything, except for scenarios where the mmap events seemingly overlap. This
> overlapping is, as far as I can see, actually a side effect of remapping
> taking place in the dynamic linker (i.e. a single dlopen/dynamic linked
> library can yield multiple mmap events). One way or another, we end up with a
> situation where we cannot report an ELF to dwfl due to two issues:
>
> a) either ELF tells us we are overlapping some module and just stops which is
> bad, since we would actually much prefer the newly reported ELF to take
> precedence
>
> b) we find an mmap event that with a non-zero pgoff, and have no clue how to
> call dwfl_report_elf and just give up.
>
> In both cases, I was hopeing for dwfl_report_module to help since it seemingly
> allows me to exactly recreate the mapping that was traced originally.
If you could add some logging and post that plus the eu-readelf -l
output of the ELF file, that might help track down what is really going
on.
Cheers,
Mark
next prev parent reply other threads:[~2018-03-21 21:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-17 13:15 Milian Wolff
2018-03-20 22:05 ` Mark Wielaard
2018-03-21 13:01 ` Milian Wolff
2018-03-21 14:23 ` Milian Wolff
2018-03-21 14:35 ` Ulf Hermann
2018-03-21 21:31 ` Mark Wielaard
2018-03-22 12:30 ` Milian Wolff
2018-03-21 21:21 ` Mark Wielaard [this message]
2018-03-22 12:29 ` Milian Wolff
2018-03-22 9:11 ` Ulf Hermann
2018-03-22 12:33 ` Milian Wolff
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=20180321212113.GJ6269@wildebeest.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.org \
--cc=mail@milianw.de \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).