Roman Plášil
Roman Plášil

Reputation: 1970

How to attach to child process in LLDB

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?

Upvotes: 26

Views: 18106

Answers (2)

jwatt
jwatt

Reputation: 870

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

Upvotes: 4

Roman Plášil
Roman Plášil

Reputation: 1970

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.

Upvotes: 21

Related Questions