【发布时间】:2019-09-13 07:03:30
【问题描述】:
(gdb) shell ls
Makefile __init__.py constants.py.in cpus.py dmesg.py lists.py modules.py proc.py symbols.py tasks.py test.py utils.py utils.pyc vmlinux-gdb.py
(gdb)
我运行 python import utils 并收到 ImportError
ImportError: No module named 'utils'
Error while executing Python code.
(gdb)
虽然我可以通过另一个 python 程序在 gdb 外部完美地导入 utils,但当我在 inside gdb 中执行它时会失败。可能的问题是什么?我正在运行 gdb 7.11 的更新版本,python 也不错。
对于某些背景,如果有帮助,我关注 https://www.kernel.org/doc/html/latest/dev-tools/gdb-kernel-debugging.html ,它有一个 vmlinux python 脚本来帮助调试东西,他们已经编写了自己的导入包。但由于这个基本问题,该脚本无法正常工作。
谢谢
[已解决]
【问题讨论】:
-
尝试在
rungdb 之前执行export PYTHONPATH=currentpath:$PYTHONPATH。祝你好运。 -
天哪,修好了!哇。谢谢楼主:)