[Cython] cygdb bugs when debugging python 3 extensions
Ben Booth
benwbooth at gmail.com
Fri Dec 12 23:14:12 CET 2014
I'm trying to figure out how to use cygdb to debug extensions built with python 3. I've tested all the debugger commands listed in http://docs.cython.org/src/userguide/debugging.html <http://docs.cython.org/src/userguide/debugging.html> when debugging python 2 extensions and everything works great. But some of the commands seem to be broken when debugging python 3 extensions.
Here are the debugger commands that I've confirmed as working with python 3 extensions:
cy break
cy step
cy next
cy run
cy cont
cy down
cy finish .. works but prints error message
cy exec
cy list
cy_lineno()
cy_eval()
cy_cname()
Here are the commands which fail under python 3, and the error message that is given for each:
cy up
Python Exception <class 'gdb.error'> There is no member named length.:
Error occurred in Python command: There is no member named length.
cy finish .. works but gives error
Python Exception <class 'gdb.error'> There is no member named length.:
Error occurred in Python command: There is no member named length.
cy bt
Python Exception <class 'gdb.error'> There is no member named length.:
Error occurred in Python command: There is no member named length.
cy print
Python Exception <class 'gdb.error'> There is no member named ma_mask.:
Python Exception <class 'gdb.error'> Error occurred in Python command: There is no member named ma_mask.:
Error occurred in Python command: Error occurred in Python command: There is no member named ma_mask.
cy set x = 2
Python Exception <class 'gdb.error'> No symbol "__pyx_v_10helloworld_x" in current context.:
Error occurred in Python command: No symbol "__pyx_v_10helloworld_x" in current context.
cy locals
Python Exception <class 'gdb.error'> There is no member named ma_mask.:
Error occurred in Python command: There is no member named ma_mask.
cy globals
Python Exception <class 'gdb.error'> There is no member named ma_mask.:
Error occurred in Python command: There is no member named ma_mask.
cy_cvalue()
Python Exception <class 'gdb.error'> There is no member named ma_mask.:
Error occurred in Python convenience function: There is no member named ma_mask.
In summary:
- The "cy set" and "cy_cname()" commands seem to be giving incorrect C names for cython variables. I did a grep of the generated .c source file for "__pyx_v_10helloworld_x", and didn't get any hits. Luckily, the "cy exec" command works, so I can use that to get the value of variables as a workaround.
- Any commands related to viewing or traversing the call stack seem to give an error related to a missing "length" member.
- Commands related to printing the value of a variable complain about a missing "ma_mask" member.
Here are the source files I used for the test:
helloworld.py:
import helloworld
helloworld.pyx:
x = 1
y = "a"
print("Hello World 1")
print("Hello World 2")
print("Hello World 3")
print("Hello World 4")
print("Hello World 5")
print("Hello World 6")
print("Hello World 8")
print("Hello World 9")
print("Hello World 10")
setup.py:
from distutils.core import setup
from Cython.Build import cythonize
from distutils.extension import Extension
extensions = [Extension("helloworld", ["helloworld.pyx"])]
setup(ext_modules=cythonize(extensions, gdb_debug=True, output_dir="."))
To compile I ran:
python setup.py build_ext --inplace
To debug, I ran:
cygdb -vv . -- --args python helloworld.py
Here is my python version:
Python 3.4.2
I used pyenv (https://github.com/yyuu/pyenv <https://github.com/yyuu/pyenv>) to build and install the latest Python 3 version with debugging symbols enabled.
Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20141212/8b15559a/attachment.html>
More information about the cython-devel
mailing list