How to change the Python Interpreter that gdb uses?
So although gdb says it's using my 2.7 interpreter
GDB doesn't say that. It says it's using 3.4.0, and that interpreter is linked into GDB, in the form of libpython3.4.a
or libpython3.4.so
.
Since there is no actual Python binary involved, the (minor) bug here is that sys.executable
returns /usr/bin/python
. It would possibly be better for it to return /usr/bin/gdb
instead.
I need a 2.7 interpreter
In that case, you'll have to rebuild gdb
from source, after configuring it with appropriate --with-python
value.
$ apt-get -qq update$ apt-get install gdb python2.7-dbg python3-all-dbg$ gdb -ex r -ex quit --args python2 -c "import sys ; print(sys.version)" # Py2.7$ gdb -ex r -ex quit --args python3 -c "import sys ; print(sys.version)" # Py3.6