def evalcode(self, code, input_type): """ Evaluate `code` in a Python or Cython stack frame using the given `input_type`. """ frame = self._find_first_cython_or_python_frame() executor = libpython.PythonCodeExecutor() if self.is_python_function(frame): return libpython._evalcode_python(executor, code, input_type) return self._evalcode_cython(executor, code, input_type)
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 invoke(self, expr, from_tty): expr, input_type = self.readcode(expr) executor = libpython.PythonCodeExecutor() executor.xdecref(self.evalcode(expr, executor.Py_single_input))