I'm trying to figure out how a DWARF 2 debug_line section is encoded. The standard paper (http://www.dwarfstd.org/doc/dwarf-2.0.0.pdf) isn't much helpful to me and I really don't understand how something like the following:

    .4byte  .debug_line
    .4byte  0x736e7502, 0x656e6769, 0x6e692064, 0x04070074

represents something. There's the "unsigned int" string encoded there but the 0x02 value before it.. what does that represent? I can't even find a standard enum/define header with the DWARF 2 constants.. can someone shed some light on how to parse a debug_line in DWARF 2?

有帮助吗?

解决方案 2

If the DWARF standard isn't helping then all I can really suggest is reading some source code that implements .debug_line parsing. Maybe that will be more clear; or maybe reading it in conjunction with the DWARF standard will help. There are plenty of readers for this information; a relatively simple one is in the GNU binutils; grab the source and look for .debug_line decoding in "bfd/dwarf2.c".

As for a standard header, binutils also includes a dwarf2.h. But you are right -- I don't think there is a standard header, rather various projects (binutils, elfutils, libdwarf, probably others) make their own headers, generally derived from the DWARF spec.

其他提示

I know, it's quite ancient question, but there might be someone who will be looking for a way to read .debug_line section. I found that readelf is able to parse it:

readelf --debug-dump=line <path/to/binary>

(or)

readelf --debug-dump=decodedline <path/to/binary>

First shows you interpreted .debug_line content as appears in Elf binary. Second composes all data into more structured view, in respect with references between different records given in particular .debug_line unit.

Also there is a tool dwarfdump (available in Ubuntu repos), but I did not have a chance to check it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top