pythondebugginglldbdsym

How can I specify dsym file using LLDB python API `debugger.CreateTarget`


I can specify myapp.dsym in the lldb command line app:

target create --no-dependents -arch arm64 --symfile myapp.dsym myapp

But how can I specify dsym file when using python API?

target = debugger.CreateTarget(

    "myapp", triple, platform_name, add_dependents, lldb.SBError())

I have search in https://github.com/llvm/llvm-project/ and https://lldb.llvm.org/python_reference/index.html . But cannot solve it.


Solution

  • If your binary is /tmp/a.out and your dSYM is /tmp/hide.noindex/a.out.dSYM, this would be one way:

    (lldb) scri
    Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
    >>> dbg = lldb.SBDebugger().Create()
    >>> dbg.SetAsync(False)
    >>> target = dbg.CreateTarget('')
    >>> modspec = lldb.SBModuleSpec()
    >>> modspec.SetFileSpec(lldb.SBFileSpec("/tmp/a.out"))
    >>> modspec.SetSymbolFileSpec(lldb.SBFileSpec("/tmp/hide.noindex/a.out.dSYM"))
    >>> target.AddModule(modspec)
    <lldb.SBModule; proxy of <Swig Object of type 'lldb::SBModule *' at 0x1077e2ea0> >
    >>> target.BreakpointCreateByName("main")
    <lldb.SBBreakpoint; proxy of <Swig Object of type 'lldb::SBBreakpoint *' at 0x1077e2f60> >
    >>> process = target.LaunchSimple(None, None, "/tmp/")
    >>> print (process)
    SBProcess: pid = 87848, state = stopped, threads = 1, executable = a.out
    >>> print (process.GetThreadAtIndex(0))
    thread #1: tid = 0xeacb2f, 0x000000010a548fb0 a.out`main, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1