1

I compiled&installed gdb(7.1.1) from the source code by doing CC=gcc-6 ./configure --with-python=python3 && make then sudo make install. Then I invoked gdb from bash as usual. But when I tried to load my python script within gdb by doing source asdf.py, it threw an error saying

AttributeError: 'module' object has no attribute 'execute'

I tried to change my code to try more functions from the gdb module but every function I tried to execute was looking like it's missing. I invoked python interpreter within gdb then did import gdb and then dir(gdb) to see gdb's contents, the output was

['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']

So there really is a module called gdb but it's contents are empty. What could have gone wrong during installation? Or is this a bug in gdb? How can I fix this?

Korcan Karaokçu
  • 467
  • 4
  • 18
  • Did you call any of your files `gdb.py`? – user2357112 May 28 '16 at 17:37
  • No, I didn't. Where is the gdb.py file anyways? – Korcan Karaokçu May 28 '16 at 17:50
  • Dunno. That list of attributes, with `__path__` and no `__file__`, looks like what you'd get with a [namespace package](https://www.python.org/dev/peps/pep-0420/). That'd happen if Python found one or more folders named `gdb` on the module search path, but it didn't find a `gdb.py` or a `gdb` folder with an `__init__.py`. That means GDB's `gdb` module isn't getting found. – user2357112 May 28 '16 at 17:59
  • I installed the previous gdb version I used to use to see how should a correct installation should look like and I noticed that gdb.py is located in `/usr/share/gdb/python/gdb` and the file is not empty. So while doing install, it didn't load any python libraries... interesting – Korcan Karaokçu May 28 '16 at 18:19

1 Answers1

0

I found that the files needed for gdb is located at gdb/data-directory. So moving all files from to the place where python scripts should be did the trick.

sudo cp -R gdb/data-directory/* /usr/share/gdb/
Korcan Karaokçu
  • 467
  • 4
  • 18