Use gdbpy_ref in gdbpy_breakpoint_cond_says_stop
authorTom Tromey <tom@tromey.com>
Sun, 20 Nov 2016 17:13:31 +0000 (10:13 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 11 Jan 2017 02:14:00 +0000 (19:14 -0700)
This changes gdbpy_breakpoint_cond_says_stop to use gdbpy_ref rather
than explicit reference management.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-breakpoint.c (gdbpy_breakpoint_cond_says_stop): Use
gdbpy_ref.

gdb/ChangeLog
gdb/python/py-breakpoint.c

index 49722e8001947b65447870271e53f9edec2fccbe..74e32bfd4a6fd600664390b141bc6377d7b6f0bf 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-10  Tom Tromey  <tom@tromey.com>
+
+       * python/py-breakpoint.c (gdbpy_breakpoint_cond_says_stop): Use
+       gdbpy_ref.
+
 2017-01-10  Tom Tromey  <tom@tromey.com>
 
        * python/py-arch.c (archpy_disassemble): Use gdbpy_ref.  Don't
index f3520cc8be50fe31496248873dca44898de9b6ea..f268b2bb44627943ff5f2f511fd3a1dea64b3118 100644 (file)
@@ -805,12 +805,12 @@ gdbpy_breakpoint_cond_says_stop (const struct extension_language_defn *extlang,
 
   if (PyObject_HasAttrString (py_bp, stop_func))
     {
-      PyObject *result = PyObject_CallMethod (py_bp, stop_func, NULL);
+      gdbpy_ref result (PyObject_CallMethod (py_bp, stop_func, NULL));
 
       stop = 1;
-      if (result)
+      if (result != NULL)
        {
-         int evaluate = PyObject_IsTrue (result);
+         int evaluate = PyObject_IsTrue (result.get ());
 
          if (evaluate == -1)
            gdbpy_print_stack ();
@@ -819,8 +819,6 @@ gdbpy_breakpoint_cond_says_stop (const struct extension_language_defn *extlang,
             the Python breakpoint wants GDB to continue.  */
          if (! evaluate)
            stop = 0;
-
-         Py_DECREF (result);
        }
       else
        gdbpy_print_stack ();
This page took 0.032147 seconds and 4 git commands to generate.