I have a large cython module that I want to debug interactively, and ultimately view the contents of some numpy arrays.
My project is using python3. I am using the debug version python3-dbg to build the project and I do have the debug version of numpy installed.
I am on linux mint 18.3, cython v 0.28.1 and gdb version 8.1 .
I am able to set breakpoints and step through the code. However I can not view cython variables, and have no idea how to view a numpy array.
One can see the current set of local variables, which are all cdef defined.
(e.g.
cdef np.ndarray Gs = self.sprdUp(Strain)
cdef int Ktrain = Strain.shape[2] )
(gdb) cy locals
Gs = (PyArrayObject *) 0x7fffcb24f2c0
Ktrain = (int) 16
self = (struct __pyx_obj_12polarnetwork_network *) 0x7fffcb245218
However it is impossible to view these variables using normal means. For example:
(gdb) cy print Ktrain
Python Exception <type 'exceptions.AttributeError'> 'PyDictObjectPtr' object has no attribute 'items':
Error occurred in Python command: 'PyDictObjectPtr' object has no attribute 'items'
Instead I have to print the C variable name to see it.
(gdb) print __pyx_v_Ktrain
$5 = 16
However what I really need is to print values of Gs
(gdb) cy print Gs[0,0,0,0]
Python Exception <type 'exceptions.AttributeError'> 'PyDictObjectPtr' object has no attribute 'items':
Error occurred in Python command: 'PyDictObjectPtr' object has no attribute 'items'
I get a similiar dictionary error with other cy commands, e.g.
(gdb) cy global
Python Exception <type 'exceptions.AttributeError'> 'PyDictObjectPtr' object has no attribute 'items':
Error occurred in Python command: 'PyDictObjectPtr' object has no attribute 'items'
It appears to be hopeless, unless I can somehow dereference the PyArrayObject pointer via straight C debugging.
Why is this happening and what is a good work-around?