我在 ~/.lldbinit 中添加了以下 shell 代碼。
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 不支持shell 代碼/語法,檢測芯片型別和動態匯入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)
uj5u.com熱心網友回復:
lldb 將腳本任務委托給腳本解釋器。我們認為 Python 人員在生成可用語言方面會比我們想出的任何語言做得更好,而且 Python 廣為人知,所以我們不會強迫人們學習另一套 shell 的怪癖比如 if 測驗和回圈結構。因此,如果您需要在與 lldb 的互動中使用邏輯測驗和回圈,您可以在 Python 中使用腳本命令或通過匯入模塊來實作。
您可以script在 ~/.lldbinit 中使用單行命令,也可以將腳本文本行內到 .lldbinit 中,但我通常在 ~/.lldb 中保留一個 .py 檔案,我command script import在 .lldbinit 中,并且它做這種作業。以這種方式添加和除錯更容易。
如果你把表格的功能:
def __lldb_init_module(debugger, dict):
在 Python 模塊中, lldb 將在匯入模塊時運行該函式(這是 using和command script import之間的最大區別之一)。這允許您向正在匯入此模塊的除錯器添加命令。command script importscript import
所以你可以這樣做:
import platform
def __lldb_init_module(debugger, dict):
if platform.machine() == 'arm64':
debugger.HandleCommand("command script import <ONE_CHISEL>")
else
debugger.HandleCommand("command script import <OTHER_CHISEL>")
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/463316.html
