Debugger: Update 'help' documentation
authorMark Florisson <markflorisson88@gmail.com>
Sat, 26 Mar 2011 10:19:26 +0000 (11:19 +0100)
committerMark Florisson <markflorisson88@gmail.com>
Sat, 26 Mar 2011 10:19:26 +0000 (11:19 +0100)
Cython/Debugger/Tests/test_libpython_in_gdb.py
Cython/Debugger/libcython.py
Cython/Debugger/libpython.py

index e45adb22fdaf984fc80bdc4456e1c7f843ebeef7..fd1582edc034c0656c4f182f4708b450b90e2840 100644 (file)
@@ -112,6 +112,4 @@ class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase):
     def test_frame_type(self):
         frame = self.pyobject_fromcode('PyEval_GetFrame()')
 
-        self.assertEqual(type(frame), libpython.PyFrameObjectPtr)
-
-
+        self.assertEqual(type(frame), libpython.PyFrameObjectPtr)
\ No newline at end of file
index fc6a777b2229a172ee84eb661eb3b609a7d10f90..a1d4221e4d5c2b8ab66065a5fac77b9618b8a361 100644 (file)
@@ -592,6 +592,7 @@ class CyCy(CythonCommand):
         cy bt / cy backtrace
         cy list
         cy print
+        cy set
         cy locals
         cy globals
         cy exec
@@ -1245,19 +1246,6 @@ class EvaluateOrExecuteCodeMixin(object):
 
         return result
 
-
-    def _evalcode_python(self, executor, code, input_type):
-        global_dict = gdb.parse_and_eval('PyEval_GetGlobals()')
-        local_dict = gdb.parse_and_eval('PyEval_GetLocals()')
-
-        if (libpython.pointervalue(global_dict) == 0 or
-            libpython.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)
-
     def evalcode(self, code, input_type):
         """
         Evaluate `code` in a Python or Cython stack frame using the given
@@ -1266,7 +1254,7 @@ class EvaluateOrExecuteCodeMixin(object):
         frame = self._find_first_cython_or_python_frame()
         executor = libpython.PythonCodeExecutor()
         if self.is_python_function(frame):
-            return self._evalcode_python(executor, code, input_type)
+            return libpython._evalcode_python(executor, code, input_type)
         return self._evalcode_cython(executor, code, input_type)
 
 
@@ -1291,6 +1279,10 @@ class CySet(CythonCommand):
 
         cy set my_cython_c_variable = 10
         cy set my_cython_py_variable = $cy_eval("{'doner': 'kebab'}")
+
+    This is equivalent to
+
+        set $cy_value("my_cython_variable") = 10
     """
 
     name = 'cy set'
index 44d9f33d7948b49b05e03026aab801cfea3444a6..43b4353b7a1aa535fcc738f15efa701510d7fcc8 100644 (file)
@@ -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')