Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.server / reconnect-ctrl-c.exp
CommitLineData
e849ea89
PA
1# This testcase is part of GDB, the GNU debugger.
2#
88b9d363 3# Copyright 2017-2022 Free Software Foundation, Inc.
e849ea89
PA
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
2252ff3d
SL
27if [target_info exists gdb,nointerrupts] {
28 verbose "Skipping reconnect-ctrl-c.exp because of nointerrupts."
29 continue
30}
31
e849ea89 32standard_testfile
8dc558a0
SM
33
34save_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\""
39 }
40
41 if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
42 return -1
43 }
e849ea89
PA
44}
45
46# Make sure we're disconnected, in case we're testing with an
47# extended-remote board, therefore already connected.
48with_test_prefix "preparation" {
49 gdb_test "disconnect" ".*"
50}
51
52# Connect, continue, send Ctrl-C and expect a SIGINT stop.
53
54proc connect_continue_ctrl_c {} {
55 global gdbserver_protocol gdbserver_gdbport
56
57 set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
58 if ![gdb_assert {$res == 0} "connect"] {
59 return
60 }
61
62 set test "continue for ctrl-c"
63 gdb_test_multiple "continue" $test {
64 -re "Continuing" {
65 pass $test
66 }
67 }
68
69 after 1000 {send_gdb "\003"}
70 gdb_test "" "Program received signal SIGINT.*" "stop with control-c"
71}
72
73with_test_prefix "first" {
74 # Start GDBserver.
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]
79
80 connect_continue_ctrl_c
81}
82
83with_test_prefix "second" {
84 gdb_test "disconnect" "Ending remote debugging."
85 connect_continue_ctrl_c
86}
This page took 0.605034 seconds and 4 git commands to generate.