public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
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: Tue, 20 Mar 2018 22:05:00 -0000	[thread overview]
Message-ID: <20180320220549.GD6269@wildebeest.org> (raw)
In-Reply-To: <3517953.ztkfjMdy38@agathebauer>

Hi Milian,

On Sat, Mar 17, 2018 at 02:14:48PM +0100, Milian Wolff wrote:
> a recurring issue in the libdwfl integration of perf and perfparser are 
> supposedly overlapping modules. The perf data file contains the exact mappings 
> for all files corresponding to the actual mmap events that occurred during 
> runtime, e.g.:
> 
> ```
> $ perf script --show-mmap-events | grep MMAP | grep stdc
> heaptrack_print 13962 87163.483450: PERF_RECORD_MMAP2 13962/13962: 
> [0x7fd0aea84000(0x387000) @ 0 08:03 413039 3864781083]: r-xp /usr/lib/libstdc+
> +.so.6.0.24
> heaptrack_print 13962 87163.483454: PERF_RECORD_MMAP2 13962/13962: 
> [0x7fd0aebfc000(0x1ff000) @ 0x178000 08:03 413039 3864781083]: ---p /usr/lib/
> libstdc++.so.6.0.24
> heaptrack_print 13962 87163.483458: PERF_RECORD_MMAP2 13962/13962: 
> [0x7fd0aedfb000(0xd000) @ 0x177000 08:03 413039 3864781083]: rw-p /usr/lib/
> libstdc++.so.6.0.24
> heaptrack_print 13962 87163.484860: PERF_RECORD_MMAP2 13962/13962: 
> [0x7fd0aedfb000(0xc000) @ 0x177000 08:03 413039 3864781083]: r--p /usr/lib/
> libstdc++.so.6.0.24
> ```
> So far, both perf and perfparser are using dwfl_report_elf to report the file. 
> But that API is deducing the mapping addresses internally, which may or may 
> not be what we saw at runtime. I suspect that this is the reason for some 
> issues we are seeing, such as supposedly overlapping modules. 

How exactly are you calling dwfl_report_elf?
Specifically are you using false for the add_p_vaddr argument?

And could you provide some example where the reported address is
wrong/different from the start address of the Dwfl_Module?

> Looking at the Dwfl API, I cannot figure out how to feed the mapping directly. 
> There's dwfl_report_module, but how would I associate an Elf* and int fd with 
> it, as done by dwfl_report_elf?

When using dwfl_report_module the find_elf callback will be called that
you registered with dwfl_begin. That callback is called "lazily" the
first time dwfl_module_getelf is called. The callback can then set the
Elf*. But that does mean you have to keep track yourself (or immediately
call dwfl_module_getelf).

I would like to understand better what is really going wrong with
dwfl_report_elf before diving into using dwfl_module_report.

Cheers,

Mark

  reply	other threads:[~2018-03-20 22:05 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 [this message]
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
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=20180320220549.GD6269@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).