Table of Content
Building GDB
For Linux and Mac
Prerequisits
- Download and extract the following parts:
- Python source [python.org]
- Expat source [sourceforge.net]
- GDB source [ftp.gnu.org]
- GDB Patches [download.qt.nokia.com]
Building Python
- Go to the directory where you have extracted the Python source and run:
- unset PYTHONHOME
- configure --prefix=<python path>
- make
- make install
Building Expat
- Go to the directory where you have extracted the Expat source and run:
- configure --prefix=<expat path>
- make
- make install
Building GDB
- Targets to build: x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, arm-none-linux-gnueabi, arm-none-symbianelf
- Note: Make sure to run “make distclean” between configure with different targets.
- Go to the directory where you have extracted the GDB source and run once:
- patch -p2 < pythonhome-<gdb version>.patch
- patch -p1 < gdb-<gdb version>-IPv6.patch
- Then run for each target:
- export PYTHONHOME=<python path>
- export PATH=<python path>/bin:<expat path>/bin:$PATH
- configure --disable-nls --prefix=/usr --target<target>
- make
- strip gdb/gdb
Shipping
- Create a directory for the GDB’s from the last step.
- Copy gdb/gdb from for every target you have build to this directory.
- Rename gdb to gdb-<target> to differentiate the GDB’s.
- Copy the directory <pythonpath>/lib to the created directory created in this step.
For Windows
A msys Environment with MinGW is required to build the GDB on Windows.
If this is not installed on the system download and install
Note: You should take a shortcut by downloading the pre-compiled Python 2.7 from the build link in the download section below.
Note: Make sure to extract files with Unix file endings. =configure= will fail spectacularly otherwise
Prerequisits
- Download and extract the following parts:
- pre-compiled Python 2.7 [download.qt.nokia.com]
- libiconv source [ftp.gnu.org]
- Expat source [sourceforge.net]
- GDB source [ftp.gnu.org]
- GDB Patches [download.qt.nokia.com]
Building Python
Note: Only follow this part if you cannot use the pre-compiled version of Python for some reason!
- Download the Python 2.7.1 source tarball [python.org]
- Apply attached setpythonhome.diff patch (line numbers may need to be adjusted)
- Build Python with MSVS according to the documentation
- For the VS2008:
- cd PCbuild
- pcbuild.sln
- file =readme.txt= tells what will build
- For the VS2005,
- cd PC\VS8.0
- pcbuild.sln
- But the VS2005 sln file is not guaranteed to be up to date. If you don’t have “pexports.exe” extract it somewhere in your path from the pexports zip file [emmestech.com]
- For the VS2008:
- From a command line in directory PCBuild or PC\VS8.0:
- pexports python27.dll | sed "s/^_\([[:alnum:]_]\+\)@[[:digit:]]\+/\1/" > python27.def
- dlltool -k --input-def python27.def --dllname python27.dll --output-lib libpython2.7.a
- Note: the dot in 2.7 is important!
Building Expat
- Start a msys shell and go to the directory where you have extracted the Expat source and run:
- configure --prefix=<expat path> --enable-static
- make
- make install
Building libiconv
- Start a msys shell and go to the directory where you have extracted the libiconv source and run:
- configure --prefix=<libiconv path> --enable-static
- make
- make install
Building GDB
- Targets to build: arm-none-symbianelf, arm-none-linux-gnueabi, i686-pc-mingw32
- Note: Make sure to run “make distclean” between configure with different targets.
- Start a msys shell and go to the directory where you have extracted the GDB source and run once:
- patch -p1 < gdb-<gdb version>-IPv6.patch
- Then run for each target:
- configure --target<target> --disable-nls /
- --with-libiconv-prefix=<libiconv path> /
- --with-expat --with-libexpat-prefix=<expat path> /
- --with-python
- patch -p1 < gdb-<gdb version>-IPv6.patch
- make LDFLAGS="-L<python path>/lib -lpthread -ldl -lutil -lpython27" CFLAGS="-I<python path>/include"
Shipping
- Create a directory for the GDB’s from the last step.
- Copy gdb/gdb.exe from for every target you have build to this directory.
- Rename gdb to gdb-<target> to differentiate the GDB’s.
- Run depends.exe from DependencyWalker [dependencywalker.com] on each GDB and ship the required DLLs in the same directory.
- For me, that’s:
- libexpat-1.dll
- libiconv-2.dll
- libpython2.7.dll
- You need to also ship the lib/ directory from the fake install directory.
Testing
- To test the GDB’s just run the executable and type:
- python print 23
- When the GDB prints “23” everything works fine.
Profit!
Congrats, if you have made it until here, you now have a Python enabled GDB debugger.
Downloads
- GDB 7.2 binaries [get.qt.nokia.com]
- GDB 7.2 build prerequisites [get.qt.nokia.com]

