Skip to content

no debug info found by lldb on macOS aarch64 #24369

Open
@190n

Description

@190n

Zig Version

0.15.0-dev.929+31e46be74

Steps to Reproduce and Observed Behavior

Compile a simple program and debug it. No source code is shown in the debugger:

//! repro.zig
pub fn main() void {
    @breakpoint();
}
$ zig-master build-exe repro.zig
$ lldb ./repro
(lldb) target create "./repro"
Current executable set to '/Users/ben/code/dbg-repro/repro' (arm64).
(lldb) r
Process 9098 launched: '/Users/ben/code/dbg-repro/repro' (arm64)
Process 9098 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x10009fe3c)
    frame #0: 0x000000010009fe40 repro`repro.main + 12
repro`repro.main:
->  0x10009fe40 <+12>: ldp    x29, x30, [sp], #0x10
    0x10009fe44 <+16>: ret    

repro`debug.attachSegfaultHandler:
    0x10009fe48 <+0>:  sub    sp, sp, #0x50
    0x10009fe4c <+4>:  stp    x29, x30, [sp, #0x40]

Expected Behavior

In 0.14.1 it works:

$ zig-0.14.1 build-exe repro.zig
$ lldb ./repro
(lldb) target create "./repro"
Current executable set to '/Users/ben/code/dbg-repro/repro' (arm64).
(lldb) r
Process 13386 launched: '/Users/ben/code/dbg-repro/repro' (arm64)
Process 13386 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x10009ec38)
    frame #0: 0x000000010009ec3c repro`repro.main at repro.zig:3:5
   1    //! repro.zig
   2    pub fn main() void {
-> 3        @breakpoint();
   4    }

I think this might be an unintended consequence of #24124, since my understanding is that PR made Zig stop emitting extra object files next to the executables. In 0.14.1, I get both a repro executable and repro.o object emitted, and when I delete repro.o the debugger fails to show source info the same way as it does on master:

$ zig-0.14.1 build-exe repro.zig
$ rm repro.o
$ lldb ./repro
(lldb) target create "./repro"
Current executable set to '/Users/ben/code/dbg-repro/repro' (arm64).
(lldb) r
Process 17549 launched: '/Users/ben/code/dbg-repro/repro' (arm64)
Process 17549 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x10009ec38)
    frame #0: 0x000000010009ec3c repro`repro.main + 12
repro`repro.main:
->  0x10009ec3c <+12>: ldp    x29, x30, [sp], #0x10
    0x10009ec40 <+16>: ret    

repro`debug.attachSegfaultHandler:
    0x10009ec44 <+0>:  sub    sp, sp, #0x30
    0x10009ec48 <+4>:  stp    x29, x30, [sp, #0x20]

So maybe somehow only the object file has debug info in it, not the executable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-aarch6464-bit ARMbugObserved behavior contradicts documented or intended behaviordebug-infoDebug information of binary generated by Zig is not as expected.os-macos

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions