gdb/python: allow for catchpoint type breakpoints in python
[deliverable/binutils-gdb.git] / gdb / python / py-bpevent.c
index 8e4afe47e21bcbbcef2b8091666f82ee2c3aa8dc..736e498d5c7a52de37b5227fb77d5eda2f5587eb 100644 (file)
@@ -1,6 +1,6 @@
 /* Python interface to inferior breakpoint stop events.
 
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include "defs.h"
 #include "py-stopevent.h"
 
-static PyTypeObject breakpoint_event_object_type;
-
 /* Create and initialize a BreakpointEvent object.  This acquires new
    references to BREAKPOINT_LIST and FIRST_BP.  */
 
-PyObject *
+gdbpy_ref<>
 create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp)
 {
-  PyObject *breakpoint_event_obj =
-      create_stop_event_object (&breakpoint_event_object_type);
+  gdbpy_ref<> breakpoint_event_obj
+    = create_stop_event_object (&breakpoint_event_object_type);
 
-  if (!breakpoint_event_obj)
-    goto fail;
+  if (breakpoint_event_obj == NULL)
+    return NULL;
 
-  if (evpy_add_attribute (breakpoint_event_obj,
-                          "breakpoint",
-                          first_bp) < 0)
-    goto fail;
-  if (evpy_add_attribute (breakpoint_event_obj,
-                          "breakpoints",
-                          breakpoint_list) < 0)
-    goto fail;
+  if (evpy_add_attribute (breakpoint_event_obj.get (),
+                         "breakpoint",
+                         first_bp) < 0)
+    return NULL;
+  if (evpy_add_attribute (breakpoint_event_obj.get (),
+                         "breakpoints",
+                         breakpoint_list) < 0)
+    return NULL;
 
   return breakpoint_event_obj;
-
- fail:
-  Py_XDECREF (breakpoint_event_obj);
-  return NULL;
 }
-
-GDBPY_NEW_EVENT_TYPE (breakpoint,
-                      "gdb.BreakpointEvent",
-                      "BreakpointEvent",
-                      "GDB breakpoint stop event object",
-                      stop_event_object_type,
-                      static);
This page took 0.025101 seconds and 4 git commands to generate.