Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2008-2020 Free Software Foundation, Inc. |
b89667eb DE |
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 | ||
2390201f DJ |
23 | if [target_info exists gdb,nosignals] { |
24 | verbose "Skipping call-signal-resume.exp because of nosignals." | |
25 | continue | |
26 | } | |
27 | ||
b89667eb | 28 | |
f76495c8 | 29 | standard_testfile call-signals.c |
b89667eb DE |
30 | |
31 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
5b362f04 | 32 | untested "failed to compile" |
b89667eb DE |
33 | return -1 |
34 | } | |
35 | ||
36 | # Some targets can't do function calls, so don't even bother with this | |
37 | # test. | |
38 | if [target_info exists gdb,cannot_call_functions] { | |
bc6c7af4 | 39 | unsupported "this target can not call functions" |
b89667eb DE |
40 | continue |
41 | } | |
42 | ||
43 | proc get_dummy_frame_number { } { | |
ad3986f0 | 44 | global gdb_prompt |
b89667eb | 45 | |
ad3986f0 MS |
46 | gdb_test_multiple "bt" "backtrace" { |
47 | -re "#(\[0-9\]*) *<function called from gdb>.*$gdb_prompt $" { | |
48 | return $expect_out(1,string) | |
49 | } | |
50 | } | |
51 | return "" | |
b89667eb DE |
52 | } |
53 | ||
54 | # Start with a fresh gdb. | |
55 | ||
f76495c8 | 56 | clean_restart ${binfile} |
b89667eb DE |
57 | |
58 | if { ![runto_main] } { | |
bc6c7af4 | 59 | fail "can't run to main" |
b89667eb DE |
60 | return 0 |
61 | } | |
62 | ||
63 | gdb_test "break stop_one" "Breakpoint \[0-9\]* at .*" | |
64 | gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, stop_one.*" \ | |
65 | "continue to breakpoint at stop_one" | |
66 | ||
67 | # Call function (causing the program to get a signal), and see if gdb handles | |
68 | # it properly. | |
23ffc893 PA |
69 | if {[gdb_test "call gen_signal ()" \ |
70 | "\[\r\n\]*The program being debugged was signaled.*" \ | |
71 | "inferior function call signaled"] != 0} { | |
72 | return 0 | |
b89667eb DE |
73 | } |
74 | ||
75 | set frame_number [get_dummy_frame_number] | |
76 | if { "$frame_number" == "" } { | |
77 | fail "dummy stack frame number" | |
78 | setup_xfail "*-*-*" | |
79 | } else { | |
80 | pass "dummy stack frame number" | |
81 | } | |
82 | ||
83 | # Pop the dummy frame. | |
f6978de9 | 84 | gdb_test "frame $frame_number" ".*" |
27d3a1a2 | 85 | gdb_test_no_output "set confirm off" |
050a2e1d | 86 | gdb_test "return" "" |
b89667eb | 87 | |
e2e4d78b JK |
88 | # Verify there are no remains of the dummy frame. |
89 | gdb_test_no_output "maintenance print dummy-frames" | |
90 | set test "maintenance info breakpoints" | |
91 | gdb_test_multiple $test $test { | |
92 | -re " call dummy .*\r\n$gdb_prompt $" { | |
93 | fail $test | |
94 | } | |
95 | -re "\r\n$gdb_prompt $" { | |
96 | pass $test | |
97 | } | |
98 | } | |
99 | ||
b89667eb DE |
100 | # Resume execution, the program should continue without any signal. |
101 | ||
102 | gdb_test "break stop_two" "Breakpoint \[0-9\]* at .*" | |
103 | gdb_test "continue" "Breakpoint \[0-9\]*, stop_two.*" \ | |
104 | "continue to breakpoint at stop_two" | |
105 | ||
106 | # Continue again, we should get a signal. | |
107 | ||
108 | gdb_test "continue" "Program received signal .*" \ | |
109 | "continue to receipt of signal" | |
110 | ||
111 | # Hand call another function that prematurely stops, | |
112 | # then manually pop the dummy stack frame. | |
113 | ||
114 | gdb_test "break null_hand_call" "Breakpoint \[0-9\]* at .*" | |
115 | gdb_test "call null_hand_call ()" "Breakpoint \[0-9\]*, null_hand_call.*" \ | |
116 | "null_hand_call" | |
117 | ||
118 | set frame_number [get_dummy_frame_number] | |
119 | if { "$frame_number" == "" } { | |
120 | fail "dummy stack frame number" | |
121 | setup_xfail "*-*-*" | |
122 | # Need something. | |
123 | set frame_number 0 | |
124 | } else { | |
125 | pass "dummy stack frame number" | |
126 | } | |
127 | ||
128 | # Pop the dummy frame. | |
f6978de9 | 129 | gdb_test "frame $frame_number" ".*" |
27d3a1a2 | 130 | gdb_test_no_output "set confirm off" |
050a2e1d | 131 | gdb_test "return" "" |
b89667eb DE |
132 | |
133 | # Continue again, this time we should get to the signal handler. | |
134 | ||
135 | gdb_test "break handle_signal" "Breakpoint \[0-9\]* at .*" | |
136 | gdb_test "continue" "Breakpoint \[0-9\]*, handle_signal.*" \ | |
137 | "continue to breakpoint at handle_signal" | |
138 | ||
139 | # Continue one last time, the program should exit normally. | |
140 | ||
eceb0c5f TT |
141 | gdb_test "continue" "$inferior_exited_re normally." \ |
142 | "continue to program exit" | |
b89667eb DE |
143 | |
144 | return 0 |