如何导入Facebook的Chisel fbchisellldb.py取决于芯片类型(M1/Intel)?
我在〜/.lldbinit中添加以下外壳代码。
if [[ $(uname -p) == 'arm' ]]; then
command script import /opt/homebrew/opt/chisel/libexec/fbchisellldb.py
fi
if [[ $(uname -p) == 'i386' ]]; then
command script import /usr/local/opt/chisel/libexec/fbchisellldb.py
fi
script fbchisellldb.loadCommandsInDirectory('/path/to/fbchisellldb.py')
但是事实证明,lldbinit不支持壳代码/语法,检测芯片类型并动态导入fbchiselldb.py的正确方法是什么?
error: 'if' is not a valid command.
error: error: No value
error: error: No value
error: error: No value
error: error: No value
Error loading Chisel (errno None)
error: 'if' is not a valid command.
error: module importing failed: invalid pathname
error: error: No value
error: error: No value
error: error: No value
error: error: No value
Error loading Chisel (errno None)
I add the following shell code in the ~/.lldbinit.
if [[ $(uname -p) == 'arm' ]]; then
command script import /opt/homebrew/opt/chisel/libexec/fbchisellldb.py
fi
if [[ $(uname -p) == 'i386' ]]; then
command script import /usr/local/opt/chisel/libexec/fbchisellldb.py
fi
script fbchisellldb.loadCommandsInDirectory('/path/to/fbchisellldb.py')
but turns out .lldbinit not support shell code/syntax, what's the correct way to detect chip type and dynamically import fbchiselldb.py.
error: 'if' is not a valid command.
error: error: No value
error: error: No value
error: error: No value
error: error: No value
Error loading Chisel (errno None)
error: 'if' is not a valid command.
error: module importing failed: invalid pathname
error: error: No value
error: error: No value
error: error: No value
error: error: No value
Error loading Chisel (errno None)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
LLDB将脚本任务委托给脚本解释器。我们认为Python的人们在制作可用的语言方面会做得更好,而不是我们想出的任何内容,而Python是广为人知的,因此我们不会强迫人们学习另一组Shell的怪癖像测试&循环结构。因此,如果您需要使用逻辑测试&在与LLDB的交互中,您可以使用脚本命令或导入模块在Python中进行此操作。
您可以在您的〜/.lldbinit中使用
脚本
命令单线,也可以将脚本文本插入在.lldbinit中,但是我通常将.py文件保留在〜/.lldb中i命令脚本导入
在.lldbinit中,并让它完成此类工作。以这种方式更容易添加和调试。如果将表单的函数列出:
在Python模块中,LLDB将在模块以
命令脚本导入导入模块时运行该功能(这是使用
)。这使您可以将命令添加到导入此模块的调试器中。命令脚本import之间的最大差异之一
和<代码>脚本导入所以你可以做:
lldb delegates scripting tasks to the script interpreter. We figured the Python folks would do a better job at producing a useable language than anything we were going to come up with, and Python is pretty widely known, so we wouldn't be forcing people to learn the quirks of yet another set of shell like if tests & looping constructs. So if you need to use logical tests & looping in your interactions with lldb, you do that in Python using the script command or by importing modules.
You can either use
script
command one-lines in your ~/.lldbinit, or you can put the script text inline in your .lldbinit, but I generally keep a .py file in ~/.lldb that Icommand script import
in the .lldbinit, and have it do this sort of job. It's easier to add to and debug that way.If you put a function of the form:
in a Python module, lldb will run that function when the module is imported with
command script import
(that's one of the big differences between usingcommand script import
andscript import
). That allows you to add commands to the debugger that's importing this module.So you could do: