To launch a program in lldb we use the "
process launch
" command or
one of its built in aliases:
(lldb) process launch
(lldb) run
(lldb) r
You can also attach to a process by process ID or process name.
When attaching to a process by name, lldb also supports the "--waitfor
" option which waits for the
next process that has that name to show up, and attaches to it
(lldb) process attach --pid 123
(lldb) process attach --name Sketch
(lldb) process attach --name Sketch --waitfor
After you launch or attach to a process, your process might stop
somewhere:
(lldb) process attach -p 12345
Process 46915 Attaching
Process 46915 Stopped
1 of 3 threads stopped with reasons:
* thread #1: tid = 0x2c03,
0x00007fff85cac76a, where = libSystem.B.dylib`__getdirentries64 + 10,
stop reason = signal = SIGSTOP, queue = com.apple.main-thread
Note the line that says "1 of 3 threads stopped with reasons:
" and the
lines that follow it. In a multi-threaded environment it is very
common for more than one thread to hit your breakpoint(s) before the
kernel actually returns control to the debugger. In that case, you
will see all the threads that stopped for some interesting reason
listed in the stop message.