简体   繁体   中英

python gdb not importing my packages

(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)

I run python import utils and I get an ImportError

ImportError: No module named 'utils' Error while executing Python code. (gdb)

While I can perfectly import utils outside gdb through another python program, it fails when I do it inside gdb. What can be the possible issue ? I am running updated version of gdb 7.11 , python is also good.

For some background, if it helps, I was following https://www.kernel.org/doc/html/latest/dev-tools/gdb-kernel-debugging.html , it has a vmlinux python script to help in debugging stuff , where they have written their own packages which they import. But that script is not working because of this fundamental issue.

Thanks

[SOLVED]

Just extracting the answer by Charles Chao which was in the comment.

Execute following before running gdb:

export PYTHONPATH=currentpath:$PYTHONPATH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM