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  <ssbssa@yahoo.de>

	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  <ssbssa@yahoo.de>

	PR python/19151
	* python.texi (Breakpoints In Python): Document
	gdb.BP_HARDWARE_BREAKPOINT.

gdb/testsuite/ChangeLog:

2021-01-21  Hannes Domani  <ssbssa@yahoo.de>

	PR python/19151
	* gdb.python/py-breakpoint.exp: Add tests for hardware breakpoints.
This commit is contained in:
Hannes Domani 2021-01-02 13:51:27 +01:00
parent 7cb6d92a3f
commit 325d39e4e0
6 changed files with 53 additions and 2 deletions

View file

@ -252,6 +252,29 @@ proc_with_prefix test_bkpt_invisible { } {
"Check maint info breakpoints shows invisible breakpoints"
}
proc_with_prefix test_hardware_breakpoints { } {
global srcfile testfile hex decimal
# Start with a fresh gdb.
clean_restart ${testfile}
if ![runto_main] then {
fail "cannot run to main."
return 0
}
delete_breakpoints
gdb_test "python hbp1 = gdb.Breakpoint(\"add\", type=gdb.BP_HARDWARE_BREAKPOINT)" \
".*Hardware assisted breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\." \
"Set hardware breakpoint"
gdb_test "python print (gdb.breakpoints()\[0\].type == gdb.BP_HARDWARE_BREAKPOINT)" \
"True" "Check hardware breakpoint type"
gdb_test "continue" \
".*Breakpoint ($decimal)+, add.*" \
"Test hardware breakpoint stop"
}
proc_with_prefix test_watchpoints { } {
global srcfile testfile hex decimal
@ -718,6 +741,7 @@ test_bkpt_basic
test_bkpt_deletion
test_bkpt_cond_and_cmds
test_bkpt_invisible
test_hardware_breakpoints
test_watchpoints
test_bkpt_internal
test_bkpt_eval_funcs