summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMark Florisson <markflorisson88@gmail.com>2010-09-19 00:44:06 +0200
committerMark Florisson <markflorisson88@gmail.com>2010-09-19 00:44:06 +0200
commitf88e64b67c619ec8bfa23779dcda78ace535bb6b (patch)
tree11e7b58be6767cc5675b4676f4db95f5f60e5bb6 /bin
parentb6dbdc5d40c3745a06db674e5171c2f31e311a51 (diff)
downloadcython-f88e64b67c619ec8bfa23779dcda78ace535bb6b.tar.gz
Preliminary debug support for Cython
added the --pyrex-debug flag to Cython's build_ext added the pyrex_debug boolean to Cython's Cython.Distutils.extension.Extension (for per-module debugging information) debug output is written to the cython_debug directory bin/cygdb is included (start this from the build directory) working commands: cy import, cy locals, cy break when debugging is active, export all functions as extern
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cygdb53
1 files changed, 53 insertions, 0 deletions
diff --git a/bin/cygdb b/bin/cygdb
new file mode 100755
index 000000000..227d5545b
--- /dev/null
+++ b/bin/cygdb
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+"""
+The Cython debugger
+
+The current directory should contain a directory named 'cython_debug', or a
+path to the cython project directory should be given (the parent directory of
+cython_debug).
+"""
+
+import os
+import sys
+import glob
+import tempfile
+import subprocess
+
+def main(import_libpython=False, path_to_debug_info=os.curdir):
+ """
+ Start the Cython debugger. This tells gdb to import the Cython and Python
+ extensions (libpython.py and libcython.py) and it enables gdb's pending
+ breakpoints
+ """
+ debug_files = glob.glob(
+ os.path.join(os.curdir, 'cython_debug/cython_debug_info_*'))
+
+ if not debug_files:
+ sys.exit('No debug files were found in the current directory. '
+ 'Aborting.')
+
+ fd, tempfilename = tempfile.mkstemp()
+ f = os.fdopen(fd, 'w')
+ f.write('set breakpoint pending on\n')
+ f.write('python from Cython.Debugger import libcython\n')
+ if import_libpython:
+ f.write('python import libpython')
+ else:
+ f.write('python from Cython.Debugger import libpython\n')
+ f.write('\n'.join('cy import %s\n' % fn for fn in debug_files))
+ f.close()
+
+ p = subprocess.Popen(['gdb', '-command', tempfilename])
+ while True:
+ try:
+ p.wait()
+ except KeyboardInterrupt:
+ pass
+ else:
+ break
+ os.remove(tempfilename)
+
+
+if __name__ == '__main__':
+ main() \ No newline at end of file