brook hong
brook hong

Reputation: 601

How to attach the second next process with lldb

Is is possible to let lldb to attach to the 2nd new process of some executable? We could attach the next new process of some executable with

attach -w -n "/path/to/executable"

But now an action will launch a pair of instances of some executable, I want to only attach to the 2nd process.

Upvotes: 0

Views: 183

Answers (1)

Jim Ingham
Jim Ingham

Reputation: 27110

lldb doesn't have a "wait for second next version" primitive. But using the SB API's it would be pretty easy to write a Python command that does an attach wait, then detaches after the first attach and immediately waits for the next one.

When you attach to a process in the SB API, you create an SBAttachInfo specifying what you want to attach to. Be sure to call SetIgnoreExisting(True) on the second attach, that way it won't try to attach again to the first process. More details on writing Python based commands is here:

https://lldb.llvm.org/use/python-reference.html#create-a-new-lldb-command-using-a-python-function

And the API reference is here:

https://lldb.llvm.org/python_reference/index.html

Upvotes: 1

Related Questions