4b2e427f0e178537035d3f7c16717cf4d3ec1a47
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ending-run.exp
1 # Copyright 1997, 1998, 1999, 2000, 2001 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # use this to debug:
21 #
22 #log_user 1
23
24 # ending-run.exp -- Expect script to test ending a test run in gdb
25
26 if $tracelevel then {
27 strace $tracelevel
28 }
29
30 set testfile ending-run
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
33
34 remote_exec build "rm -f ${binfile}"
35 remote_exec build "rm -f core"
36
37
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
40 }
41
42
43
44 gdb_exit
45 gdb_start
46 gdb_reinitialize_dir $srcdir/$subdir
47 gdb_load ${binfile}
48
49 # CHFts23469: Test that you can "clear" a bp set at
50 # a line _before_ the routine (which will default to the
51 # first line in the routine, which turns out to correspond
52 # to the prolog--that's another bug...)
53 #
54
55 gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \
56 "bpt at line before routine"
57
58 gdb_test "b ending-run.c:13" \
59 ".*Note.*also.*Breakpoint 2.*ending-run.c, line 13.*" \
60 "b ending-run.c:13, one"
61
62 # Set up to go to the next-to-last line of the program
63 #
64 gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*"
65
66 # Expect to hit the bp at line "1", but symbolize this
67 # as line "13". Then try to clear it--this should work.
68 #
69 if [target_info exists use_gdb_stub] {
70 gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*"
71 } else {
72 gdb_test "r" ".*Breakpoint.*1.*callee.*13.*"
73 }
74 gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked"
75 send_gdb "i b\n"
76 gdb_expect {
77 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" { fail "clear bp" }
78 -re ".*3.*main.*31.*$gdb_prompt $" { pass "cleared bp at line before routine" }
79 -re ".*$gdb_prompt $" { fail "info b" }
80 }
81
82 # Test some other "clear" combinations
83 #
84 gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
85 gdb_test "b ending-run.c:13" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:13, two"
86 gdb_test "cle ending-run.c:13" \
87 ".*Deleted breakpoint 5.*" "Only cleared 1 by line"
88
89 send_gdb "inf line ending-run.c:13\n"
90 gdb_expect {
91 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
92 set line_eight $expect_out(1,string)
93 gdb_test "b 13" ".*Breakpoint.*6.*"
94 gdb_test "cle *$line_eight" ".*Deleted breakpoints 6 4.*" "Clear 2 by address"
95 }
96 -re ".*$gdb_prompt $" {
97 fail "need to fix test for new compile outcome"
98 }
99 }
100
101 send_gdb "inf line ending-run.c:14\n"
102 gdb_expect {
103 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
104 set line_nine $expect_out(1,string)
105 gdb_test "b ending-run.c:14" ".*Breakpoint 7.*ending-run.c, line 14.*"
106 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 8.*"
107 gdb_test "c" ".*Breakpoint.*7.*callee.*14.*"
108 gdb_test "cle" ".*Deleted breakpoints 8 7.*" "Clear 2 by default"
109 }
110 -re ".*$gdb_prompt $" {
111 fail "need to fix test for new compile outcome"
112 }
113 }
114
115 send_gdb "i b\n"
116 gdb_expect {
117 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" {
118 fail "didn't clear bps"
119 }
120 -re ".*3.*main.*31.*$gdb_prompt $" {
121 pass "all set to continue"
122 }
123 -re ".*$gdb_prompt $" {
124 fail "missing bp at end"
125 }
126 }
127
128
129 # See if we can step out with control. The "1 2 3" stuff
130 # is output from the program.
131 #
132 gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*31.*"
133
134 if ![gdb_skip_stdio_test "Step to return"] {
135 gdb_test "next" ".*Goodbye!.*32.*" \
136 "Step to return"
137 } else {
138 gdb_test "next" "" ""
139 }
140
141 set old_timeout $timeout
142 set timeout 50
143 set program_exited 0
144 send_gdb "next\n"
145 gdb_expect {
146 -re "33.*$gdb_prompt $" {
147 # sometimes we stop at the closing brace, if so, do another next
148 send_gdb "next\n"
149 gdb_expect {
150 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
151 fail "Old bug came back!"
152 gdb_test "n" ".*" ""
153 }
154 -re ".*in.*start.*$gdb_prompt $" {
155 pass "step out of main"
156 }
157 -re ".*in.*bsp_trap.*$gdb_prompt $" {
158 pass "step out of main"
159 }
160 -re ".*in.*init.*$gdb_prompt $" {
161 # This is what happens on sparc64-elf ultra.
162 pass "step out of main"
163 }
164 -re ".*Program exited normally.*$gdb_prompt $" {
165 # This is what happens on Linux i86 (and I would expect others)
166 set program_exited 1
167 pass "step out of main"
168 }
169 -re ".*in .nope ().*$gdb_prompt $" {
170 # This is what happens on Solaris currently -sts 1999-08-25
171 pass "step out of main on Solaris"
172 }
173 -re ".*in _int_reset ().*$gdb_prompt $" {
174 # This is what happens on Sanyo XStormy16
175 pass "step out of main"
176 }
177 -re ".*in ..change.mode ().*$gdb_prompt $" {
178 # This is what happens on ARM in thumb mode -fn 2000-02-01
179 pass "step out of main on ARM thumb"
180 }
181 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
182 pass "step out of main"
183 }
184 -re ".*$gdb_prompt $" { fail "step at end 2" }
185 timeout { fail "hang or timeout on step at end 2" }
186 }
187 }
188 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
189 fail "Old bug came back!"
190 gdb_test "n" ".*" ""
191 }
192 -re ".*in.*start.*$gdb_prompt $" {
193 pass "step out of main"
194 }
195 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
196 pass "step out of main 2"
197 }
198 -re ".*Program exited normally.*$gdb_prompt $" {
199 # This is what happens on Linux i86 (and I would expect others)
200 set program_exited 1
201 pass "step out of main"
202 }
203 -re ".*in.*currently asm.*$gdb_prompt $" {
204 pass "step out of main into assembler"
205 }
206 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
207 pass "Cygmon stopped in ending trap."
208 }
209 -re ".*$gdb_prompt $" { fail "step at end 1" }
210 timeout { fail "hang or timeout on step at end 1" }
211 }
212
213 if {![target_info exists use_cygmon] || ![target_info use_cygmon]} {
214 global program_exited;
215 if {[eval expr $program_exited == 0]} {
216 send_gdb "n\n"
217 gdb_expect {
218 -re "Program exited normally.*$gdb_prompt $" {
219 # If we actually have debug info for the start function,
220 # then we won't get the "Single-stepping until function
221 # exit" message.
222 pass "step to end of run"
223 }
224 -re ".*Single.*Program exited.*$gdb_prompt $" {
225 pass "step to end of run"
226 }
227 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
228 pass "step to end of run"
229 gdb_test "c" ".*" "continue after exit"
230 }
231 -re ".*Single.*_int_reset.*$gdb_prompt $" {
232 pass "step to end of run"
233 setup_xfail "xstormy16-*-*"
234 }
235 -re ".*$gdb_prompt $" {
236 fail "step to end of run"
237 }
238 timeout {
239 fail "(timeout) step to end of run"
240 }
241 }
242 }
243
244 set timeout $old_timeout
245
246 gdb_test "n" ".*The program is not being run.*" "don't step after run"
247
248 set exec_output [remote_exec host "ls core"]
249
250 if [ regexp "core not found" $exec_output] {
251 pass "No core dumped on quit"
252 } else {
253 if [ regexp "No such file or directory" $exec_output] {
254 pass "ls: core: No core dumped on quit"
255 } else {
256 remote_exec build "rm -f core"
257 fail "Core dumped on quit"
258 }
259 }
260 }
261
262 #remote_exec build "rm -f ${binfile}"
263 return 0
264
265
266
267
This page took 0.036433 seconds and 4 git commands to generate.