Reputation: 11
(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]
Upvotes: 1
Views: 2589
Reputation: 1750
Just extracting the answer by Charles Chao which was in the comment.
Execute following before running gdb:
export PYTHONPATH=currentpath:$PYTHONPATH
Upvotes: 3