]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/call-signal-resume.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / call-signal-resume.exp
1 # Copyright 2008-2024 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 # Test inferior resumption after discarding a hand-called function.
17 # There are two things to test.
18 # 1) Inferior stops normally. Upon resumption it should continue normally,
19 # regardless of whatever signal the hand-called function got.
20 # 2) Inferior is stopped at a signal. Upon resumption it should continue
21 # with that signal, regardless of whatever the hand-called function did.
22
23 require {!target_info exists gdb,nosignals}
24
25 # Some targets can't do function calls, so don't even bother with this
26 # test.
27 require {!target_info exists gdb,cannot_call_functions}
28
29
30 standard_testfile call-signals.c
31
32 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33 untested "failed to compile"
34 return -1
35 }
36
37 proc get_dummy_frame_number { } {
38 global gdb_prompt
39
40 gdb_test_multiple "bt" "backtrace" {
41 -re "#(\[0-9\]*) *<function called from gdb>.*$gdb_prompt $" {
42 return $expect_out(1,string)
43 }
44 }
45 return ""
46 }
47
48 # Start with a fresh gdb.
49
50 clean_restart ${binfile}
51
52 if { ![runto_main] } {
53 return 0
54 }
55
56 gdb_test "break stop_one" "Breakpoint \[0-9\]* at .*"
57 gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, stop_one.*" \
58 "continue to breakpoint at stop_one"
59
60 # Call function (causing the program to get a signal), and see if gdb handles
61 # it properly.
62 if {[gdb_test "call gen_signal ()" \
63 "\[\r\n\]*The program being debugged was signaled.*" \
64 "inferior function call signaled"] != 0} {
65 return 0
66 }
67
68 set frame_number [get_dummy_frame_number]
69 if { "$frame_number" == "" } {
70 fail "dummy stack frame number"
71 setup_xfail "*-*-*"
72 } else {
73 pass "dummy stack frame number"
74 }
75
76 # Pop the dummy frame.
77 gdb_test "frame $frame_number" ".*"
78 gdb_test_no_output "set confirm off"
79 gdb_test "return" ""
80
81 # Verify there are no remains of the dummy frame.
82 gdb_test_no_output "maintenance print dummy-frames"
83 set test "maintenance info breakpoints"
84 gdb_test_multiple $test $test {
85 -re " call dummy .*\r\n$gdb_prompt $" {
86 fail $test
87 }
88 -re "\r\n$gdb_prompt $" {
89 pass $test
90 }
91 }
92
93 # Resume execution, the program should continue without any signal.
94
95 gdb_test "break stop_two" "Breakpoint \[0-9\]* at .*"
96 gdb_test "continue" "Breakpoint \[0-9\]*, stop_two.*" \
97 "continue to breakpoint at stop_two"
98
99 # Continue again, we should get a signal.
100
101 gdb_test "continue" "Program received signal .*" \
102 "continue to receipt of signal"
103
104 # Hand call another function that prematurely stops,
105 # then manually pop the dummy stack frame.
106
107 gdb_test "break null_hand_call" "Breakpoint \[0-9\]* at .*"
108 gdb_test "call null_hand_call ()" "Breakpoint \[0-9\]*, null_hand_call.*" \
109 "null_hand_call"
110
111 set frame_number [get_dummy_frame_number]
112 if { "$frame_number" == "" } {
113 fail "dummy stack frame number, two"
114 setup_xfail "*-*-*"
115 # Need something.
116 set frame_number 0
117 } else {
118 pass "dummy stack frame number, two"
119 }
120
121 # Pop the dummy frame.
122 gdb_test "frame $frame_number" ".*"
123 gdb_test "return" "" "return, two"
124
125 # Continue again, this time we should get to the signal handler.
126
127 gdb_test "break handle_signal" "Breakpoint \[0-9\]* at .*"
128 gdb_test "continue" "Breakpoint \[0-9\]*, handle_signal.*" \
129 "continue to breakpoint at handle_signal"
130
131 # Continue one last time, the program should exit normally.
132
133 gdb_test "continue" "$inferior_exited_re normally." \
134 "continue to program exit"