1 # This testcase is part of GDB
, the GNU debugger.
3 # Copyright
2017-2022 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"
27 if [target_info
exists gdb
,nointerrupts
] {
28 verbose
"Skipping reconnect-ctrl-c.exp because of nointerrupts."
34 save_vars
{ GDBFLAGS
} {
35 #
If GDB and GDBserver are both running locally
, set the sysroot to avoid
36 # reading files via the remote protocol.
37 if { ![is_remote host
] && ![is_remote target
] } {
38 set GDBFLAGS
"$GDBFLAGS -ex \"set sysroot\""
41 if [prepare_for_testing
"failed to prepare" $testfile $srcfile] {
46 # Make sure we
're disconnected, in case we're testing with an
47 # extended
-remote board
, therefore already connected.
48 with_test_prefix
"preparation" {
49 gdb_test
"disconnect" ".*"
52 #
Connect, continue, send Ctrl
-C and expect a SIGINT stop.
54 proc connect_continue_ctrl_c
{} {
55 global gdbserver_protocol gdbserver_gdbport
57 set res
[gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
]
58 if ![gdb_assert
{$res
== 0} "connect"] {
62 set test
"continue for ctrl-c"
63 gdb_test_multiple
"continue" $test {
69 after
1000 {send_gdb
"\003"}
70 gdb_test
"" "Program received signal SIGINT.*" "stop with control-c"
73 with_test_prefix
"first" {
75 set gdbserver_reconnect_p
1
76 set res
[gdbserver_start
"" $binfile]
77 set gdbserver_protocol
[lindex $res
0]
78 set gdbserver_gdbport
[lindex $res
1]
80 connect_continue_ctrl_c
83 with_test_prefix
"second" {
84 gdb_test
"disconnect" "Ending remote debugging."
85 connect_continue_ctrl_c