< expLog

Python GDB

There's a significant amount of documentation of using GDB on the Python wiki: but first, I need to get debug symbols for Python on Arch linux.

Getting debug symbols for Arch linux (abandoned)

The Arch Wiki has a lot of helpful documentation about this (as expected), which recommends doing a custom package build:

pacman -S asp # Get ASP to work with ABS
asp checkout python # Fetch the python PKGBUILD

cp -r python/repos/repo-x86_64/PKGBUILD python-dbg

Added options\=(debug !strip) to the file to retain debug symbols.

Finally, to do makepkg I also had to download some dependencies (one of which, deliciously, was GDB). I also had to accept the GPG key for python, which is a slightly scary experience; I wonder if I could simply have built my python checkout instead.


Kicked off the actual build for python, which I expect to take some time and a significant number of cycles. The compilation ultimately failed with a failed ncurses test; and I can't say I'm excited about debugging those.

Simply building python locally

Cloning and building python master was far simpler and more convenient, nicely documented on the cpython devguide.

./configure --with-pydebug
make -j4

Building also generates the magical python-gdb.py file in the root directory, which extends GDB's with python to pretty print python. This is also conveniently documented in the devguide.

DebuggingWithGDB discusses how to actually run a python program under GDB.

gdb python
run <program>.py

The python-gdb.py extension

Other references

Py-spy looks fascinating, and might be something I want to play with.