Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

bad dwarf debug info when using self-hosted x86 backend #17811

Closed
Tracked by #17748
andrewrk opened this issue Oct 31, 2023 · 0 comments · Fixed by #17970
Closed
Tracked by #17748

bad dwarf debug info when using self-hosted x86 backend #17811

andrewrk opened this issue Oct 31, 2023 · 0 comments · Fixed by #17970
Labels
arch-x86_64 64-bit x86 backend-self-hosted bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@andrewrk
Copy link
Member

zig version: 0.12.0-dev.1372+8457439a8

pub fn main() void {
    @panic("crash");
}
$ stage3/bin/zig run test.zig -fno-llvm -fno-lld
panic: crash
Unwind error at address `exe:0x8032a6e` (error.MissingFDE), trace may be incomplete

/home/andy/Downloads/zig/build-release/test.zig:2:0: 0x8000c70 in test.main (test.zig)
    @panic("crash");

/home/andy/Downloads/zig/lib/std/start.zig:369:0: 0x800062f in start.posixCallMainAndExit (test.zig)
    while (envp_optional[envp_count]) |_| : (envp_count += 1) {}

/home/andy/Downloads/zig/lib/std/start.zig:251:0: 0x800001a in start._start (test.zig)
    asm volatile (switch (native_arch) {

Aborted (core dumped)

Expected output:

$ stage3/bin/zig run test.zig -fllvm -flld
thread 411659 panic: crash
/home/andy/Downloads/zig/build-release/test.zig:2:5: 0x21dcd5 in main (test)
    @panic("crash");
    ^
/home/andy/Downloads/zig/lib/std/start.zig:573:22: 0x21d57c in posixCallMainAndExit (test)
            root.main();
                     ^
/home/andy/Downloads/zig/lib/std/start.zig:251:5: 0x21d0d1 in _start (test)
    asm volatile (switch (native_arch) {
    ^
???:?:?: 0x0 in ??? (???)
Aborted (core dumped)

Observations:

  • Unwind error at address exe:0x8032a6e (error.MissingFDE), trace may be incomplete
  • Column information is completely missing
  • The symbol names are fully qualified in the first one. I think that's actually kinda nice, but I'm not sure why there is a difference.
  • The line number of the second frame is completely wrong

As a reminder, it is our intent to make this backend the default for debug mode, so it's actually even more important for debug info to be good in this backend than in the llvm backend!

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior arch-x86_64 64-bit x86 backend-self-hosted labels Oct 31, 2023
@andrewrk andrewrk added this to the 0.13.0 milestone Oct 31, 2023
jacobly0 added a commit to jacobly0/zig that referenced this issue Nov 11, 2023
andrewrk pushed a commit that referenced this issue Nov 12, 2023
@andrewrk andrewrk modified the milestones: 0.13.0, 0.12.0 Nov 12, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
arch-x86_64 64-bit x86 backend-self-hosted bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant