PyCortexMDebug icon indicating copy to clipboard operation
PyCortexMDebug copied to clipboard

ModuleNotFoundError: No module named 'cmdebug' when sourcing in gdb

Open EarthLord opened this issue 3 years ago • 2 comments

Hello @bnahill and co developers

Thanks for this tool. I came across it in this Interrupt blog. So I cloned the repo, installed it with python3 with setup.py. Then in gdb I tried

source ~/PyCortexDebug/cmdebug/svd_gdb.py

which gives the following error

Traceback (most recent call last):
  File "~/PyCortexDebug/cmdebug/svd_gdb.py", line 26, in <module>
ModuleNotFoundError: No module named 'cmdebug'

Any obvious thing that I am missing? Thanks.

EarthLord avatar Jan 18 '22 13:01 EarthLord

Is there a chance your GDB is built with Python2? This is surprisingly common still these days. Try installing the python2 branch and see if it picks it up.

bnahill avatar Jan 19 '22 02:01 bnahill

Just reporting here in case someone else bumps into this error.

After seeing this response, I verified that my gdb-multiarch is built with Python3.x.

To verify, I ran the following inside my gdb prompt:

(gdb) py
>import sys
>print(sys.version)
>end
3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0]

To fix the issue, I had to run the following in this project directory:

pip3 install ./

After that, I was able to load the python file from GDB and got past this step.

lukebayes avatar Aug 09 '22 16:08 lukebayes