From 325d39e4e09f0b7c8eec7e33ca93d0a9c82632ec Mon Sep 17 00:00:00 2001 From: Hannes Domani Date: Sat, 2 Jan 2021 13:51:27 +0100 Subject: Add Python support for hardware breakpoints This allows the creation of hardware breakpoints in Python with gdb.Breakpoint(type=gdb.BP_HARDWARE_BREAKPOINT) And they are included in the sequence returned by gdb.breakpoints(). gdb/ChangeLog: 2021-01-21 Hannes Domani PR python/19151 * python/py-breakpoint.c (bppy_get_location): Handle bp_hardware_breakpoint. (bppy_init): Likewise. (gdbpy_breakpoint_created): Likewise. gdb/doc/ChangeLog: 2021-01-21 Hannes Domani PR python/19151 * python.texi (Breakpoints In Python): Document gdb.BP_HARDWARE_BREAKPOINT. gdb/testsuite/ChangeLog: 2021-01-21 Hannes Domani PR python/19151 * gdb.python/py-breakpoint.exp: Add tests for hardware breakpoints. --- gdb/python/py-breakpoint.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gdb/python/py-breakpoint.c') diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 9f6ae96..3fbb1c6 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -58,6 +58,7 @@ static struct pybp_code pybp_codes[] = { { "BP_NONE", bp_none}, { "BP_BREAKPOINT", bp_breakpoint}, + { "BP_HARDWARE_BREAKPOINT", bp_hardware_breakpoint}, { "BP_WATCHPOINT", bp_watchpoint}, { "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint}, { "BP_READ_WATCHPOINT", bp_read_watchpoint}, @@ -383,7 +384,8 @@ bppy_get_location (PyObject *self, void *closure) BPPY_REQUIRE_VALID (obj); - if (obj->bp->type != bp_breakpoint) + if (obj->bp->type != bp_breakpoint + && obj->bp->type != bp_hardware_breakpoint) Py_RETURN_NONE; const char *str = event_location_to_string (obj->bp->location.get ()); @@ -793,6 +795,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) switch (type) { case bp_breakpoint: + case bp_hardware_breakpoint: { event_location_up location; symbol_name_match_type func_name_match_type @@ -834,7 +837,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) create_breakpoint (python_gdbarch, location.get (), NULL, -1, NULL, 0, - temporary_bp, bp_breakpoint, + temporary_bp, type, 0, AUTO_BOOLEAN_TRUE, ops, @@ -1008,6 +1011,7 @@ gdbpy_breakpoint_created (struct breakpoint *bp) return; if (bp->type != bp_breakpoint + && bp->type != bp_hardware_breakpoint && bp->type != bp_watchpoint && bp->type != bp_hardware_watchpoint && bp->type != bp_read_watchpoint -- cgit v1.1