gdb/python: allow for catchpoint type breakpoints in python

This commit adds initial support for catchpoints to the python
breakpoint API.

This commit adds a BP_CATCHPOINT constant which corresponds to
GDB's internal bp_catchpoint.  The new constant is documented in the
manual.

The user can't create breakpoints with type BP_CATCHPOINT after this
commit, but breakpoints that already exist, obtained with the
`gdb.breakpoints` function, can now have this type.  Additionally,
when a stop event is reported for hitting a catchpoint, GDB will now
report a BreakpointEvent with the attached breakpoint being of type
BP_CATCHPOINT - previously GDB would report a generic StopEvent in
this situation.

gdb/ChangeLog:

	* NEWS: Mention Python BP_CATCHPOINT feature.
	* python/py-breakpoint.c (pybp_codes): Add bp_catchpoint support.
	(bppy_init): Likewise.
	(gdbpy_breakpoint_created): Likewise.

gdb/doc/ChangeLog:

	* python.texinfo (Breakpoints In Python): Add BP_CATCHPOINT
	description.

gdb/testsuite/ChangeLog:

	* gdb.python/py-breakpoint.c (do_throw): New function.
	(main): Call do_throw.
	* gdb.python/py-breakpoint.exp (test_catchpoints): New proc.
This commit is contained in:
Andrew Burgess 2021-05-05 15:26:28 +01:00
parent 08080f9744
commit 6b95f5ad96
8 changed files with 108 additions and 1 deletions

View file

@ -86,6 +86,7 @@ static struct pybp_code pybp_codes[] =
{ "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint},
{ "BP_READ_WATCHPOINT", bp_read_watchpoint},
{ "BP_ACCESS_WATCHPOINT", bp_access_watchpoint},
{ "BP_CATCHPOINT", bp_catchpoint},
{NULL} /* Sentinel. */
};
@ -883,6 +884,8 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
error(_("Cannot understand watchpoint access type."));
break;
}
case bp_catchpoint:
error (_("BP_CATCHPOINT not supported"));
default:
error(_("Do not understand breakpoint type to set."));
}
@ -1038,7 +1041,8 @@ gdbpy_breakpoint_created (struct breakpoint *bp)
&& bp->type != bp_watchpoint
&& bp->type != bp_hardware_watchpoint
&& bp->type != bp_read_watchpoint
&& bp->type != bp_access_watchpoint)
&& bp->type != bp_access_watchpoint
&& bp->type != bp_catchpoint)
{
pybp_debug_printf ("is not a breakpoint or watchpoint");
return;