You could take a look at avr-readelf in binutils. The display_debug_lines () function in binutils / dwarf.c does the job of decrypting the DWARF number information.
Alternatively, as suggested above, you can use libdwarf. This is a good job at smoothing out the low-level complexities of DWARF and allows you to focus on getting data.
After setting up libdwarf with elfdescriptor and getting the Dwarf_Debug structure, you can do the following:
- Moving all compilation units with dwarf_srclines ()
- use dwarf_srclines () for each cu
- use dwarf_lineaddr () for each entry in the array returned from dwarf_srclines ()
- Remember to use dwarf_dealloc () in the right places.
Torleif
source share