[PATCH 5/57][Arm][GAS] Add support for MVE instructions: vmull{b,t}
[binutils-gdb.git] / gdb / testsuite / gdb.base / catch-signal.exp
blobcb94d32ee41612026f2c1f1779cce99094af4025
1 # Copyright 2012-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 catch-signal.exp because of nosignals."
18     continue
21 standard_testfile
23 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
24     return -1
27 proc test_catch_signal {signame} {
28     global srcfile
30     with_test_prefix $signame {
31         if {![runto_main]} {
32             return -1
33         }
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
45         # see gdb's SIGTRAP.
46         gdb_breakpoint ${srcfile}:[gdb_get_line_number "handle marker"]
47         gdb_continue_to_breakpoint "handle marker"
49         delete_breakpoints
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 .*"
56         delete_breakpoints
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"
73         delete_breakpoints
75         # Verify an internal signal used by gdb is properly caught.
76         gdb_breakpoint ${srcfile}:[gdb_get_line_number "first INT"]
77         gdb_continue_to_breakpoint "first INT"
78         set test "override SIGINT to catch"
79         gdb_test "handle SIGINT nostop print nopass" \
80             "SIGINT.*No.*Yes.*No.*" \
81             "$test" \
82             "SIGINT is used by the debugger.*Are you sure you want to change it.*y or n.*" \
83             y
84         gdb_test "catch signal SIGINT" "Catchpoint .*"
85         gdb_test "continue" "Catchpoint .* SIGINT.*"
86         
87     }
90 # Test with symbolic signal.
91 test_catch_signal SIGHUP
93 # Test with numeric signal.
94 clean_restart $testfile
95 test_catch_signal 1
97 # Test with two signals in catchpoint.
98 clean_restart $testfile
99 test_catch_signal "SIGHUP SIGUSR2"
102 # Coverage tests.
105 gdb_test "catch signal SIGZARDOZ" "Unknown signal name 'SIGZARDOZ'."
106 gdb_test "catch signal all" "Catchpoint .*"
107 gdb_test "catch signal all SIGHUP" "'all' cannot be caught with other signals"
108 gdb_test "catch signal SIGHUP all" "'all' cannot be caught with other signals"
110 set i 0
111 foreach {arg desc} {"" "standard signals" \
112                         SIGHUP SIGHUP \
113                         "SIGHUP SIGUSR2" "SIGHUP SIGUSR2" \
114                         all "any signal"} {
115     delete_breakpoints
116     gdb_test "catch signal $arg" "Catchpoint .*" \
117         "set catchpoint '$arg' for printing"
118     gdb_test "info break" "$decimal.*catchpoint.*signal.*$desc.*" \
119         "info break for '$arg'"
120     gdb_breakpoint "main"
121     gdb_test "save breakpoints [standard_output_file bps.$i]" \
122         "Saved to file .*bps.$i.*" \
123         "save breakpoints for '$arg'"
125     set filename [remote_upload host [standard_output_file bps.$i] \
126                       [standard_output_file bps-local.$i]]
127     set fd [open $filename]
128     set file_data [read $fd]
129     set data [split $file_data "\n"]
130     close $fd
132     if {$arg == ""} {
133         set pattern "catch signal"
134     } else {
135         set pattern "catch signal $arg"
136     }
137     gdb_assert {[expr [llength $data] == 3]} \
138         "Number of lines of save breakpoints for '$arg'"
139     # Check the first line.
140     gdb_assert {[string match $pattern [lindex $data 0]]} \
141         "1st line of save breakpoints for '$arg'"
142     # Check the second line.
143     gdb_assert {[string match "break main" [lindex $data 1]]} \
144         "2nd line of save breakpoints for '$arg'"
145     # Check the trailing newline.
146     gdb_assert {[string match "" [lindex $data 2]]} \
147         "Trailing newline of save breakpoints for '$arg'"
149     incr i