From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89146 invoked by alias); 20 Mar 2018 22:05:54 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 89116 invoked by uid 89); 20 Mar 2018 22:05:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=supposedly, diving X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Mar 2018 22:05:52 +0000 Received: from librem.wildebeest.org (deer0x01.wildebeest.org [172.31.17.131]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 2108B302BB23; Tue, 20 Mar 2018 23:05:50 +0100 (CET) Received: by librem.wildebeest.org (Postfix, from userid 1000) id BB77A14064F; Tue, 20 Mar 2018 23:05:49 +0100 (CET) Date: Tue, 20 Mar 2018 22:05:00 -0000 From: Mark Wielaard To: Milian Wolff Cc: elfutils-devel@sourceware.org Subject: Re: How to associate Elf with Dwfl_Module returned by dwfl_report_module Message-ID: <20180320220549.GD6269@wildebeest.org> References: <3517953.ztkfjMdy38@agathebauer> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3517953.ztkfjMdy38@agathebauer> User-Agent: Mutt/1.9.3 (2018-01-21) X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2018-q1/txt/msg00085.txt.bz2 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