如何使用 LLDB python API `debugger.CreateTarget` 指定 dsym 文件

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

我可以在lldb命令行app中指定myapp.dsym:

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

但是在使用python API时如何指定dsym文件呢?

target = debugger.CreateTarget(

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

我在 https://github.com/llvm/llvm-project/ and https://lldb.llvm.org/python_reference/index.html 中搜索。但是无法解决。

如果您的二进制文件是 /tmp/a.out 并且您的 dSYM 是 /tmp/hide.noindex/a.out.dSYM,这将是一种方式:

(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