To launch a program in lldb we use the "
process launch" command or one of its built in aliases:
(lldb) process launchYou 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 123After you launch or attach to a process, your process might stop somewhere:
(lldb) process attach --name Sketch
(lldb) process attach --name Sketch --waitfor
(lldb) process attach -p 12345Note the line that says "
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
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.