Пример #1
0
    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
Пример #2
0
    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))