bg-execution-repeat.exp revision 1.6
1# Copyright (C) 2014-2019 Free Software Foundation, Inc. 2 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. 7# 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. 12# 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/>. 15 16# Test that repeating a background command doesn't lose the "&" in the 17# repeat, turning a background command into a foreground command. See 18# PR gdb/17471. 19 20standard_testfile 21 22if { [build_executable "failed to prepare" ${testfile} $srcfile] } { 23 return -1 24} 25 26set linenum [gdb_get_line_number "set break here"] 27 28# Run the test proper. CONTINUE_CMD is the background continue 29# command to issue. 30 31proc test {continue_cmd} { 32 global gdb_prompt 33 global binfile 34 global linenum 35 36 clean_restart $binfile 37 38 if ![runto_main] { 39 return 40 } 41 42 gdb_breakpoint "$linenum" 43 44 set test $continue_cmd 45 gdb_test_multiple $test $test { 46 -re "Continuing\\.\r\n$gdb_prompt " { 47 # Note no end anchor. If the breakpoint triggers soon enough 48 # enough we see further output after the prompt. 49 pass $test 50 } 51 } 52 53 # Wait for the stop. Don't expect a prompt, as we had resumed the 54 # inferior in the background. 55 set test "breakpoint hit 1" 56 gdb_test_multiple "" $test { 57 -re "set break here" { 58 pass $test 59 } 60 } 61 62 # Trigger a repeat. Buggy GDB used to lose the "&", making this a 63 # foreground command... 64 send_gdb "\n" 65 gdb_test "" "Continuing\\." "repeat bg command" 66 67 # ... and thus further input wouldn't be processed until the target 68 # stopped. 69 gdb_test "print 1" " = 1" "input still accepted" 70 71 # Make sure we see a stop after the print, and not before. Don't 72 # expect a prompt, as we had resumed the inferior in the background. 73 set test "breakpoint hit 2" 74 gdb_test_multiple "" $test { 75 -re "set break here ..\r\n" { 76 pass $test 77 } 78 } 79} 80 81# Test with and without extra arguments. 82foreach cmd {"c&" "c 1&"} { 83 with_test_prefix $cmd { 84 test $cmd 85 } 86} 87