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