1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2017-2018 Free Software Foundation, Inc.
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.
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.
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/>.
18 # Test that Ctrl-C works after reconnecting.
20 load_lib gdbserver-support.exp
22 if { [skip_gdbserver_tests] } {
23 verbose "skipping gdbserver tests"
28 if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
32 # Make sure we're disconnected, in case we're testing with an
33 # extended-remote board, therefore already connected.
34 with_test_prefix "preparation" {
35 gdb_test "disconnect" ".*"
38 # Connect, continue, send Ctrl-C and expect a SIGINT stop.
40 proc connect_continue_ctrl_c {} {
41 global gdbserver_protocol gdbserver_gdbport
43 set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
44 if ![gdb_assert {$res == 0} "connect"] {
48 set test "continue for ctrl-c"
49 gdb_test_multiple "continue" $test {
55 after 1000 {send_gdb "\003"}
56 gdb_test "" "Program received signal SIGINT.*" "stop with control-c"
59 with_test_prefix "first" {
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]
66 connect_continue_ctrl_c
69 with_test_prefix "second" {
70 gdb_test "disconnect" "Ending remote debugging."
71 connect_continue_ctrl_c