1 # Copyright 2009-2024 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 require {!target_info exists gdb,nosignals}
18 require supports_reverse
22 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
26 proc test_one_sig {nextsig} {
30 global record_instruction_kfail
32 set this_sig_supported $sig_supported
33 gdb_test "handle SIG$thissig stop print" \
34 "SIG$thissig\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
35 gdb_test "b handle_$thissig" "Breakpoint \[0-9\]+ .*"
36 gdb_test "b gen_$nextsig" "Breakpoint \[0-9\]+ .*"
38 set need_another_continue 1
40 if {$this_sig_supported} {
41 if { $thissig == "IO" } {
42 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
44 gdb_test_multiple "continue" "get signal $thissig" {
46 "Program received signal SIG$thissig.*handle_$thissig.*" {
47 fail "$gdb_test_name (wrong location)"
49 -wrap -re "Program received signal SIG$thissig.*" {
52 -wrap -re "Breakpoint.* handle_$thissig.*" {
54 set need_another_continue 0
57 "Process record does not support instruction 0xfae64 at.*" {
58 kfail "gdb/25038" $gdb_test_name
59 set record_instruction_kfail 1
65 if {$need_another_continue} {
66 if { $thissig == "URG" } {
67 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
69 # Either Lynx or GDB screws up on SIGPRIO
70 if { $thissig == "PRIO" } {
71 setup_xfail "*-*-*lynx*"
73 set testmsg "send signal $thissig"
74 gdb_test_multiple "continue" $testmsg {
75 -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" {
78 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
79 fail "missed breakpoint at handle_$thissig"
85 if {$missed_handler == "0"} {
86 set testmsg "advance to $nextsig"
87 gdb_test_multiple "signal 0" $testmsg {
88 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
92 -re "Breakpoint.*gen_$nextsig.*handle.*$gdb_prompt $" {
101 proc test_one_sig_reverse {prevsig} {
104 gdb_test "reverse-continue" "Breakpoint .* handle_$prevsig.*" \
105 "reverse to handler of $prevsig"
108 set testmsg "reverse to gen_$prevsig"
109 gdb_test_multiple "reverse-continue" $testmsg {
110 -re "Breakpoint.*handle_.*$gdb_prompt " {
111 pass "$testmsg (un-handled)"
113 -re "Program received signal SIG$prevsig.*$gdb_prompt " {
114 pass "reverse to signal event, $prevsig"
116 set nested_testmsg "reverse signal $prevsig delivered"
117 gdb_test_multiple "frame" $nested_testmsg {
118 -re ".*handle_$prevsig.*$gdb_prompt " {
119 fail "$nested_testmsg (wrong location)"
121 -re ".*$gdb_prompt " {
127 send_gdb "reverse-continue\n"
130 -re "Breakpoint.*kill.*$gdb_prompt " {
132 pass "$testmsg (handled)"
134 xfail "$testmsg (handled)"
137 -re "No more reverse-execution history.*kill.*$gdb_prompt " {
139 pass "$testmsg (handled)"
141 xfail "$testmsg (handled)"
147 clean_restart $binfile
151 if [supports_process_record] {
152 # Activate process record/replay
153 gdb_test_no_output "record" "turn on process record"
156 # The list of signals that the program generates, in the order they
232 # Make the first signal SIGABRT because it is always supported.
236 # test signal handling
237 with_test_prefix "sig-test-1" {
238 set record_instruction_kfail 0
239 foreach sig [lrange $signals 1 end] {
241 if { $record_instruction_kfail } {
247 # The last signal (SIGTERM) gets handled slightly differently because
248 # we are not setting up for another test.
249 gdb_test "handle SIGTERM stop print" \
250 "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
251 gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*"
252 gdb_test "continue" \
253 "Continuing.*Program received signal SIGTERM.*" \
255 gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
257 with_timeout_factor 2 {
258 gdb_test "continue" "\[process \[0-9\]+ .*" "continue to signal exit" \
259 "The next instruction is syscall exit_group.* program...y. or n. " \
263 foreach sig [lreverse $signals] {
264 test_one_sig_reverse $sig
267 # Make the first signal SIGABRT because it is always supported.
271 with_test_prefix "sig-test-2" {
272 foreach sig [lrange $signals 1 end] {