how to attach to process with python scripting on lldb?


I have been trying for some days to resolve a symbol of address using lldb python api but I haven’t found how to do that.
So I think that I need to attach to the PID using python but it’s not working, I tried:

target = lldb.debugger.FindTargetWithProcessID(71321)

process = target.LaunchSimple(None, None, os.getcwd())

process.GetState() → Returns 0 … Why?

So I could use the ResolveSymbolAddress function because if I attach it outside of scripting then I do not own the self – debugger object.

I appreciate your help.

Try target.AttachToProcessWithID() instead of target.LaunchSimple(). LaunchSimple tells lldb to run, creating a new process, instead of attaching to an existing one. See the SBTarget Python documentation here: .

You should also be able to attach using the lldb command line, then go into the scripting interface and get the debugger object with lldb.debugger . Or attach using debugger.HandleCommand() to run an lldb command from the scripting interface.