How to attach to child process in LLDB

Roman Plášil picture Roman Plášil · Feb 7, 2013 · Viewed 10.7k times · Source

My process starts child processes and I want to debug these as well, using LLDB on OS X. I can't find any option in the debugger to auto-attach. How to do it?

Answer

Roman Plášil picture Roman Plášil · Feb 7, 2013

Google is really silent on this issue, but I found a workaround.

Run your main process and stop it before it spins off any children. Then put a breakpoint on the function fork:

b fork

and let the program continue. When it is about to launch a child process, the breakpoint will be hit. At this moment, run another instance of LLDB and let it wait and autoattach to your process:

attach -w -n yourapp

Now let the parent program continue.