[Dwarf-Discuss] Obtain DIE based on physical file offset

Florian Weimer fw@deneb.enyo.de
Sat Jul 25 16:18:15 GMT 2009


* David Anderson:

> Florian Weimer wrote:
>> Is there a simple way to obtain a DIE based on physical file offset,
>> using libdwarf?  (My actual goal is to obtain source file and line
>> number from a programm counter value, and this seems to be a required
>> intermediate step.)

> Yes, pretty simple in a sense, but your note is a bit hard to understand.

Sorry about that.

> The .debug_line section relates program counter values to
> source file and line.

I haven't implemented it yet, but it looks doable.  Thanks.

I'm currently struggling with a way to obtain the function name for a
PC value.  This seems to be somewhat difficult because the DIE can be
nested, and PC range information and function name information are
sometimes split across multiple DIE.  (I think I got it working for
top-level functions, but not for C++ class members.)

> Why you mention physical file offset is unclear (at least at this
> high level of discourse).

I'm trying to map program counter values from dynamic shared objects
to the correct offset to pass to libdwarf.  I initially thought that I
had to use physical offset information, but I think I get the correct
offsets now (after consulting the ELF spec).




More information about the Dwarf-discuss mailing list