1# This testcase is part of GDB, the GNU debugger. 2# 3# Copyright 2017-2019 Free Software Foundation, Inc. 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 3 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18# Test that Ctrl-C works after reconnecting. 19 20load_lib gdbserver-support.exp 21 22if { [skip_gdbserver_tests] } { 23 verbose "skipping gdbserver tests" 24 return -1 25} 26 27standard_testfile 28if [prepare_for_testing "failed to prepare" $testfile $srcfile] { 29 return -1 30} 31 32# Make sure we're disconnected, in case we're testing with an 33# extended-remote board, therefore already connected. 34with_test_prefix "preparation" { 35 gdb_test "disconnect" ".*" 36} 37 38# Connect, continue, send Ctrl-C and expect a SIGINT stop. 39 40proc connect_continue_ctrl_c {} { 41 global gdbserver_protocol gdbserver_gdbport 42 43 set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] 44 if ![gdb_assert {$res == 0} "connect"] { 45 return 46 } 47 48 set test "continue for ctrl-c" 49 gdb_test_multiple "continue" $test { 50 -re "Continuing" { 51 pass $test 52 } 53 } 54 55 after 1000 {send_gdb "\003"} 56 gdb_test "" "Program received signal SIGINT.*" "stop with control-c" 57} 58 59with_test_prefix "first" { 60 # Start GDBserver. 61 set gdbserver_reconnect_p 1 62 set res [gdbserver_start "" $binfile] 63 set gdbserver_protocol [lindex $res 0] 64 set gdbserver_gdbport [lindex $res 1] 65 66 connect_continue_ctrl_c 67} 68 69with_test_prefix "second" { 70 gdb_test "disconnect" "Ending remote debugging." 71 connect_continue_ctrl_c 72} 73