1 # Copyright 2009-2013 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 if [target_info exists gdb,nosignals] {
17 verbose "Skipping sigall-reverse.exp because of nosignals."
21 if ![supports_reverse] {
28 gdb_reinitialize_dir $srcdir/$subdir
32 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
36 proc test_one_sig {nextsig} {
41 set this_sig_supported $sig_supported
42 gdb_test "handle SIG$thissig stop print" \
43 "SIG$thissig\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
44 gdb_test "b handle_$thissig" "Breakpoint \[0-9\]+ .*"
45 gdb_test "b gen_$nextsig" "Breakpoint \[0-9\]+ .*"
47 set need_another_continue 1
49 if $this_sig_supported then {
50 if { $thissig == "IO" } {
51 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
53 set testmsg "get signal $thissig"
54 gdb_test_multiple "continue" $testmsg {
55 -re "Program received signal SIG$thissig.*handle_$thissig.*$gdb_prompt $" {
56 fail "$testmsg (wrong location)"
58 -re "Program received signal SIG$thissig.*$gdb_prompt $" {
61 -re "Breakpoint.* handle_$thissig.*$gdb_prompt $" {
63 set need_another_continue 0
67 if [ istarget "alpha-dec-osf3*" ] then {
68 # OSF/1-3.x is unable to continue with a job control stop signal.
69 # The inferior remains stopped without an event of interest
70 # and GDB waits forever for the inferior to stop on an event
71 # of interest. Work around the kernel bug.
72 if { $thissig == "TSTP" || $thissig == "TTIN" || $thissig == "TTOU" } {
73 setup_xfail "alpha-dec-osf3*"
74 fail "cannot continue from signal $thissig"
75 set need_another_continue 0
79 if $need_another_continue then {
80 if { $thissig == "URG" } {
81 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
83 # Either Lynx or GDB screws up on SIGPRIO
84 if { $thissig == "PRIO" } {
85 setup_xfail "*-*-*lynx*"
87 set testmsg "send signal $thissig"
88 gdb_test_multiple "continue" $testmsg {
89 -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" {
92 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
93 fail "missed breakpoint at handle_$thissig"
99 if { $missed_handler == "0" } then {
100 set testmsg "advance to $nextsig"
101 gdb_test_multiple "signal 0" $testmsg {
102 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
106 -re "Breakpoint.*gen_$nextsig.*handle.*$gdb_prompt $" {
115 proc test_one_sig_reverse {prevsig} {
118 gdb_test "reverse-continue" "Breakpoint .* handle_$prevsig.*" \
119 "reverse to handler of $prevsig"
122 set testmsg "reverse to gen_$prevsig"
123 gdb_test_multiple "reverse-continue" $testmsg {
124 -re "Breakpoint.*handle_.*$gdb_prompt " {
125 pass "$testmsg (un-handled)"
127 -re "Program received signal SIG$prevsig.*$gdb_prompt " {
128 pass "reverse to signal event, $prevsig"
130 set nested_testmsg "reverse signal delivered"
131 gdb_test_multiple "frame" $nested_testmsg {
132 -re ".*handle_$prevsig.*$gdb_prompt " {
133 fail "$nested_testmsg (wrong location)"
135 -re ".*$gdb_prompt " {
141 send_gdb "reverse-continue\n"
144 -re "Breakpoint.*kill.*$gdb_prompt " {
145 if { $saw_signal } then {
146 pass "$testmsg (handled)"
148 xfail "$testmsg (handled)"
151 -re "No more reverse-execution history.*kill.*$gdb_prompt " {
152 if { $saw_signal } then {
153 pass "$testmsg (handled)"
155 xfail "$testmsg (handled)"
165 if [supports_process_record] {
166 # Activate process record/replay
167 gdb_test_no_output "record" "Turn on process record"
170 # The list of signals that the program generates, in the order they
246 # Make the first signal SIGABRT because it is always supported.
250 # test signal handling
251 foreach sig [lrange $signals 1 end] {
255 # The last signal (SIGTERM) gets handled slightly differently because
256 # we are not setting up for another test.
257 gdb_test "handle SIGTERM stop print" \
258 "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
259 gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*"
260 gdb_test "continue" \
261 "Continuing.*Program received signal SIGTERM.*" \
263 gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
265 gdb_test "continue" "\[process \[0-9\]+ .*" "continue to sigal exit" \
266 "The next instruction is syscall exit_group.* program...y. or n. " \
269 foreach sig [lreverse $signals] {
270 test_one_sig_reverse $sig
273 # Make the first signal SIGABRT because it is always supported.
277 foreach sig [lrange $signals 1 end] {