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:
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:
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 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
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:
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...