gprofng: Correctly handle DWARF 5 indexed string and address forms
gprofng now correctly interprets DWARF 5's indexed string and address forms, fixing issues with compilation unit names, directories, and PC ranges.
This commit corrects how gprofng handles DWARF 5’s indexed string (DW_FORM_strx*) and address (DW_FORM_addrx*) forms. Previously, gprofng treated these indices as byte offsets or raw addresses, leading to incorrect compilation unit names, directories, and PC ranges. This resulted in “instructions without line numbers” and errors when trying to locate source files. The fix involves reading new DWARF sections (.debug_str_offsets, .debug_addr) and resolving indices using base attributes, ensuring accurate debugging information.
- proposer
Submitted a patch series to fix incorrect handling of DWARF 5 indexed string and address forms in gprofng.
“Clang emits DW_FORM_strx* and DW_FORM_addrx* by default for DWARF 5. gprofng used the strx index as a byte offset into .debug_str and kept the addrx index as the address, so compilation unit names, directories and every PC range were wrong.”
In Details
This series of commits addresses issues in binutils' gprofng profiler related to its DWARF 5 debug information parsing. Specifically, it corrects the interpretation of DW_FORM_strx* and DW_FORM_addrx* forms, which are used by compilers like Clang to represent strings and addresses via indices into dedicated sections (.debug_str_offsets, .debug_addr). Previously, gprofng misinterpreted these indices, leading to incorrect source location and function range information. The fix involves properly utilizing the DW_AT_str_offsets_base and DW_AT_addr_base attributes to resolve thes…
- gprofng
- The next-generation version of the gprof performance analysis tool, part of the binutils package.
- DWARF 5
- The fifth version of the DWARF debugging data format, which includes extensions for indexed string and address forms.
- DW_FORM_strx*
- A DWARF debugging information form that represents a string index into the .debug_str section, using an offset base.
- DW_FORM_addrx*
- A DWARF debugging information form that represents an address index into the .debug_addr section, using an offset base.
- DIE
- Debug Information Entry, a fundamental unit of DWARF debugging information.
- .debug_str
- A section in DWARF that stores string constants used in debugging information.
- .debug_str_offsets
- A DWARF section that provides offsets into the .debug_str section for indexed string forms.
- .debug_addr
- A DWARF section that stores addresses for indexed address forms.
- DW_AT_str_offsets_base
- A DWARF attribute that specifies the base offset for indices into the .debug_str_offsets section.
- DW_AT_addr_base
- A DWARF attribute that specifies the base offset for indices into the .debug_addr section.