]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/ending-run.exp
2001-07-25 Michael Snyder <msnyder@redhat.com>
[thirdparty/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" ".*Breakpoint.*31.*"
133
134 if ![gdb_skip_stdio_test "Step to return"] {
135 gdb_test "next" ".*1 2 7 14 23 34 47 62 79 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 ..change.mode ().*$gdb_prompt $" {
174 # This is what happens on ARM in thumb mode -fn 2000-02-01
175 pass "step out of main on ARM thumb"
176 }
177 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
178 pass "step out of main"
179 }
180 -re ".*$gdb_prompt $" { fail "step at end 2" }
181 timeout { fail "hang or timeout on step at end 2" }
182 }
183 }
184 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
185 fail "Old bug came back!"
186 gdb_test "n" ".*" ""
187 }
188 -re ".*in.*start.*$gdb_prompt $" {
189 pass "step out of main"
190 }
191 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
192 pass "step out of main 2"
193 }
194 -re ".*Program exited normally.*$gdb_prompt $" {
195 # This is what happens on Linux i86 (and I would expect others)
196 set program_exited 1
197 pass "step out of main"
198 }
199 -re ".*in.*currently asm.*$gdb_prompt $" {
200 pass "step out of main into assembler"
201 }
202 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
203 pass "Cygmon stopped in ending trap."
204 }
205 -re ".*$gdb_prompt $" { fail "step at end 1" }
206 timeout { fail "hang or timeout on step at end 1" }
207 }
208
209 if {![target_info exists use_cygmon] || ![target_info use_cygmon]} {
210 global program_exited;
211 if {[eval expr $program_exited == 0]} {
212 send_gdb "n\n"
213 gdb_expect {
214 -re "Program exited normally.*$gdb_prompt $" {
215 # If we actually have debug info for the start function,
216 # then we won't get the "Single-stepping until function
217 # exit" message.
218 pass "step to end of run 1"
219 }
220 -re ".*Single.*Program exited.*$gdb_prompt $" {
221 pass "step to end of run 1"
222 }
223 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
224 pass "step to end of run 2"
225 gdb_test "c" ".*" "continue after exit"
226 }
227 -re ".*$gdb_prompt $" {
228 fail "step to end of run"
229 }
230 timeout {
231 fail "(timeout) step to end of run"
232 }
233 }
234 }
235
236 set timeout $old_timeout
237
238 gdb_test "n" ".*The program is not being run.*" "don't step after run"
239
240 set exec_output [remote_exec host "ls core"]
241
242 if [ regexp "core not found" $exec_output] {
243 pass "No core dumped on quit"
244 } else {
245 if [ regexp "No such file or directory" $exec_output] {
246 pass "ls: core: No core dumped on quit"
247 } else {
248 remote_exec build "rm -f core"
249 fail "Core dumped on quit"
250 }
251 }
252 }
253
254 #remote_exec build "rm -f ${binfile}"
255 return 0
256
257
258
259