This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 02/13] Use gdbpy_ref in gdbpy_breakpoint_cond_says_stop
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Sun, 20 Nov 2016 13:41:25 -0700
- Subject: [RFA 02/13] Use gdbpy_ref in gdbpy_breakpoint_cond_says_stop
- Authentication-results: sourceware.org; auth=none
- References: <1479674496-14000-1-git-send-email-tom@tromey.com>
This changes gdbpy_breakpoint_cond_says_stop to use gdbpy_ref rather
than explicit reference management.
2016-11-20 Tom Tromey <tom@tromey.com>
* python/py-breakpoint.c (gdbpy_breakpoint_cond_says_stop): Use
gdbpy_ref.
---
gdb/ChangeLog | 5 +++++
gdb/python/py-breakpoint.c | 8 +++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 527053f..ebb4d71 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2016-11-20 Tom Tromey <tom@tromey.com>
+ * python/py-breakpoint.c (gdbpy_breakpoint_cond_says_stop): Use
+ gdbpy_ref.
+
+2016-11-20 Tom Tromey <tom@tromey.com>
+
* python/py-arch.c (archpy_disassemble): Use gdbpy_ref. Don't
decref results of PyArg_ParseTupleAndKeywords.
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 198669b..418b637 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -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 ();
--
2.7.4