Using GDB with Cython
To debug Cython, you need GDB >= 7.0. On Mac OS X Xcode, build tools have moved to LLVM and lldb as respective debuggers. You can install gdb
using homebrew:
$ brew install gdb
We cannot use the Python debugger since the Cython code is compiled down to C/C++. Therefore, when debugging without the Cython plugin, you will be stepping through the generated C/C++ code, which won't be helpful as it won't understand the context of the Cython program.
Running cygdb
Cygdb is installed as a part of Cython and is a wrapper over GDB (it invokes GDB with arguments to set up the Cython plugin). Before you can debug the Cython code, we need to generate the debugging information. Just like C/C++, we need to specify compiler options to generated debuggable code we can pass –gdb
when invoking the Cython compiler:
$ cython --gdb cycode.pyx
Note
Before you start debugging on Debian, you need to install the Python debug information package and GDB as it is not installed...