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?
In lldb you can set breakpoints by typing either break or b followed by information on where you want the program to pause. After the b command, you can put either: a function name (e.g., b my_subroutine ) a line number (e.g., b 12 )
Press Ctrl+Alt+F5 or choose Run | Attach to Process from the main menu. CLion will show the list of the running local processes. Select the process to attach to.
Type quit to exit the lldb session.
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.
https://bugs.llvm.org/show_bug.cgi?id=17972 seems to be a relevant LLDB issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With