Stopping "stop reason = exec"

Hi all,

Is there anything I can put into my lldb init script to prevent LLDB from stopping on exec? Every time I run a program I get this super irritating behavior:

Thanks for any help!

-Chris

Process 20310 launched: '/Users/clattner/Projects/build/Xcode-ReleaseAssert+swift-DebugAssert/swift-macosx-x86_64/Debug/bin/swift' (x86_64)
Process 20310 stopped
* thread #2, stop reason = exec
    frame #0: 0x000000010984f000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x10984f000 <+0>: popq %rdi
    0x10984f001 <+1>: pushq $0x0
    0x10984f003 <+3>: movq %rsp, %rbp
    0x10984f006 <+6>: andq $-0x10, %rsp
Target 0: (swift) stopped.
(lldb)

There isn't a setting to auto-continue from exec. Definitely should be.

If somebody wants to try their hand at it, just add a setting in parallel to stop-on-sharedlibrary-events and then add a ShouldStop to the StopInfoExec (StopInfo.cpp) that checks this setting. The StopInfoSignal does something equivalent, should be able to copy that.

For macOS, you can also just do:

(lldb) break set -n _dyld_start --skip-prologue 0 -s dyld
Breakpoint 2: where = dyld`_dyld_start, address = 0x000000010000b19c
(lldb) b com add -o continue

either in your .lldbinit or in your debug session. If you are using TOT lldb you can do:

(lldb) break set -n _dyld_start --skip-prologue 0 -s dyld --auto-continue 1

Jim

There isn't a setting to auto-continue from exec. Definitely should be.

Yeah, I assumed that I could redefine my “r” alias to include this, but there is no flag to process launch.

If somebody wants to try their hand at it, just add a setting in parallel to stop-on-sharedlibrary-events and then add a ShouldStop to the StopInfoExec (StopInfo.cpp) that checks this setting. The StopInfoSignal does something equivalent, should be able to copy that.

For macOS, you can also just do:

(lldb) break set -n _dyld_start --skip-prologue 0 -s dyld
Breakpoint 2: where = dyld`_dyld_start, address = 0x000000010000b19c
(lldb) b com add -o continue
either in your .lldbinit or in your debug session.

This doesn’t appear to work, I tried both lldb and in a debug session. I’m starting lldb with “lldb -- swiftc … “ if that matters.

(lldb) break set -n _dyld_start --skip-prologue 0 -s dyld
Breakpoint 1: where = dyld`_dyld_start, address = 0x0000000000001000
(lldb) b com add -o continue
Breakpoint 2: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.

If you are using TOT lldb you can do:
(lldb) break set -n _dyld_start --skip-prologue 0 -s dyld --auto-continue 1

I’m not :frowning:

-Chris

I realize that this is probably because you’re not using the standard ‘b’ alias. When I use ‘br’, the command succeeds, but I still stop on launch:

(lldb) br com add -o continue
(lldb) r
There is a running process, kill it and restart?: [Y/n] y
Process 24049 exited with status = 9 (0x00000009)
Process 24054 launched: ‘/Users/clattner/Projects/build/Xcode-ReleaseAssert+swift-DebugAssert/swift-macosx-x86_64/Debug/bin/swiftc’ (x86_64)
Process 24054 stopped

  • thread #2, stop reason = exec
    frame #0: 0x0000000109852000 dyld_dyld_start dyld_dyld_start:
    → 0x109852000 <+0>: popq %rdi
    0x109852001 <+1>: pushq $0x0
    0x109852003 <+3>: movq %rsp, %rbp
    0x109852006 <+6>: andq $-0x10, %rsp
    Target 0: (swiftc) stopped.

Thank you for the help, I appreciate it!

-Chris

Yup, apparently debugserver tells us the stop is for exec directly so we don't treat it as a breakpoint hit. That sorta makes sense, you don't want to trigger a breakpoint hit every time you find a thread at the pc of a breakpoint (might be a thread that hit a breakpoint, then didn't get to run till the next stop.) But it defeats the obvious method.

Anyway, it is a program stop, so you can use a stop hook:

(lldb) target stop-hook add -n _dyld_start -o continue

That one does work, though the stop-hook output is a little ugly. It would also be nice to specify stop-hooks by stop reason too. But this method does work...

Jim

That works, thanks Jim! Agreed that it is ugly though :slight_smile:

-Chris