cython/cython — pull request #262 by msabramo (2013-10-13 10:12:21+00:00)
Title: Cython/Debugger/Cygdb.py: Add debug logging with `logging` module

This adds configurable logging to show what's going on and to aid in debugging.

Example usage:

```
(py27_cython_dbg)marca@marca-ubuntu13:~/dev/cygdb_example2$ cygdb -vv . -- --args python-dbg -c 'import hello; hello.func_line_1()'
INFO:Cython.Debugger.Cygdb:verbosity = 2
DEBUG:Cython.Debugger.Cygdb:options = ; args = ['.', '--args', 'python-dbg', '-c', 'import hello; hello.func_line_1()']
DEBUG:Cython.Debugger.Cygdb:Done parsing command-line options. path_to_debug_info = '.', gdb_argv = ['--args', 'python-dbg', '-c', 'import hello; hello.func_line_1()']
INFO:Cython.Debugger.Cygdb:Launching gdb with command file: /tmp/tmpHicium and gdb_argv: ['--args', 'python-dbg', '-c', 'import hello; hello.func_line_1()']
DEBUG:Cython.Debugger.Cygdb:Command file (/tmp/tmpHicium) contains: """
# This is a gdb command file
# See https://sourceware.org/gdb/onlinedocs/gdb/Command-Files.html

set breakpoint pending on
set print pretty on

python
# Activate virtualenv, if we were launched from one
import os
virtualenv = os.getenv('VIRTUAL_ENV')
if virtualenv:
path_to_activate_this_py = os.path.join(virtualenv, 'bin', 'activate_this.py')
print("gdb command file: Activating virtualenv: %s; path_to_activate_this_py: %s"
% (virtualenv, path_to_activate_this_py,))
execfile(path_to_activate_this_py, dict(__file__=path_to_activate_this_py))

from Cython.Debugger import libcython, libpython
end
file /usr/bin/python-dbg
cy import ./cython_debug/cython_debug_info_hello

cy import ./cython_debug/cython_debug_info_hello.xml
python
import sys
try:
gdb.lookup_type('PyModuleObject')
except RuntimeError:
sys.stderr.write(
'Python was not compiled with debug symbols (or it was '
'stripped). Some functionality may not work (properly).\n')
end
"""
INFO:Cython.Debugger.Cygdb:Spawning gdb...
INFO:Cython.Debugger.Cygdb:Spawned gdb (pid 9047)
DEBUG:Cython.Debugger.Cygdb:Waiting for gdb (pid 9047) to exit...
GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /home/marca/virtualenvs/py27_cython_dbg/bin/python-dbg...done.
gdb command file: Activating virtualenv: /home/marca/virtualenvs/py27_cython_dbg; path_to_activate_this_py: /home/marca/virtualenvs/py27_cython_dbg/bin/activate_this.py
(gdb) quit
close failed in file object destructor:
IOError: [Errno 9] Bad file descriptor
DEBUG:Cython.Debugger.Cygdb:Wait for gdb (pid 9047) to exit is done. Returned: 0
DEBUG:Cython.Debugger.Cygdb:Removing temp command file: /tmp/tmpHicium
DEBUG:Cython.Debugger.Cygdb:Removed temp command file: /tmp/tmpHicium
[45622 refs]
```