summaryrefslogtreecommitdiff
path: root/Cython/Debugger/libpython.py
diff options
context:
space:
mode:
authorMark Florisson <markflorisson88@gmail.com>2011-03-26 11:19:26 +0100
committerMark Florisson <markflorisson88@gmail.com>2011-03-26 11:19:26 +0100
commita0dc7e649c44621a812930c93be0c61cdee3f8b6 (patch)
treed7958da42ce100f72b25e3a073dfdc8fdb265070 /Cython/Debugger/libpython.py
parent298ea9669c696ff20b1b915138d208edff5654c1 (diff)
downloadcython-a0dc7e649c44621a812930c93be0c61cdee3f8b6.tar.gz
Debugger: Update 'help' documentation
Diffstat (limited to 'Cython/Debugger/libpython.py')
-rw-r--r--Cython/Debugger/libpython.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/Cython/Debugger/libpython.py b/Cython/Debugger/libpython.py
index 44d9f33d7..43b4353b7 100644
--- a/Cython/Debugger/libpython.py
+++ b/Cython/Debugger/libpython.py
@@ -2463,6 +2463,20 @@ class FixGdbCommand(gdb.Command):
self.fix_gdb()
+def _evalcode_python(executor, code, input_type):
+ """
+ Execute Python code in the most recent stack frame.
+ """
+ global_dict = gdb.parse_and_eval('PyEval_GetGlobals()')
+ local_dict = gdb.parse_and_eval('PyEval_GetLocals()')
+
+ if (pointervalue(global_dict) == 0 or pointervalue(local_dict) == 0):
+ raise gdb.GdbError("Unable to find the locals or globals of the "
+ "most recent Python function (relative to the "
+ "selected frame).")
+
+ return executor.evalcode(code, input_type, global_dict, local_dict)
+
class PyExec(gdb.Command):
def readcode(self, expr):
@@ -2486,8 +2500,8 @@ class PyExec(gdb.Command):
def invoke(self, expr, from_tty):
expr, input_type = self.readcode(expr)
executor = PythonCodeExecutor()
- result = executor.evalcode(expr, input_type, global_dict, local_dict)
- executor.xdecref(result)
+ executor.xdecref(_evalcode_python(executor, input_type, global_dict,
+ local_dict))
gdb.execute('set breakpoint pending on')