How to associate Elf with Dwfl_Module returned by dwfl_report_module

Milian Wolff mail@milianw.de
Thu Mar 22 12:30:00 GMT 2018


On Mittwoch, 21. März 2018 22:31:07 CET Mark Wielaard wrote:
> On Wed, Mar 21, 2018 at 03:23:51PM +0100, Milian Wolff wrote:
> > Here's one way to investigate where perf and dwfl disagree on the file
> > mappings:
> > 
> > diff --git a/tools/perf/util/unwind-libdw.c
> > b/tools/perf/util/unwind-libdw.c index 7bdd239c795c..739c68b73772 100644
> > --- a/tools/perf/util/unwind-libdw.c
> > +++ b/tools/perf/util/unwind-libdw.c
> > @@ -48,11 +48,17 @@ static int __report_module(struct addr_location *al,
> > u64 ip,
> > 
> >  			mod = 0;
> >  	
> >  	}
> > 
> > -	if (!mod)
> > +	if (!mod) {
> > +		Dwarf_Addr s, e;
> > 
> >  		mod = dwfl_report_elf(ui->dwfl, dso->short_name,
> >  		
> >  				      (dso->symsrc_filename ? dso->symsrc_filename : dso-
> > >
> > >long_name), -1, al->map->start,
> > >
> >  				      false);
> > 
> > +		dwfl_module_info(mod, NULL, &s, &e, NULL, NULL, NULL, NULL);
> > +		if (al->map->start != s || al->map->end != e)
> > +			pr_warning("MEH: %s | mmap: %zx %zx | dwfl: %zx %zx\n", dso-
> > 
> > >short_name, al->map->start, al->map->end, s, e);
> > 
> > +	}
> > +
> > 
> >  	return mod && dwfl_addrmodule(ui->dwfl, ip) == mod ? 0 : -1;
> >  
> >  }
> > 
> > On one of my perf.data files with many broken backtraces this gives me:
> > 
> > MEH: heaptrack_print | mmap: 56166e9d4000 56166ea39000 | dwfl:
> > 56166e9d4000
> > 56166ea38880
> > MEH: ld-2.26.so | mmap: 7fd0afc6c000 7fd0afe93000 | dwfl: 7fd0afc6c000
> > 7fd0afe920f8
> > MEH: libc-2.26.so | mmap: 7fd0ae16a000 7fd0ae521000 | dwfl: 7fd0ae16a000
> > 7fd0ae5208f0
> > MEH: libstdc++.so.6.0.24 | mmap: 7fd0aea84000 7fd0aee0b000 | dwfl:
> > 7fd0aea84000 7fd0aee0a640
> > MEH: libzstd.so.1.3.3 | mmap: 7fd0aee0b000 7fd0af087000 | dwfl:
> > 7fd0aee0b000 7fd0af086030
> > 
> > Interestingly, here the mmap events observed by perf are actually always
> > *larger* than what dwfl sees...
> 
> I think that is simply the end address being extended to the next page.
> Where the page size seems to be 4K (0x1000). I assume if you look at
> the actual LOAD segment sizes of the files (eu-readelf -l) they match
> with what dwfl reports, and if it extends to the nearest 4k page it
> matches whatp mmap reports.

Yes, I agree - the above does not explain the issues I am seeing. It is most 
probably just noise and can be ignored.

I'll try to dig deeper to figure out what is going on and then come back here. 
For now, it seems like using dwfl_report_elf is fine.

Cheers

-- 
Milian Wolff
mail@milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://sourceware.org/pipermail/elfutils-devel/attachments/20180322/2725bd43/attachment.sig>


More information about the Elfutils-devel mailing list