Debugging running Python scripts with PDB via GDB
disconnect3d.pl
disconnect3d.pl
import signal
def sigusr1_handler(signum, stack):
breakpoint()
signal.signal(signal.SIGUSR1, sigusr1_handler)
And then I can drop into pdb by sending a signal: $ kill -s sigusr1 $PID
I also want to highlight something non-obvious about debugging mixed native and Python code. Because Python is interpreted, it is possible to run both gdb and pdb on a process at the same time, and set breakpoints using both, without issue. This can be really nice when you're working on Python bindings.