-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use DWARF debug format option #19633
base: master
Are you sure you want to change the base?
Use DWARF debug format option #19633
Conversation
.elf, .macho, .wasm => switch (options.debug_format.?.dwarf) { | ||
.@"32" => .{ .dwarf = .@"32" }, | ||
.@"64" => .{ .dwarf = .@"64" }, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works as expected with
$ zig build-obj -gdwarf32 -O Debug -target x86_64-linux example.zig
$ /opt/homebrew/opt/binutils/bin/objdump --dwarf=info example.o | head -20
example.o: file format elf64-x86-64
Contents of the .debug_info section:
Compilation Unit @ offset 0:
Length: 0x25f5a (32-bit)
Version: 4
Abbrev Offset: 0
Pointer Size: 8
...
and
$ zig build-obj -gdwarf64 -O Debug -target x86_64-linux example.zig
$ /opt/homebrew/opt/binutils/bin/objdump --dwarf=info example.o | head -20
example.o: file format elf64-x86-64
Contents of the .debug_info section:
Compilation Unit @ offset 0:
Length: 0x31232 (64-bit)
Version: 4
Abbrev Offset: 0
Pointer Size: 8
...
But, reviewing my code, I'm unsure of what the behavior would be if debug_format
were empty. I can see that a 32-bit size is used when no flag is added:
$ zig build-obj -O Debug -target x86_64-linux example.zig
$ /opt/homebrew/opt/binutils/bin/objdump --dwarf=info example.o | head -20
example.o: file format elf64-x86-64
Contents of the .debug_info section:
Compilation Unit @ offset 0:
Length: 0x25f5a (32-bit)
Version: 4
Abbrev Offset: 0
Pointer Size: 8
...
Is this wanted?
I can see in past versions 32-bit format was used, and the |
Also, as a further suggestion, it might be straightforward to also support DWARF generation for windows target (COFF object) with these options. As mentioned in CodeLLDB's wiki page, LLDB's support for CodeView is incomplete, and GDB currently has no support for Codeview. Allowing DWARF generation for windows could make it easier to integrate with mingw toolchain (which uses GDB or LLDB) and to debug zig program in Wine environment |
7afec96
to
b1ff696
Compare
@geezmolycos I made a pass at adding DWARF support for COFF objects as you suggested, but with my limited time, wasn't able to come up with a good emulation solution for verifying my changes. I'd prefer to add a new issue for adding DWARF support for COFF objects, and get this code reviewed as is. How does that all sound to you? |
Okay, the current solution should be fine for the original problem. I know that the COFF thing might need more reviewing and testing. I will look into that and post another issue to find help or try to work with that myself. Anyways, thanks for your contribution |
Thanks for all of your guidance, @geezmolycos, and for writing a detailed & helpful issue -- that made it much easier to contribute. :D |
@kubkon 👋 Pinging for a review, since you've previously reviewed a different, related PR. |
@andrewrk 👋 Pinging for a review |
Addresses #19478