OSDN Git Service

Update copyright year in most headers.
[pf3gnuchains/pf3gnuchains3x.git] / gdb / testsuite / gdb.base / sigall.exp
1 #   Copyright 1995, 1996, 1997, 1999, 2007, 2008, 2009, 2010
2 #   Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 if [target_info exists gdb,nosignals] {
18     verbose "Skipping sigall.exp because of nosignals."
19     continue
20 }
21
22 if $tracelevel then {
23         strace $tracelevel
24 }
25
26 set prms_id 0
27 set bug_id 0
28
29 gdb_exit
30 gdb_start
31 gdb_reinitialize_dir $srcdir/$subdir
32
33 set testfile sigall
34 set srcfile ${testfile}.c
35 set binfile ${objdir}/${subdir}/${testfile}
36 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37      untested sigall.exp
38      return -1
39 }
40
41 # Make the first signal SIGABRT because it is always supported.
42 set sig_supported 1
43 set thissig "ABRT"
44
45 proc test_one_sig {nextsig} {
46     global sig_supported
47     global gdb_prompt
48     global thissig
49
50     set this_sig_supported $sig_supported
51     gdb_test "handle SIG$thissig stop print" \
52         "SIG$thissig\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
53     gdb_test "b handle_$thissig" "Breakpoint \[0-9\]+ .*"
54     gdb_test "b gen_$nextsig" "Breakpoint \[0-9\]+ .*"
55
56     set need_another_continue 1
57     set missed_handler 0
58     if $this_sig_supported then {
59         send_gdb "continue\n"
60         if { $thissig == "IO" } {
61             setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
62         }
63         gdb_expect {
64             -re "Continuing.*Program received signal SIG$thissig.*$gdb_prompt $" {
65                 pass "get signal $thissig"
66             }
67             -re ".*$gdb_prompt $" {
68                 fail "get signal $thissig"
69                 set need_another_continue 0
70             }
71             default {
72                 fail "get signal $thissig (eof or timeout)"
73             }
74         }
75     }
76     if [ istarget "alpha-dec-osf3*" ] then {
77         # OSF/1-3.x is unable to continue with a job control stop signal.
78         # The inferior remains stopped without an event of interest
79         # and GDB waits forever for the inferior to stop on an event
80         # of interest. Work around the kernel bug.
81         if { $thissig == "TSTP" || $thissig == "TTIN" || $thissig == "TTOU" } {
82             setup_xfail "alpha-dec-osf3*"
83             fail "cannot continue from signal $thissig"
84             set need_another_continue 0
85         }
86     }
87
88     if $need_another_continue then {
89         send_gdb "continue\n"
90         if { $thissig == "URG" } {
91             setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
92         }
93         # Either Lynx or GDB screws up on SIGPRIO
94         if { $thissig == "PRIO" } {
95             setup_xfail "*-*-*lynx*"
96         }
97         gdb_expect {
98             -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" {
99                 pass "send signal $thissig"
100             }
101             -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
102                 fail "missed breakpoint at handle_$thissig"
103                 set missed_handler 1
104             }
105         }
106     }
107
108     if { $missed_handler == "0" } then {
109         send_gdb "signal 0\n"
110         gdb_expect {
111             -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
112                 pass "advance to $nextsig"
113                 set sig_supported 1
114             }
115             -re "Breakpoint.*gen_$nextsig.*handle.*$gdb_prompt $" {
116                 pass "advance to $nextsig"
117                 set sig_supported 0
118             }
119             -re ".*$gdb_prompt $" { fail "advance to $nextsig" }
120             default { fail "advance to $nextsig (eof or timeout)" }
121         }
122     }
123     set thissig $nextsig
124 }
125
126 gdb_load $binfile
127
128 runto gen_ABRT
129 test_one_sig HUP
130 test_one_sig QUIT
131 test_one_sig ILL
132 test_one_sig EMT
133 test_one_sig FPE
134 test_one_sig BUS
135 test_one_sig SEGV
136 test_one_sig SYS
137 test_one_sig PIPE
138 test_one_sig ALRM
139 test_one_sig URG
140 test_one_sig TSTP
141 test_one_sig CONT
142 test_one_sig CHLD
143 test_one_sig TTIN
144 test_one_sig TTOU
145 test_one_sig IO
146 test_one_sig XCPU
147 test_one_sig XFSZ
148 test_one_sig VTALRM
149 test_one_sig PROF
150 test_one_sig WINCH
151 test_one_sig LOST
152 test_one_sig USR1
153 test_one_sig USR2
154 test_one_sig PWR
155 test_one_sig POLL
156 test_one_sig WIND
157 test_one_sig PHONE
158 test_one_sig WAITING
159 test_one_sig LWP
160 test_one_sig DANGER
161 test_one_sig GRANT
162 test_one_sig RETRACT
163 test_one_sig MSG
164 test_one_sig SOUND
165 test_one_sig SAK
166 test_one_sig PRIO
167 test_one_sig 33
168 test_one_sig 34
169 test_one_sig 35
170 test_one_sig 36
171 test_one_sig 37
172 test_one_sig 38
173 test_one_sig 39
174 test_one_sig 40
175 test_one_sig 41
176 test_one_sig 42
177 test_one_sig 43
178 test_one_sig 44
179 test_one_sig 45
180 test_one_sig 46
181 test_one_sig 47
182 test_one_sig 48
183 test_one_sig 49
184 test_one_sig 50
185 test_one_sig 51
186 test_one_sig 52
187 test_one_sig 53
188 test_one_sig 54
189 test_one_sig 55
190 test_one_sig 56
191 test_one_sig 57
192 test_one_sig 58
193 test_one_sig 59
194 test_one_sig 60
195 test_one_sig 61
196 test_one_sig 62
197 test_one_sig 63
198 test_one_sig TERM
199
200 # The last signal (SIGTERM) gets handled slightly differently because
201 # we are not setting up for another test.
202 gdb_test "handle SIGTERM stop print" \
203     "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
204 gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*"
205 gdb_test "continue" \
206     "Continuing.*Program received signal SIGTERM.*" \
207     "get signal TERM"
208 gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
209 gdb_continue_to_end "continue to sigall exit"
210
211 return 0