def invoke(self, expr, from_tty): frame = self._find_first_cython_or_python_frame() if self.is_python_function(frame): libpython.py_exec.invoke(expr, from_tty) return expr, input_type = self.readcode(expr) executor = libpython.PythonCodeExecutor() # get the dict of Cython globals and construct a dict in the inferior # with Cython locals global_dict = gdb.parse_and_eval( '(PyObject *) PyModule_GetDict(__pyx_m)') local_dict = gdb.parse_and_eval('(PyObject *) PyDict_New()') cython_function = self.get_cython_function() try: self._fill_locals_dict(executor, libpython.pointervalue(local_dict)) executor.evalcode(expr, input_type, global_dict, local_dict) finally: # try: # tp, val, tb = sys.exc_info() # sys.exc_clear() # # try: # long(gdb.parse_and_eval("(void *) 0")) == 0 # except RuntimeError: # # At this point gdb is broken, just exit this s***e, it # # ain't getting better. # # # /home/mark/source/code/cython/Cython/Debugger/libcython.py:1206: # # RuntimeWarning: tp_compare didn't return -1 or -2 for exception # # long(gdb.parse_and_eval("(void *) 0")) == 0 # # Traceback (most recent call last): # # File "/home/mark/source/code/cython/Cython/Debugger/libcython.py", line 1206, # # in invoke # # long(gdb.parse_and_eval("(void *) 0")) == 0 # # RuntimeError: Cannot convert value to int. # # Error occurred in Python command: Cannot convert value to int. # if sys.exc_info()[0] is None and val is not None: # raise val, tb # # for name, value in libpython.PyDictObjectPtr(local_dict).iteritems(): # name = name.proxyval(set()) # cyvar = cython_function.locals.get(name) # if cyvar is not None and cyvar.type == PythonObject: # gdb.parse_and_eval('set %s = (PyObject *) %d' % (cyvar.cname, # pointervalue(value._gdbval))) # finally: executor.decref(libpython.pointervalue(local_dict))
def _evalcode_cython(self, executor, code, input_type): with libpython.FetchAndRestoreError(): # get the dict of Cython globals and construct a dict in the # inferior with Cython locals global_dict = gdb.parse_and_eval( '(PyObject *) PyModule_GetDict(__pyx_m)') local_dict = gdb.parse_and_eval('(PyObject *) PyDict_New()') try: self._fill_locals_dict(executor, libpython.pointervalue(local_dict)) result = executor.evalcode(code, input_type, global_dict, local_dict) finally: executor.xdecref(libpython.pointervalue(local_dict)) return result
def invoke(self, expr, from_tty): frame = self._find_first_cython_or_python_frame() if self.is_python_function(frame): libpython.py_exec.invoke(expr, from_tty) return expr, input_type = self.readcode(expr) executor = libpython.PythonCodeExecutor() with libpython.FetchAndRestoreError(): # get the dict of Cython globals and construct a dict in the # inferior with Cython locals global_dict = gdb.parse_and_eval( '(PyObject *) PyModule_GetDict(__pyx_m)') local_dict = gdb.parse_and_eval('(PyObject *) PyDict_New()') try: self._fill_locals_dict(executor, libpython.pointervalue(local_dict)) executor.evalcode(expr, input_type, global_dict, local_dict) finally: executor.decref(libpython.pointervalue(local_dict))
def get_pyobject(self, code): value = gdb.parse_and_eval(code) assert libpython.pointervalue(value) != 0 return value