1 # Copyright 2009-2019 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} {
40 global record_instruction_kfail
42 set this_sig_supported $sig_supported
43 gdb_test "handle SIG$thissig stop print" \
44 "SIG$thissig\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
45 gdb_test "b handle_$thissig" "Breakpoint \[0-9\]+ .*"
46 gdb_test "b gen_$nextsig" "Breakpoint \[0-9\]+ .*"
48 set need_another_continue 1
50 if $this_sig_supported then {
51 if { $thissig == "IO" } {
52 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
54 gdb_test_multiple "continue" "get signal $thissig" {
56 "Program received signal SIG$thissig.*handle_$thissig.*" {
57 fail "$gdb_test_name (wrong location)"
59 -wrap -re "Program received signal SIG$thissig.*" {
62 -wrap -re "Breakpoint.* handle_$thissig.*" {
64 set need_another_continue 0
67 "Process record does not support instruction 0xfae64 at.*" {
68 kfail "gdb/25038" $gdb_test_name
69 set record_instruction_kfail 1
75 if $need_another_continue then {
76 if { $thissig == "URG" } {
77 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
79 # Either Lynx or GDB screws up on SIGPRIO
80 if { $thissig == "PRIO" } {
81 setup_xfail "*-*-*lynx*"
83 set testmsg "send signal $thissig"
84 gdb_test_multiple "continue" $testmsg {
85 -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" {
88 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
89 fail "missed breakpoint at handle_$thissig"
95 if { $missed_handler == "0" } then {
96 set testmsg "advance to $nextsig"
97 gdb_test_multiple "signal 0" $testmsg {
98 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
102 -re "Breakpoint.*gen_$nextsig.*handle.*$gdb_prompt $" {
111 proc test_one_sig_reverse {prevsig} {
114 gdb_test "reverse-continue" "Breakpoint .* handle_$prevsig.*" \
115 "reverse to handler of $prevsig"
118 set testmsg "reverse to gen_$prevsig"
119 gdb_test_multiple "reverse-continue" $testmsg {
120 -re "Breakpoint.*handle_.*$gdb_prompt " {
121 pass "$testmsg (un-handled)"
123 -re "Program received signal SIG$prevsig.*$gdb_prompt " {
124 pass "reverse to signal event, $prevsig"
126 set nested_testmsg "reverse signal $prevsig delivered"
127 gdb_test_multiple "frame" $nested_testmsg {
128 -re ".*handle_$prevsig.*$gdb_prompt " {
129 fail "$nested_testmsg (wrong location)"
131 -re ".*$gdb_prompt " {
137 send_gdb "reverse-continue\n"
140 -re "Breakpoint.*kill.*$gdb_prompt " {
141 if { $saw_signal } then {
142 pass "$testmsg (handled)"
144 xfail "$testmsg (handled)"
147 -re "No more reverse-execution history.*kill.*$gdb_prompt " {
148 if { $saw_signal } then {
149 pass "$testmsg (handled)"
151 xfail "$testmsg (handled)"
161 if [supports_process_record] {
162 # Activate process record/replay
163 gdb_test_no_output "record" "turn on process record"
166 # The list of signals that the program generates, in the order they
242 # Make the first signal SIGABRT because it is always supported.
246 # test signal handling
247 with_test_prefix "sig-test-1" {
248 set record_instruction_kfail 0
249 foreach sig [lrange $signals 1 end] {
251 if { $record_instruction_kfail } {
257 # The last signal (SIGTERM) gets handled slightly differently because
258 # we are not setting up for another test.
259 gdb_test "handle SIGTERM stop print" \
260 "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
261 gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*"
262 gdb_test "continue" \
263 "Continuing.*Program received signal SIGTERM.*" \
265 gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
267 with_timeout_factor 2 {
268 gdb_test "continue" "\[process \[0-9\]+ .*" "continue to signal exit" \
269 "The next instruction is syscall exit_group.* program...y. or n. " \
273 foreach sig [lreverse $signals] {
274 test_one_sig_reverse $sig
277 # Make the first signal SIGABRT because it is always supported.
281 with_test_prefix "sig-test-2" {
282 foreach sig [lrange $signals 1 end] {