Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使命令解释器知道新创建的目标_Python_Debugging_Lldb - Fatal编程技术网

Python 如何使命令解释器知道新创建的目标

Python 如何使命令解释器知道新创建的目标,python,debugging,lldb,Python,Debugging,Lldb,我想使用LLDB作为python库,如下所述 使用创建目标后 debugger=lldb.SBDebugger.Create() target=debugger.CreateTargetWithFileAndArch(路径到可执行文件,lldb.lldb\u ARCH\u默认) 以及使用命令解释器 transparer=debugger.getCommandTransparer() 我试着从目标开始 ret=llldb.SBCommandReturnObject() 解释器HandleCom

我想使用LLDB作为python库,如下所述

使用创建目标后

debugger=lldb.SBDebugger.Create()
target=debugger.CreateTargetWithFileAndArch(路径到可执行文件,lldb.lldb\u ARCH\u默认)
以及使用命令解释器

transparer=debugger.getCommandTransparer()
我试着从目标开始

ret=llldb.SBCommandReturnObject()
解释器HandleCommand('/r',ret)
我收到
错误:目标无效,请使用“target create”命令创建目标。我还尝试使用
调试器设置所选目标。SetSelectedTarget(target)
,但也不起作用。在命令处理程序中运行
文件
,工作正常


有没有办法在python中创建目标并在解释器中对其运行命令?

显然,
调试器。CreateTargetWithFileAndArch
不会返回有效的目标,您可以通过执行
bool(target)
来查看。使用

target=debugger.CreateTargetWithFileAndArch(路径\u到\u可执行文件,lldb.lldb\u默认)
debugger.SetSelectedTarget(目标)

显然,
lldb.lldb\u ARCH\u DEFAULT
由于某种原因在MacOS上不起作用。因此,我用一个明确的名称替换了它:

target = debugger.CreateTargetWithFileAndArch(exe, "x86_64-apple-macosx10.15.0")
其次是:

assert target

这将有助于避免意外的空目标。

如果目标无效,那么
调试器.SetSelectedTarget(目标)
将如何帮助?