gdb: remove iterate_over_breakpoints function
[deliverable/binutils-gdb.git] / gdb / python / py-breakpoint.c
index 4710f3e9e6a6f70b95f62bd70a0ddad7b58093bd..a2ce4cdd06fd7ab3cf42a3bd6d2b00e907b8d127 100644 (file)
@@ -898,25 +898,24 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
   return 0;
 }
 
-\f
+/* Append to LIST the breakpoint Python object associated to B.
+
+   Return true on success.  Return false on failure, with the Python error
+   indicator set.  */
 
 static bool
 build_bp_list (struct breakpoint *b, PyObject *list)
 {
   PyObject *bp = (PyObject *) b->py_bp_object;
-  int iserr = 0;
 
   /* Not all breakpoints will have a companion Python object.
      Only breakpoints that were created via bppy_new, or
      breakpoints that were created externally and are tracked by
      the Python Scripting API.  */
-  if (bp)
-    iserr = PyList_Append (list, bp);
-
-  if (iserr == -1)
+  if (bp == nullptr)
     return true;
 
-  return false;
+  return PyList_Append (list, bp) == 0;
 }
 
 /* Static function to return a tuple holding all breakpoints.  */
@@ -931,15 +930,11 @@ gdbpy_breakpoints (PyObject *self, PyObject *args)
   if (list == NULL)
     return NULL;
 
-  /* If iterate_over_breakpoints returns non NULL it signals an error
-     condition.  In that case abandon building the list and return
-     NULL.  */
-  auto callback = [&] (breakpoint *bp)
-    {
-      return build_bp_list(bp, list.get ());
-    };
-  if (iterate_over_breakpoints (callback) != NULL)
-    return NULL;
+  /* If build_bp_list returns false, it signals an error condition.  In that
+     case abandon building the list and return nullptr.  */
+  for (breakpoint *bp : all_breakpoints ())
+    if (!build_bp_list (bp, list.get ()))
+      return nullptr;
 
   return PyList_AsTuple (list.get ());
 }
This page took 0.023779 seconds and 4 git commands to generate.