1 # Copyright 2012 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 catch-signal.exp because of nosignals."
23 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
27 proc test_catch_signal {signame} {
30 with_test_prefix $signame {
35 # Test "catch signal" without arguments.
36 # Don't let the signal be handled otherwise.
37 gdb_breakpoint ${srcfile}:[gdb_get_line_number "first HUP"]
38 gdb_continue_to_breakpoint "first HUP"
39 gdb_test "handle SIGHUP nostop noprint pass" \
40 "SIGHUP.*No.*No.*Yes.*"
41 gdb_test "catch signal" "Catchpoint .*"
42 gdb_test "continue" "Catchpoint .*"
44 # Now ensure that the "pass" setting worked, and also that we did not
46 gdb_breakpoint ${srcfile}:[gdb_get_line_number "handle marker"]
47 gdb_continue_to_breakpoint "handle marker"
51 # Catch just $SIGNAME.
52 gdb_breakpoint ${srcfile}:[gdb_get_line_number "second HUP"]
53 gdb_continue_to_breakpoint "second HUP"
54 gdb_test "catch signal $signame" "Catchpoint .*"
55 gdb_test "continue" "Catchpoint .*"
58 # Catch just SIGUSR1 -- but it isn't sent.
59 gdb_breakpoint ${srcfile}:[gdb_get_line_number "third HUP"]
60 gdb_continue_to_breakpoint "third HUP"
61 gdb_test "handle SIGUSR1 nostop noprint pass" \
62 "SIGUSR1.*No.*No.*Yes.*"
63 gdb_test "catch signal SIGUSR1" "Catchpoint .*"
65 # Also verify that if we set SIGHUP to "nopass", then it is
66 # still not delivered.
67 gdb_breakpoint ${srcfile}:[gdb_get_line_number "handle marker"]
68 gdb_test "handle SIGHUP nostop noprint nopass" \
69 "SIGHUP.*No.*No.*No.*"
71 gdb_breakpoint ${srcfile}:[gdb_get_line_number "fourth HUP"]
72 gdb_continue_to_breakpoint "fourth HUP"
77 # Test with symbolic signal.
78 test_catch_signal SIGHUP
80 # Test with numeric signal.
81 clean_restart $testfile
84 # Test with two signals in catchpoint.
85 clean_restart $testfile
86 test_catch_signal "SIGHUP SIGUSR2"
92 gdb_test "catch signal SIGZARDOZ" "Unknown signal name 'SIGZARDOZ'."
93 gdb_test "catch signal all" "Catchpoint .*"
94 gdb_test "catch signal all SIGHUP" "'all' cannot be caught with other signals"
95 gdb_test "catch signal SIGHUP all" "'all' cannot be caught with other signals"
98 foreach {arg desc} {"" "standard signals" \
100 "SIGHUP SIGUSR2" "SIGHUP SIGUSR2" \
103 gdb_test "catch signal $arg" "Catchpoint .*" \
104 "set catchpoint '$arg' for printing"
105 gdb_test "info break" "$decimal.*catchpoint.*signal.*$desc.*" \
106 "info break for '$arg'"
107 gdb_test "save breakpoints [standard_output_file bps.$i]" \
108 "Saved to file .*bps.$i.*" \
109 "save breakpoints for '$arg'"
111 set filename [remote_upload host [standard_output_file bps.$i] \
112 [standard_output_file bps-local.$i]]
113 set fd [open $filename]
114 set contents [read -nonewline $fd]
118 set pattern "catch signal"
120 set pattern "catch signal $arg"
122 if {[string match $pattern $contents]} {
123 pass "results of save breakpoints for '$arg'"
125 fail "results of save breakpoints for '$arg'"