]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/ending-run.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / ending-run.exp
CommitLineData
1bf404ef
AC
1# This testcase is part of GDB, the GNU debugger.
2
42a4f53d 3# Copyright 1997-2019 Free Software Foundation, Inc.
c906108c
SS
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
e22f8b7c 7# the Free Software Foundation; either version 3 of the License, or
c906108c 8# (at your option) any later version.
e22f8b7c 9#
c906108c
SS
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
e22f8b7c 14#
c906108c 15# You should have received a copy of the GNU General Public License
e22f8b7c 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c
SS
17
18# use this to debug:
19#
20#log_user 1
21
22# ending-run.exp -- Expect script to test ending a test run in gdb
23
04e5059b
AA
24standard_testfile
25
5b362f04 26if { [prepare_for_testing "failed to prepare" $testfile] } {
dbc52822 27 return -1
c906108c 28}
c906108c
SS
29remote_exec build "rm -f core"
30
c906108c
SS
31# CHFts23469: Test that you can "clear" a bp set at
32# a line _before_ the routine (which will default to the
33# first line in the routine, which turns out to correspond
34# to the prolog--that's another bug...)
35#
b84b7669
MS
36
37gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \
38 "bpt at line before routine"
39
04e5059b
AA
40set break1_line [gdb_get_line_number "-break1-"]
41gdb_test "b ending-run.c:$break1_line" \
42 ".*Note.*also.*Breakpoint 2.*ending-run.c, line $break1_line.*" \
43 "b ending-run.c:$break1_line, one"
c906108c
SS
44
45# Set up to go to the next-to-last line of the program
46#
04e5059b
AA
47set break2_line [gdb_get_line_number "-break2-"]
48gdb_test "b ending-run.c:$break2_line" ".*Breakpoint 3.*ending-run.c, line $break2_line.*"
c906108c
SS
49
50# Expect to hit the bp at line "1", but symbolize this
085dd6e6 51# as line "13". Then try to clear it--this should work.
c906108c 52#
b741e217 53gdb_run_cmd
04e5059b 54gdb_test "" ".*Breakpoint.*1.*callee.*$break1_line.*" "run"
b741e217 55
d6e956e5 56gdb_test "cle" ".*Deleted breakpoints 1 2.*" "clear worked"
a76e022a 57gdb_test_multiple "i b" "cleared bp at line before routine" {
ed4c619a 58 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
cb9a9d3e
MS
59 fail "cleared bp at line before routine"
60 }
04e5059b 61 -re ".*3.*main.*$break2_line.*$gdb_prompt $" {
cb9a9d3e
MS
62 pass "cleared bp at line before routine"
63 }
c906108c
SS
64}
65
66# Test some other "clear" combinations
67#
b84b7669 68gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
04e5059b
AA
69gdb_test "b ending-run.c:$break1_line" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:$break1_line, two"
70gdb_test "cle ending-run.c:$break1_line" \
a9e40818 71 ".*Deleted breakpoints 4 5.*" "Cleared 2 by line"
c906108c 72
04e5059b 73gdb_test_multiple "info line ending-run.c:$break1_line" "" {
c906108c
SS
74 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
75 set line_nine $expect_out(1,string)
04e5059b 76 gdb_test "b ending-run.c:$break1_line" ".*Breakpoint 6.*ending-run.c, line $break1_line.*"
cdc7edd7 77 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 7.*" "breakpoint 7 at *ending-run.c:$break1_line"
a9e40818 78 gdb_test "cle" ".*Deleted breakpoints 6 7.*" "clear 2 by default"
c906108c
SS
79 }
80 -re ".*$gdb_prompt $" {
81 fail "need to fix test for new compile outcome"
82 }
83}
84
a76e022a 85gdb_test_multiple "i b" "all set to continue" {
ed4c619a 86 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
cb9a9d3e 87 fail "all set to continue (didn't clear bps)"
c906108c 88 }
04e5059b 89 -re ".*3.*main.*$break2_line.*$gdb_prompt $" {
c906108c
SS
90 pass "all set to continue"
91 }
92 -re ".*$gdb_prompt $" {
cb9a9d3e 93 fail "all set to continue (missing bp at end)"
c906108c
SS
94 }
95}
96
97
98# See if we can step out with control. The "1 2 3" stuff
99# is output from the program.
100#
004af6c7 101if ![gdb_skip_stdio_test "cont"] {
7cb000a9
PA
102 gdb_test_stdio "cont" \
103 "1 2 7 14 23 34 47 62 79" \
104 "Breakpoint.*$break2_line.*"
004af6c7 105} else {
04e5059b 106 gdb_test "cont" ".*Breakpoint.*$break2_line.*"
004af6c7 107}
13a5e3b8
MS
108
109if ![gdb_skip_stdio_test "Step to return"] {
7cb000a9
PA
110 gdb_test_stdio "next" \
111 "Goodbye!" \
112 "[expr {$break2_line + 1}].*" \
113 "Step to return"
13a5e3b8 114} else {
de7ff789 115 gdb_test "next" ".*" ""
13a5e3b8 116}
c906108c
SS
117
118set old_timeout $timeout
119set timeout 50
2b1a1355 120set program_exited 0
697bc68d 121set nexted 0
a76e022a
MS
122
123gdb_test_multiple "next" "step out of main" {
04e5059b 124 -re "[expr {$break2_line + 2}]\[ \t\]+\}.*$gdb_prompt $" {
c906108c 125 # sometimes we stop at the closing brace, if so, do another next
697bc68d
NS
126 if { $nexted } {
127 fail "step out of main"
128 } else {
129 set nexted 1
130 send_gdb "next\n"
131 exp_continue
c906108c
SS
132 }
133 }
134 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
697bc68d
NS
135 fail "step out of main"
136 gdb_test "n" ".*" ""
c906108c
SS
137 }
138 -re ".*in.*start.*$gdb_prompt $" {
697bc68d
NS
139 pass "step out of main"
140 }
141 -re ".*in.*bsp_trap.*$gdb_prompt $" {
142 pass "step out of main"
c906108c 143 }
697bc68d
NS
144 -re ".*in.*init.*$gdb_prompt $" {
145 # This is what happens on sparc64-elf ultra.
146 pass "step out of main"
147 }
148 -re ".*in.*dll_crt0_1.*$gdb_prompt $" {
149 # This is what happens on Cygwin.
150 pass "step out of main"
085dd6e6 151 }
8b5a0f4f
PA
152 -re ".*WinMain.*$gdb_prompt $" {
153 # This is what happens on mingw32ce.
154 pass "step out of main"
155 }
fda326dd 156 -re ".*$inferior_exited_re normally.*$gdb_prompt $" {
2b1a1355
MS
157 # This is what happens on Linux i86 (and I would expect others)
158 set program_exited 1
159 pass "step out of main"
160 }
697bc68d
NS
161 -re ".*in .nope ().*$gdb_prompt $" {
162 # This is what happens on Solaris currently -sts 1999-08-25
163 pass "step out of main"
164 }
165 -re ".*in _int_reset ().*$gdb_prompt $" {
166 # This is what happens on Sanyo XStormy16
167 pass "step out of main"
168 }
169 -re ".*init ().*$gdb_prompt $" {
170 # This is what happens on many Mips targets
171 pass "step out of main"
172 }
173 -re ".*in ..change.mode ().*$gdb_prompt $" {
174 # This is what happens on ARM in thumb mode -fn 2000-02-01
175 pass "step out of main"
176 }
293e2f9e 177 -re ".*__rt_entry.* ().*$gdb_prompt $" {
697bc68d
NS
178 # This is what happens on the ARM RVDS runtime
179 pass "step out of main"
180 }
181 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
182 pass "step out of main"
183 }
184 -re ".*in __wrap__?main ().*$gdb_prompt $" {
185 pass "step out of main"
186 }
187 -re "__setup_argv_for_main (.*).*$gdb_prompt $" {
188 # On sh, another wrapper function (start_l) exists, so
189 # another `next' is necessary.
190 gdb_test "next" ".*in start_l ().*" "step out of main"
191 }
759f0f0b
PA
192 -re "E32Main (.*).*$gdb_prompt $" {
193 # On SymbianOS there's a different function which calls main.
194 pass "step out of main"
195 }
cce74817 196 -re ".*in.*currently asm.*$gdb_prompt $" {
697bc68d
NS
197 pass "step out of main"
198 }
199 -re "_*start\[0-9\]* \\(\[^)\]*\\).*$gdb_prompt $" {
200 pass "step out of main"
cce74817
JM
201 }
202 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
697bc68d 203 pass "step out of main"
cce74817 204 }
dbc0f131
YQ
205 -re ".*in.*__uClibc_main.*$gdb_prompt $" {
206 # This is what happens on system using uClibc.
207 pass "step out of main"
208 }
c906108c
SS
209}
210
0f815cdf
JB
211# When we're talking to a program running on a real stand-alone board,
212# every BSP's exit function behaves differently, so there's no single
213# way to tell whether we've exited gracefully or not. So don't run
214# these tests when use_gdb_stub is set, or when we're running under Cygmon.
31e45dee
FN
215set program_exited_normally 0
216set program_not_exited 0
217set program_in_exit 0
e11ac3a3 218if {!$use_gdb_stub
0f815cdf 219 && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} {
4ec70201 220 global program_exited
2b1a1355 221 if {[eval expr $program_exited == 0]} {
a76e022a 222 gdb_test_multiple "n" "step to end of run" {
fda326dd 223 -re "$inferior_exited_re normally.*$gdb_prompt $" {
2b1a1355
MS
224 # If we actually have debug info for the start function,
225 # then we won't get the "Single-stepping until function
226 # exit" message.
36a22261 227 pass "step to end of run"
31e45dee 228 set program_exited_normally 1
2b1a1355 229 }
fda326dd 230 -re "Single.*EXIT code 0\r\n.*$inferior_exited_re normally.*$gdb_prompt $" {
cb9a9d3e 231 pass "step to end of run (status wrapper)"
31e45dee 232 set program_exited_normally 1
cb9a9d3e 233 }
afb5c968
CV
234 -re "Single.*EXIT code 0\r\n.*$gdb_prompt $" {
235 pass "step to end of run (status wrapper)"
236 }
fda326dd 237 -re ".*Single.*$inferior_exited_re.*$gdb_prompt $" {
36a22261 238 pass "step to end of run"
31e45dee 239 set program_exited_normally 1
2b1a1355
MS
240 }
241 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
36a22261 242 pass "step to end of run"
31e45dee 243 set program_in_exit 1
2b1a1355 244 }
36a22261
CV
245 -re ".*Single.*_int_reset.*$gdb_prompt $" {
246 pass "step to end of run"
31e45dee
FN
247 if {![istarget "xstormy16-*-*"]} {
248 set program_exited_normally 1
249 }
36a22261 250 }
2b1a1355
MS
251 }
252 }
253
31e45dee
FN
254 if {$program_in_exit} {
255 if {[gdb_test "c" ".*" "continue after exit"] == 0} {
256 set program_exited_normally 1
257 }
258 } else {
259 unsupported "continue after exit"
260 }
261
31e45dee
FN
262 if {$program_exited_normally} {
263 gdb_test "n" ".*The program is not being run.*" "don't step after run"
264 } elseif {$program_not_exited} {
265 unresolved "don't step after run"
266 } else {
267 unsupported "don't step after run"
268 }
2b1a1355
MS
269
270 set exec_output [remote_exec host "ls core"]
271
272 if [ regexp "core not found" $exec_output] {
bc6c7af4 273 pass "no core dumped on quit"
7a292a7a 274 } else {
2b1a1355 275 if [ regexp "No such file or directory" $exec_output] {
cb9a9d3e 276 pass "ls: core (No core dumped on quit)"
2b1a1355
MS
277 } else {
278 remote_exec build "rm -f core"
cb9a9d3e 279 fail "ls: core (Core dumped on quit)"
2b1a1355 280 }
7a292a7a 281 }
c906108c
SS
282}
283
97f2ed50
DJ
284set timeout $old_timeout
285
c906108c
SS
286#remote_exec build "rm -f ${binfile}"
287return 0
288
289
290
291