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-precsave.exp because of nosignals."
21 if ![supports_reverse] {
28 gdb_reinitialize_dir $srcdir/$subdir
30 standard_testfile sigall-reverse.c
31 set precsave [standard_output_file sigall.precsave]
33 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
37 proc test_one_sig {nextsig} {
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 set testmsg "get signal $thissig"
55 gdb_test_multiple "continue" $testmsg {
56 -re "Program received signal SIG$thissig.*handle_$thissig.*$gdb_prompt $" {
57 fail "$testmsg (wrong location)"
59 -re "Program received signal SIG$thissig.*$gdb_prompt $" {
62 -re "Breakpoint.* handle_$thissig.*$gdb_prompt $" {
64 set need_another_continue 0
69 if $need_another_continue then {
70 if { $thissig == "URG" } {
71 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
73 # Either Lynx or GDB screws up on SIGPRIO
74 if { $thissig == "PRIO" } {
75 setup_xfail "*-*-*lynx*"
77 set testmsg "send signal $thissig"
78 gdb_test_multiple "continue" $testmsg {
79 -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" {
82 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
83 fail "missed breakpoint at handle_$thissig"
89 if { $missed_handler == "0" } then {
90 set testmsg "advance to $nextsig"
91 gdb_test_multiple "signal 0" $testmsg {
92 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
96 -re "Breakpoint.*gen_$nextsig.*handle.*$gdb_prompt $" {
105 proc test_one_sig_reverse {prevsig} {
108 gdb_test "reverse-continue" "Breakpoint .* handle_$prevsig.*" \
109 "reverse to handler of $prevsig"
112 set testmsg "reverse to gen_$prevsig"
113 gdb_test_multiple "reverse-continue" $testmsg {
114 -re "Breakpoint.*handle_.*$gdb_prompt " {
115 pass "$testmsg (un-handled)"
117 -re "Program received signal SIG$prevsig.*$gdb_prompt " {
118 pass "reverse to signal event, $prevsig"
120 set nested_testmsg "reverse signal delivered"
121 gdb_test_multiple "frame" $nested_testmsg {
122 -re ".*handle_$prevsig.*$gdb_prompt " {
123 fail "$nested_testmsg (wrong location)"
125 -re ".*$gdb_prompt " {
131 send_gdb "reverse-continue\n"
134 -re "Breakpoint.*kill.*$gdb_prompt " {
135 if { $saw_signal } then {
136 pass "$testmsg (handled)"
138 xfail "$testmsg (handled)"
141 -re "No more reverse-execution history.*kill.*$gdb_prompt " {
142 if { $saw_signal } then {
143 pass "$testmsg (handled)"
145 xfail "$testmsg (handled)"
155 if [supports_process_record] {
156 # Activate process record/replay
157 gdb_test_no_output "record" "turn on process record"
160 # Run until end, then save execution log.
162 set breakloc [gdb_get_line_number "end of main" "$srcfile"]
163 gdb_test "break $breakloc" \
164 "Breakpoint $decimal at .*$srcfile, line $breakloc\." \
165 "breakpoint at end of main"
167 # Signal handlers must be disabled
168 gdb_test "handle all nostop noprint"
170 # The list of signals that the program generates, in the order they
246 # Software single-step targets can't step into signal handlers. Since
247 # later, when replaying the execution log, the test wants to set
248 # breakpoints on handlers, we need to make sure that while recording,
249 # GDB steps through the handlers too, so that the execution log covers
250 # them. Setting breakpoints in all handlers takes care of it. This
251 # is harmless for hardware-step targets.
252 foreach sig $signals {
253 set test "break *handle_$sig"
254 gdb_test_multiple $test $test {
255 -re "Breakpoint .*$gdb_prompt $" {
256 # No need to record a pass for each breakpoint.
261 gdb_test_multiple "continue" "continue" {
262 -re "Breakpoint .* end of main .*$gdb_prompt $" {
263 pass "run to end of main"
265 -re "Breakpoint .* handle_.*$gdb_prompt $" {
266 send_gdb "continue\n"
273 gdb_test "record save $precsave" \
274 "Saved core file $precsave with execution log\." \
275 "save process recfile"
277 gdb_test "kill" "" "kill process, prepare to debug log file" \
278 "Kill the program being debugged\\? \\(y or n\\) " "y"
280 gdb_test "record restore $precsave" \
281 "Restored records from core file .*" \
282 "reload precord save file"
284 # Signal handlers must be re-enabled
285 gdb_test "handle all stop print"
287 # Make the first signal SIGABRT because it is always supported.
291 # test signal handling
292 foreach sig [lrange $signals 1 end] {
296 # The last signal (SIGTERM) gets handled slightly differently because
297 # we are not setting up for another test.
298 gdb_test "handle SIGTERM stop print" \
299 "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
300 gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*"
301 gdb_test "continue" \
302 "Continuing.*Program received signal SIGTERM.*" \
304 gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
306 gdb_test "continue" " end of main .*" "continue to sigall exit"
308 foreach sig [lreverse $signals] {
309 test_one_sig_reverse $sig
312 # Make the first signal SIGABRT because it is always supported.
316 foreach sig [lrange $signals 1 end] {