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