1 # Copyright 2008-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}
19 # Some targets can't do function calls, so don't even bother with this
21 require {!target_info exists gdb,cannot_call_functions}
25 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
29 if { ![runto_main] } {
33 gdb_test "break stop_here" "Breakpoint \[0-9\]* at .*"
34 gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, stop_here.*" \
35 "continue to breakpoint at stop_here"
37 # Turn on unwind-on-signal.
38 gdb_test_no_output "set unwind-on-signal on" \
39 "setting unwind-on-signal"
41 gdb_test "show unwind-on-signal" \
42 "Unwinding of stack .* is on." \
43 "showing unwind-on-signal"
45 # For backward compatibility we maintain a 'unwindonsignal' alias for
46 # 'unwind-on-signal', check it now.
47 gdb_test "show unwindonsignal" \
48 "Unwinding of stack .* is on\\." \
49 "showing unwindonsignal alias"
51 gdb_test_no_output "set unwindonsignal off" \
52 "setting unwindonsignal alias to off"
54 gdb_test "show unwind-on-signal" \
55 "Unwinding of stack .* is off\\." \
56 "showing unwind-on-signal after setting via alias"
58 gdb_test_no_output "set unwindonsignal on" \
59 "setting unwindonsignal alias to on"
61 # Call function (causing the program to get a signal), and see if gdb handles
63 if {[gdb_test "call gen_signal ()" \
65 "The program being debugged received signal SIGABRT, Aborted" \
66 "while in a function called from GDB\\. GDB has restored the context" \
67 "to what it was before the call\\. To change this behavior use" \
68 "\"set unwind-on-signal off\"\\. Evaluation of the expression containing" \
69 "the function \\(gen_signal\\) will be abandoned\\."] \
70 "unwindonsignal, inferior function call signaled"] != 0} {
74 # Verify the stack got unwound.
76 "#0 *\[x0-9a-f in\]*stop_here \\(.*\\) at .*#1 *\[x0-9a-f in\]*main \\(.*\\) at .*" \
79 # Verify the dummy frame got removed from dummy_frame_stack.
80 gdb_test_multiple "maint print dummy-frames" \
81 "unwind-on-signal, dummy frame removed" {
82 -re "\[\r\n\]*.*stack=.*code=.*\[\r\n\]+$gdb_prompt $" {
85 -re "\[\r\n\]+$gdb_prompt $" {