Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to attach to child process in LLDB

Tags:

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?

like image 742
Roman Plášil Avatar asked Feb 07 '13 07:02

Roman Plášil


People also ask

How do you set a breakpoint in LLDB?

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 )

How do you attach a process to CLion?

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.

How do I quit LLDB?

Type quit to exit the lldb session.


2 Answers

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.

like image 138
Roman Plášil Avatar answered Sep 25 '22 12:09

Roman Plášil


https://bugs.llvm.org/show_bug.cgi?id=17972 seems to be a relevant LLDB issue.

like image 35
jwatt Avatar answered Sep 25 '22 12:09

jwatt