-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Zig Version
0.14.0 - but present in master too
Steps to Reproduce and Observed Behavior
std.debug.Dwarf fails to extract source files and line numbers info from my C++ code when compiled with zig compiler and -gdwarf-5 (or just -gdwarf which defaults to 5). std.debug.Dwarf.getSynbol will have null as it's source_location field.
libbacktrace seems to find source locations fine.
If compiled with -gdwarf-4 it also works fine.
These binaries have embedded DWARF 5 info that should recreate this issue.
- Download and extract Floe-Packager-v0.9.2-beta-macOS.zip or Floe-Packager-v0.9.2-beta-Windows.zip from https://github.com/floe-audio/Floe/releases/tag/v0.9.2-beta
- Use the std.debug.Dwarf API or std.debug.SelfInfo to try parsing the DWARF info.
Stepping through with the debugger, this line returns an error:
Line 1418 in 8e79fc6
| const compile_unit_cwd = try compile_unit.die.getAttrString(d, AT.comp_dir, d.section(.debug_line_str), compile_unit.*); |
A simple fix I found is to move the declaration of compile_unit_cwd to inside the if (version < 5) {} so that it only runs when it's actually needed: for version 4 or lower. I don't know the reason why this works so I'm not confident to suggest it unanimously.
Workaround for me is to use -gdwarf-4.
Expected Behavior
Source location and line number should be correctly extracted from DWARF 5.