[lldb-dev] how to attach to process with python scripting on lldb?

Ted Woodward via lldb-dev lldb-dev at lists.llvm.org
Wed Nov 3 09:43:09 PDT 2021


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: https://lldb.llvm.org/python_reference/lldb.SBTarget-class.html .

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.

Ted

From: lldb-dev <lldb-dev-bounces at lists.llvm.org> On Behalf Of Pi Pony via lldb-dev
Sent: Wednesday, November 3, 2021 10:20 AM
To: lldb-dev at lists.llvm.org
Subject: [lldb-dev] how to attach to process with python scripting on lldb?


WARNING: This email originated from outside of Qualcomm. Please be wary of any links or attachments, and do not enable macros.
Hello,

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20211103/f0d1eadd/attachment-0001.html>


More information about the lldb-dev mailing list