I am trying to install GDB7.8 with Python support. From the source folder, I am running ./configure --with-python
When I did tab-complete from –with- I did not see Python in the list.
But when I ran configure with that flag, it did not baulk.
When I run make, it complains that Python is not found.
checking for python2.7... no
but Python is installed:
$ which python
python python2.7 python2.7-dbg-config
python2 python2.7-dbg
$ which python2.7
/usr/bin/python2.7
I compiled GDB without –with-python
and things installed without error. I was under the impression that GDB7.8 had Python support without the need for special flags. But when I run:
$gdb python
(gdb) run test.py
I get some sort of cannot import gdb Import error
So then I tried calling "pi":
(gdb) pi printf.py
Python scripting is not supported in this copy of GDB.
So… how do I get Python support in GDB7.8? is it actually not supported? Or should I not call "pi"?
Best Answer
I spent quite a bit of time working on getting gdb (7.9) to work with Python (2.7). In the end everything worked rather well. However, there are a bunch of things that you have to get right. The key point is that the gdb configure script tries to compile a small C program that looks like this.
If this program won't compile, then Python support won't be built. For this program to compile, the Python.h include file must be found in
/usr/include/python2.7
. This file will only exist if thepython-devel
package is installed. On my system (redhat), the command for installing this package issudo yum install python-devel
.However, that's not enough to get Python installed. Before the configure script tries to compile the C program, it gets various options from
python-config.py
. If these options aren't correct, then the C program won't compile. On my system,python-config.py
returned the options below.These options didn't cause any problems in my environment. Other folks have had problems with the options returned from
python-config.py
and have made changes topython-config.py
to resolve these problems. On my system the complete compile command wasThis compile command completed without any errors as soon as I installed
python-devel
. Note you don't have to manually enter thegcc
command. I did run thegcc
command several times to make sure everything was correct. Normally, the configure script will run the compiler for you. Also note that to get the overall gdb install process to complete,makeinfo
also had to be installed. The command for installing makeinfo wassudo yum install texinfo
.Overall, the correct set of steps seems to be
Install python-devel
Install texinfo
Download the gdb source and gunzip it and untar it.
cd
to thegdb-7.9
directory with theconfigure
file.It should be possible to get gdb to work with Python 3. The various gdb scripts and install programs mention Python 3 in many, many places. However, the correct procedure for installing gdb with Python 3 is unknown to me at this point.