/* Python interface to breakpoints
- Copyright (C) 2008-2019 Free Software Foundation, Inc.
+ Copyright (C) 2008-2020 Free Software Foundation, Inc.
This file is part of GDB.
static PyObject *
bppy_get_location (PyObject *self, void *closure)
{
- const char *str;
gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
BPPY_REQUIRE_VALID (obj);
if (obj->bp->type != bp_breakpoint)
Py_RETURN_NONE;
- struct event_location *location = obj->bp->location.get ();
- /* "catch throw" makes a breakpoint of type bp_breakpoint that does
- not have a location. */
- if (location == nullptr)
- Py_RETURN_NONE;
- str = event_location_to_string (location);
+ const char *str = event_location_to_string (obj->bp->location.get ());
if (! str)
str = "";
return host_string_to_python_string (str).release ();
location = new_explicit_location (&explicit_loc);
}
+ const struct breakpoint_ops *ops =
+ breakpoint_ops_for_event_location (location.get (), false);
+
create_breakpoint (python_gdbarch,
location.get (), NULL, -1, NULL,
0,
temporary_bp, bp_breakpoint,
0,
AUTO_BOOLEAN_TRUE,
- &bkpt_breakpoint_ops,
+ ops,
0, 1, internal_bp, 0);
break;
}
\f
-static int
-build_bp_list (struct breakpoint *b, void *arg)
+static bool
+build_bp_list (struct breakpoint *b, PyObject *list)
{
- PyObject *list = (PyObject *) arg;
PyObject *bp = (PyObject *) b->py_bp_object;
int iserr = 0;
iserr = PyList_Append (list, bp);
if (iserr == -1)
- return 1;
+ return true;
- return 0;
+ return false;
}
/* Static function to return a tuple holding all breakpoints. */
/* If iterate_over_breakpoints returns non NULL it signals an error
condition. In that case abandon building the list and return
NULL. */
- if (iterate_over_breakpoints (build_bp_list, list.get ()) != NULL)
+ auto callback = [&] (breakpoint *bp)
+ {
+ return build_bp_list(bp, list.get ());
+ };
+ if (iterate_over_breakpoints (callback) != NULL)
return NULL;
return PyList_AsTuple (list.get ());
if (bppy_pending_object)
{
newbp = bppy_pending_object;
+ Py_INCREF (newbp);
bppy_pending_object = NULL;
}
else
newbp->bp = bp;
newbp->bp->py_bp_object = newbp;
newbp->is_finish_bp = 0;
- Py_INCREF (newbp);
++bppy_live;
}
else