1 # Copyright 1995-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}
20 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
24 proc test_one_sig {nextsig} {
29 set this_sig_supported $sig_supported
30 gdb_test "handle SIG$thissig stop print" \
31 "SIG$thissig\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
32 gdb_test "b handle_$thissig" "Breakpoint \[0-9\]+ .*"
33 gdb_test "b gen_$nextsig" "Breakpoint \[0-9\]+ .*"
35 set need_another_continue 1
37 if {$this_sig_supported} {
40 if { $thissig == "IO" } {
41 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
43 # On Linux SPARC64 systems SIGLOST==SIGPWR and gdb identifies
44 # the raised signal as PWR.
45 if {$thissig == "LOST" && [istarget "sparc64-*-linux*"]} {
50 "Continuing.*Program received signal SIG$esig.*" \
54 if {$need_another_continue} {
55 if { $thissig == "URG" } {
56 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
58 # Either Lynx or GDB screws up on SIGPRIO
59 if { $thissig == "PRIO" } {
60 setup_xfail "*-*-*lynx*"
62 gdb_test_multiple "continue" "send signal $thissig" {
63 -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" {
64 pass "send signal $thissig"
66 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
67 fail "missed breakpoint at handle_$thissig"
73 if {$missed_handler == "0"} {
74 gdb_test_multiple "signal 0" "advance to $nextsig" {
75 -re "Breakpoint.*gen_$nextsig.*\r\n\[0-9\]+\[ \t\]+kill \\(.*\r\n$gdb_prompt $" {
76 pass "advance to $nextsig"
79 -re "Breakpoint.*gen_$nextsig.*\r\n\[0-9\]+\[ \t\]+handle_.*\r\n$gdb_prompt $" {
80 pass "advance to $nextsig"
88 # The list of signals that the program generates, in the order they
164 # Make the first signal SIGABRT because it is always supported.
170 foreach sig [lrange $signals 1 end] {
174 # The last signal (SIGTERM) gets handled slightly differently because
175 # we are not setting up for another test.
176 gdb_test "handle SIGTERM stop print" \
177 "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
178 gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*"
179 gdb_test "continue" \
180 "Continuing.*Program received signal SIGTERM.*" \
182 gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
183 gdb_continue_to_end "continue to sigall exit"