This is the mail archive of the
mailing list for the elfutils project.
Re: Using dwfl to enumerate frames of current thread
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Thu, 20 Aug 2015 17:32:23 +0200
- Subject: Re: Using dwfl to enumerate frames of current thread
On Thu, 2015-08-20 at 17:02 +0200, Ben Gamari wrote:
> Fair enough. However, I was basing my original statement not on the
> output of elfutils' readelf but instead on libdwfl data structures
> dumped in gdb.
> As you may have realized by now, the problem begins in
> dwfl_module_getsrc, which returns DWFL_E_ADDR_OUTOFRANGE.
> If you look at the Dwfl_Module that gets passed to dwfl_module_getsrc,
> you'll find that mod->ncu == 1 (which is confirmed by traversing the
> mod->cu list). This struct me as rather odd.
mod->ncu is the number of CUs that have been interned because they have
been used. But you are correct that the Dwfl isn't seeing/using many
CUs. The reason for that is that dwfl only caches the CUs which (program
scope) addresses associated with it. There seem to be only 64 CUs that
have a DW_AT_low_pc associated with the DW_TAG_compile unit (the same
number as listed in .debug_aranges). All those seem to be generated by
GCC for C files. None of the compile_unit generated by ghc seem to have
address ranges associates with their CUs. Because of that libdwfl
assumed that there are no program scopes inside that CU (only types) and
so doesn't use them.
I am pondering if we can use the fact that they do have a
DW_AT_stmt_list to keep/cache them anyway. But I would suggest that ghc
outputs the program scope address ranges that the CU covers (either a
DW_AT_low_pc plus DW_AT_high_pc for a continues address range or a
DW_AT_low_pc plus DW_AT_ranges or non-contiguous address ranges). There
are other places where things probably go wrong if they aren't there.
elfutils tries to be efficient and not read a whole DIE tree unless it
thinks it needs it. One way to do that is to only read the children of a
program scope DIE if it covers the address we are looking for.
See Dwarf 4 2.17 Code Addresses and Ranges. In particular elfutils takes
"If an entity has no associated machine code, none of these attributes
P.S. Is the DW_AT_language code you use for Haskell standardized?