macOS 內(nèi)核調(diào)試環(huán)境搭建中的兩個error解決

這兩個error都出現(xiàn)在執(zhí)行command script import ...時。


報錯1 :

error描述:

在lldb中執(zhí)行命令

command script import "/Library/Developer/KDKs/KDK_10.11.3_15D21.kdk/System/Library/Kernels/kernel.dSYM/Contents/Resources/DWARF/../Python/lldbmacros/xnu.py"

報錯如下:

error: module importing failed: dlopen(/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so, 2): Symbol not found: __PySlice_AdjustIndices

解決方法:

問題就出在這個_ctypes.so上。在terminal中執(zhí)行sudo find / -name _ctypes.so

輸出如下:

find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so
/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so

其中第四行是這個報錯的文件,第三行是系統(tǒng)自帶文件。將第四行的文件備份后,用第三行文件的文件覆蓋它。

cp /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so  /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so

報錯2 :

error描述 :

依然是執(zhí)行 command script import時報錯:

error: module importing failed: No module named logging
  File "temp.py", line 1, in <module>
  File "/Library/Developer/KDKs/KDK_10.11.3_15D21.kdk/System/Library/Kernels/kernel.dSYM/Contents/Resources/DWARF/../Python/lldbmacros/xnu.py", line 757, in <module>
    from usertaskgdbserver import *
  File "/Library/Developer/KDKs/KDK_10.11.3_15D21.kdk/System/Library/Kernels/kernel.dSYM/Contents/Resources/DWARF/../Python/lldbmacros/usertaskgdbserver.py", line 2, in <module>
    import logging

解決方法:

參考這個鏈接里的回答:

...but because this question appears high in search results for the error, I wanted to say that I had this error on OSX because my default system Python was 2.7, and I brew installed "python@2" while installing another package.
If you're on OSX and are using homebrew, check your packages installed with brew by running brew list, and if "python@2" appears in that list, and Python 2.7 is your system Python, you can remove the brew installed package with brew remove python@2 --ignore-dependencies

先通過brew list查看是否通過homebrew安裝了"python@2",如果有,執(zhí)行brew remove python@2 --ignore-dependencies。

然后就可以開始愉快滴調(diào)試啦

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容