A popular technique for debugging C and Fortran extensions to Python
is to run Python under the gdb debugger. If the code crashes inside
a compiled extension module, this event is caught by gdb. One can
then use gdb in the usual way -- see the stack, examine local variable
values, etc. However, one cannot set a break point, restart Python,
and have that break point survive the restart. Setting a break point
requires that one pause the code after importing the appropriate
extension module, then send an interrupt to Python in order to enter
gdb, and finally set the break point in the usual way.
We have developed a new Python application, called PyDebug, which
introduces a middle-ware layer between gdb and the code being debugged.
PyDebug enables the user to set break points seamlessly inside compiled
C and Fortran extensions to Python and have these break points persist
through code crashes and restarts. Our middle-ware approach, which requires
careful use of both pipes and threading, enables the user to issue any
gdb command from the Python prompt and have it passed through to the gdb
application. One can also embed gdb commands as comments within a Python
script. PyDebug could easily be extended to debuggers other than gdb.