1 # Copyright
(C
) 2014-2024 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this
program.
If not
, see
<http
://www.gnu.org
/licenses
/>.
16 # Test that repeating a background command doesn
't lose the "&" in the
17 # repeat, turning a background command into a foreground command. See
22 if { [build_executable "failed to prepare" ${testfile} $srcfile] } {
26 set linenum [gdb_get_line_number "set break here"]
28 # Run the test proper. CONTINUE_CMD is the background continue
31 proc test {continue_cmd} {
36 clean_restart $binfile
42 gdb_breakpoint "$linenum"
44 # If the breakpoint triggers soon enough we see further output after the
45 # prompt, so no prompt anchor.
46 gdb_test -no-prompt-anchor $continue_cmd [string_to_regexp "Continuing."]
48 # Wait for the stop. Don't expect a prompt
, as we had resumed the
49 # inferior in the background.
50 set test
"breakpoint hit 1"
51 gdb_test_multiple
"" $test {
52 -re
"set break here" {
57 # Trigger a repeat. Buggy GDB used to lose the
"&", making this a
58 # foreground command...
60 gdb_test
"" "Continuing\\." "repeat bg command"
62 # ... and thus further input wouldn
't be processed until the target
64 gdb_test "print 1" " = 1" "input still accepted"
66 # With gdbserver, we cannot set memory while the inferior is running, so
67 # enable the "set var" command with an interrupt / continue& pair.
68 gdb_test -no-prompt-anchor "interrupt"
70 # Allow the breakpoint to trigger.
71 gdb_test -no-prompt-anchor "set var do_wait=0"
73 gdb_test -no-prompt-anchor "continue&"
75 # Make sure we see a stop after the print, and not before. Don't
76 # expect a prompt
, as we had resumed the inferior in the background.
77 set test
"breakpoint hit 2"
78 gdb_test_multiple
"" $test {
79 -re
"set break here ..\r\n" {
85 # Test with and without extra arguments.
86 foreach cmd
{"c&" "c 1&"} {
87 with_test_prefix $cmd
{