【问题标题】:python gdb not importing my packagespython gdb没有导入我的包
【发布时间】: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 脚本来帮助调试东西,他们已经编写了自己的导入包。但由于这个基本问题,该脚本无法正常工作。

谢谢

[已解决]

【问题讨论】:

  • 尝试在run gdb 之前执行export PYTHONPATH=currentpath:$PYTHONPATH。祝你好运。
  • 天哪,修好了!哇。谢谢楼主:)

标签: python gdb kernel


【解决方案1】:

刚刚提取了评论中 Charles Chao 的答案。

在运行 gdb 之前执行以下操作:

export PYTHONPATH=currentpath:$PYTHONPATH

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-07
    • 2016-01-31
    • 2021-05-01
    • 1970-01-01
    • 2022-04-14
    • 2020-12-10
    • 2012-02-03
    相关资源
    最近更新 更多