diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-breakpoint.c | 14 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-breakpoint.exp | 60 |
3 files changed, 80 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 30db261..567c134 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2021-06-25 Andrew Burgess <andrew.burgess@embecosm.com> + * gdb.python/py-breakpoint.c (do_throw): New function. + (main): Call do_throw. + * gdb.python/py-breakpoint.exp (test_catchpoints): New proc. + +2021-06-25 Andrew Burgess <andrew.burgess@embecosm.com> + * gdb.guile/scm-breakpoint.exp (test_catchpoints): New proc. 2021-06-25 Andrew Burgess <andrew.burgess@embecosm.com> diff --git a/gdb/testsuite/gdb.python/py-breakpoint.c b/gdb/testsuite/gdb.python/py-breakpoint.c index 830e4c2..dca668d 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.c +++ b/gdb/testsuite/gdb.python/py-breakpoint.c @@ -39,6 +39,11 @@ int add (int i) return i + i; /* Break at function add. */ } +void +do_throw () +{ + throw 123; +} int main (int argc, char *argv[]) { @@ -46,6 +51,15 @@ int main (int argc, char *argv[]) int bar = 42; int i; + try + { + do_throw (); + } + catch (...) + { + /* Nothing. */ + } + for (i = 0; i < 10; i++) { result += multiply (foo); /* Break at multiply. */ diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index 64a70ab..d8fb85b 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -737,11 +737,71 @@ proc_with_prefix test_bkpt_probe {} { "-probe in spec string" } +proc_with_prefix test_catchpoints {} { + global srcfile testfile + global gdb_prompt decimal + + # Start with a fresh gdb. + clean_restart ${testfile} + + if ![runto_main] then { + fail "cannot run to main." + return 0 + } + + # Try to create a catchpoint, currently this isn't supported via + # the python api. + gdb_test "python gdb.Breakpoint (\"syscall\", type=gdb.BP_CATCHPOINT)" \ + [multi_line \ + "gdb.error: BP_CATCHPOINT not supported" \ + "Error while executing Python code\\."] \ + "create a catchpoint via the api" + + # Setup a catchpoint. + set num "XXX" + gdb_test_multiple "catch throw" "" { + -re "The feature \'catch throw\' is not supported.*\r\n$gdb_prompt $" { + unsupported "catch syscall isn't supported" + return -1 + } + -re "Catchpoint ($decimal) \\(throw\\)\r\n$gdb_prompt $" { + set num $expect_out(1,string) + pass $gdb_test_name + } + } + + # Look for the catchpoint in the breakpoint list. + gdb_test_multiline "scan breakpoint list for BP_CATCHPOINT" \ + "python" "" \ + "def scan_bp_list ():" "" \ + " for b in gdb.breakpoints():" "" \ + " if b.type == gdb.BP_CATCHPOINT:" "" \ + " print(\"breakpoint #%d, type BP_CATCHPOINT\" % b.number)" "" \ + "end" "" + gdb_test "python scan_bp_list ()" \ + "breakpoint #${num}, type BP_CATCHPOINT" \ + "scan breakpoint for BP_CATCHPOINT" + + # Arrange to print something when GDB stops, then continue to the + # catchpoint and check we get the expected event. + gdb_test_multiline "setup stop event handler" \ + "python" "" \ + "def stop_handler (event):" "" \ + " if (isinstance (event, gdb.BreakpointEvent)" "" \ + " and isinstance (event.breakpoint, gdb.Breakpoint)" "" \ + " and event.breakpoint.type == gdb.BP_CATCHPOINT):" "" \ + " print (\"Stopped at catchpoint event: %d\" % event.breakpoint.number)" "" \ + "end" "" \ + "python gdb.events.stop.connect (stop_handler)" "" + gdb_test "continue" "Stopped at catchpoint event: ${num}" +} + test_bkpt_basic test_bkpt_deletion test_bkpt_cond_and_cmds test_bkpt_invisible test_hardware_breakpoints +test_catchpoints test_watchpoints test_bkpt_internal test_bkpt_eval_funcs |