From 581dd502f6898ba38373c2ff302b840b3edfed79 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 11 Jun 2025 23:35:57 +0100 Subject: [PATCH] New gdb.base/continue-break-command.exp testcase Change-Id: Ie57493bb5032f28619db418d9d8068aae2d40b09 --- .../gdb.base/continue-break-command.c | 42 +++++++++++ .../gdb.base/continue-break-command.exp | 75 +++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 gdb/testsuite/gdb.base/continue-break-command.c create mode 100644 gdb/testsuite/gdb.base/continue-break-command.exp diff --git a/gdb/testsuite/gdb.base/continue-break-command.c b/gdb/testsuite/gdb.base/continue-break-command.c new file mode 100644 index 00000000000..585476aa838 --- /dev/null +++ b/gdb/testsuite/gdb.base/continue-break-command.c @@ -0,0 +1,42 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2025 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +static void +foo () +{ +} + +static void +bar () +{ +} + +int +main (void) +{ + /* The testcase sets breakpoints on these two, that when hit, are + removed by their corresponding breakpoint command. */ + foo (); + bar (); + + /* Call them again to make sure the breakpoints are really + deleted. */ + foo (); + bar (); + + return 0; +} diff --git a/gdb/testsuite/gdb.base/continue-break-command.exp b/gdb/testsuite/gdb.base/continue-break-command.exp new file mode 100644 index 00000000000..6d77d282d78 --- /dev/null +++ b/gdb/testsuite/gdb.base/continue-break-command.exp @@ -0,0 +1,75 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# XXX, some meaninful explanation here. + +standard_testfile .c + +if { [build_executable "failed to prepare" $testfile $srcfile {debug}] \ + == -1 } { + return +} + +proc test {} { + clean_restart $::binfile + + if ![runto_main] { + return + } + + # Disable "[Thread 14192.0x3618 exited with code 0]" messages. + gdb_test_no_output "set print thread-events off" + + gdb_breakpoint "foo" message + gdb_test_multiple "commands" "command for foo" { + -re "End with" { + gdb_test \ + [multi_line_input \ + {silent} \ + {printf "Breakpoint hit #1.\n"} \ + {clear foo} \ + {continue} \ + {end}] \ + "" \ + $gdb_test_name + } + } + + gdb_breakpoint "bar" message + gdb_test_multiple "commands" "commands for bar" { + -re "End with" { + gdb_test \ + [multi_line_input \ + {silent} \ + {printf "Breakpoint hit #2.\n"} \ + {clear bar} \ + {continue} \ + {end}] \ + "" \ + $gdb_test_name + } + } + + gdb_test "info breakpoints" ".*" + + gdb_test_sequence "continue" "" \ + [list \ + "Continuing\\." \ + "^\r\nBreakpoint hit #1\\." \ + "^\r\nBreakpoint hit #2\\." \ + "^\r\n$::inferior_exited_re normally"] +} + +test base-commit: eb6c9310ee4d6cbde509d251fafb54ae45f5a5bf -- 2.49.0