Linux – Linux native debugging symbols format

debugginglinux

GCC documentation says that the -g option produces debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF 2).

So, what is Linux native debugging symbols format? What is it called?


Update: I've just found a 15-year old gcc mailing list discussion where it was said that the native format at that point was stabs and then they were considering to switch to DWARF2. But it was 15 years ago… Any updates? =)

Best Answer

On Linux the default is now Dwarf 2 and/or 4. To see this, run readelf --debug-dump=info on a binary containing debug symbols (or stripped symbols); for example, on Fedora, with glibc-debuginfo installed, running readelf --debug-dump=info /usr/lib/debug/bin/gencat.debug will give you something like

 <1><ea>: Abbrev Number: 0
  Compilation Unit @ offset 0xeb:
   Length:        0x5c (32-bit)
   Version:       2
   Abbrev Offset: 0x52
   Pointer Size:  8
 <0><f6>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <f7>   DW_AT_stmt_list   : 0x83
    <fb>   DW_AT_ranges      : 0x0
    <ff>   DW_AT_name        : ../sysdeps/x86_64/crti.S
    <118>   DW_AT_comp_dir    : /usr/src/debug////////glibc-2.21/csu
    <13d>   DW_AT_producer    : GNU AS 2.25
    <149>   DW_AT_language    : 32769   (MIPS assembler)

This is a set of Dwarf 2 information (see the Version: header for version information; the same binary includes Dwarf 2 and Dwarf 4 sections).

Related Question