Update copyright year in most headers.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / interrupt.exp
CommitLineData
4c38e0a4 1# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2007, 2008, 2009, 2010
b6ba6518 2# Free Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
eecf4bed
JB
17if [target_info exists gdb,nointerrupts] {
18 verbose "Skipping interrupt.exp because of nointerrupts."
19 continue
c906108c
SS
20}
21
22if [target_info exists gdb,noinferiorio] {
23 verbose "Skipping interrupt.exp because of noinferiorio."
24 return
25}
26
27if $tracelevel then {
28 strace $tracelevel
29}
30
31set prms_id 0
32set bug_id 0
33
34set testfile interrupt
35set srcfile ${testfile}.c
36set binfile ${objdir}/${subdir}/${testfile}
a12cc160
DJ
37
38set options { debug }
39if { ! [target_info exists gdb,nosignals] } {
40 lappend options "additional_flags=-DSIGNALS"
41}
42
43if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $options] != "" } {
b60f0898
JB
44 untested interrupt.exp
45 return -1
c906108c
SS
46}
47
48gdb_start
49
50
51if ![file exists $binfile] then {
52 perror "$binfile does not exist."
53 return 0
54} else {
55 gdb_reinitialize_dir $srcdir/$subdir
56 gdb_load $binfile
57 # Hope this is unix :-)
58 gdb_test "shell stty intr '^C'" "" \
59 "set interrupt character in interrupt.exp"
60 if [runto_main] then {
61 send_gdb "continue\n"
62 gdb_expect {
63 -re "\r\ntalk to me baby\r\n$" {
64 pass "child process is alive"
65 }
66 timeout { fail "run (timeout)" }
67 eof { fail "run (eof)" }
68 }
69 # This should appear twice, once for the echo and once for the
70 # program's output. Under dejagnu (but not interactively) for
71 # SunOS4, it only appears once. Don't worry about it, I imagine
72 # dejagnu has just done something to the tty modes.
73 send_gdb "a\n"
74 gdb_expect {
75 -re "^a\r\n(|a\r\n)$" {
76 pass "child process ate our char"
77 }
78 timeout { fail "echo a (timeout)" }
79 eof { fail "echo a (eof)" }
80 }
81 # Wait until the program is in the read system call again.
82 sleep 2
83
84 # Cntrl-c may fail for simulator targets running on a BSD host.
85 # This is the result of a combination of the read syscall
86 # being restarted and gdb capturing the cntrl-c signal.
87
88 # Cntrl-c may fail for simulator targets on slow hosts.
89 # This is because there is a race condition between entering
90 # the read and delivering the cntrl-c.
91
92 send_gdb "\003"
93 gdb_expect {
94 -re "Program received signal SIGINT.*$gdb_prompt $" {
95 pass "send_gdb control C"
96 }
97 -re ".*$gdb_prompt $" { fail "send_gdb control C" }
98 timeout { fail "send_gdb control C (timeout)" }
99 eof { fail "send_gdb control C (eof)" }
100 }
101
102 send_gdb "p func1 ()\n"
103 gdb_expect {
104 -re " = 4.*$gdb_prompt $" { pass "call function when asleep" }
92b8ae91 105 -re ".*Program received signal SIG(SEGV|ILL).*$gdb_prompt $" {
c906108c
SS
106 setup_xfail "i*86-pc-linux*-gnu*"
107 fail "child died when we called func1, skipped rest of tests"
108 return
109 }
085dd6e6
JM
110 -re "$gdb_prompt $" {
111 # On HPUX-11.0 'send "p func1 ()"' above
112 # terminates the program. A defect is pending on this
113 # issue [defect #DTS CHFts24203]. Hence calling setup_xfail
114 # below.
a0b3c4fd 115 setup_xfail "hppa*-*-*11*" CHFts24203
085dd6e6
JM
116 fail "call function when asleep (wrong output)"
117 }
c906108c
SS
118 default {
119
120 # This fail probably happens whenever we use /proc (we
121 # don't use PRSABORT), but apparently also happens on
122 # other machines as well.
123
124 setup_xfail "sparc*-*-solaris2*"
125 setup_xfail "mips-*-ultrix*"
c906108c
SS
126 setup_xfail "i*86-*-solaris2*"
127 setup_xfail "*-*-sysv4*"
128 setup_xfail "vax-*-*"
129 setup_xfail "alpha-*-*"
8afa723e 130 setup_xfail "*-*-*bsd*"
c906108c
SS
131 setup_xfail "*-*-irix*"
132 setup_xfail "*-*-hpux*"
133 setup_xfail "*-*-*lynx*"
134 fail "call function when asleep (stays asleep)"
135 # Send_Gdb a newline to wake it up
136 send_gdb "\n"
137 gdb_test "" " = 4" "call function after waking it"
138 }
139# eof { fail "call function when asleep (eof)" }
140 }
141
142 # Now try calling the function again.
143 gdb_test "p func1 ()" " = 4" "call function a second time"
144
145 # And the program should still be doing the same thing.
146 # The optional trailing \r\n is in case we sent a newline above
147 # to wake the program, in which case the program now sends it
148 # back. We check for it either here or in the next gdb_expect
149 # command, because which one it ends up in is timing dependent.
150 send_gdb "continue\n"
151 # For some reason, i386-*-sysv4 gdb fails to issue the Continuing
152 # message, but otherwise appears normal (FIXME).
153 gdb_expect {
154 -re "^continue\r\nContinuing.\r\n(\r\n|)$" { pass "continue" }
155 -re "^continue\r\n\r\n" { fail "continue (missing Continuing.)" }
156 -re "$gdb_prompt $" { fail "continue" }
157 timeout { fail "continue (timeout)" }
158 eof { fail "continue (eof)" }
159 }
160
161 send_gdb "data\n"
162 # The optional leading \r\n is in case we sent a newline above
163 # to wake the program, in which case the program now sends it
164 # back.
085dd6e6
JM
165 # FIXME: The pattern below leads to an expected success on HPUX-11.0
166 # but the success is spurious. Need to provide the right reg.expr.
167 # here.
c906108c
SS
168 gdb_expect {
169 -re "^(\r\n|)data\r\n(|data\r\n)$" { pass "echo data" }
170 timeout { fail "echo data (timeout)" }
171 eof { fail "echo data (eof)" }
172 }
173
a12cc160
DJ
174 if { ! [target_info exists gdb,nosignals] } {
175 # Wait until the program is in the read system call again.
176 sleep 2
177
178 # Stop the program for another test.
179 set msg "Send Control-C, second time"
180 send_gdb "\003"
181 gdb_test_multiple "" "$msg" {
182 -re "Program received signal SIGINT.*$gdb_prompt $" {
183 pass "$msg"
184 }
185 }
186
187 # The "signal" command should deliver the correct signal and
188 # return to the loop.
189 set msg "signal SIGINT"
190 gdb_test_multiple "signal SIGINT" "$msg" {
191 -re "^signal SIGINT\r\nContinuing with signal SIGINT.\r\n(\r\n|)$" { pass "$msg" }
192 }
193
194 # We should be back in the loop.
195 send_gdb "more data\n"
196 gdb_expect {
197 -re "^(\r\n|)more data\r\n(|more data\r\n)$" { pass "echo more data" }
198 timeout { fail "echo more data (timeout)" }
199 eof { fail "echo more data (eof)" }
200 }
201 }
202
c906108c
SS
203 send_gdb "\004"
204 gdb_expect {
205 -re "end of file.*Program exited normally.*$gdb_prompt $" {
89cb06a2 206 pass "send end of file"
c906108c
SS
207 }
208 -re "$gdb_prompt $" { fail "send end of file" }
209 timeout { fail "send end of file (timeout)" }
210 eof { fail "send end of file (eof)" }
211 }
212 }
213}
214return 0
This page took 0.947321 seconds and 4 git commands to generate.