Update/correct copyright notices.
[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
61 # Set up to go to the next-to-last line of the program
62 #
63 gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*"
64
65 # Expect to hit the bp at line "1", but symbolize this
66 # as line "13". Then try to clear it--this should work.
67 #
68 if [target_info exists use_gdb_stub] {
69 gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*"
70 } else {
71 gdb_test "r" ".*Breakpoint.*1.*callee.*13.*"
72 }
73 gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked"
74 send_gdb "i b\n"
75 gdb_expect {
76 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" { fail "clear bp" }
77 -re ".*3.*main.*31.*$gdb_prompt $" { pass "cleared bp at line before routine" }
78 -re ".*$gdb_prompt $" { fail "info b" }
79 }
80
81 # Test some other "clear" combinations
82 #
83 gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
84 gdb_test "b ending-run.c:13" ".*Note.*also.*Breakpoint.*5.*"
85 gdb_test "cle ending-run.c:13" \
86 ".*Deleted breakpoint 5.*" "Only cleared 1 by line"
87
88 send_gdb "inf line ending-run.c:13\n"
89 gdb_expect {
90 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
91 set line_eight $expect_out(1,string)
92 gdb_test "b 13" ".*Breakpoint.*6.*"
93 gdb_test "cle *$line_eight" ".*Deleted breakpoints 6 4.*" "Clear 2 by address"
94 }
95 -re ".*$gdb_prompt $" {
96 fail "need to fix test for new compile outcome"
97 }
98 }
99
100 send_gdb "inf line ending-run.c:14\n"
101 gdb_expect {
102 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
103 set line_nine $expect_out(1,string)
104 gdb_test "b ending-run.c:14" ".*Breakpoint 7.*ending-run.c, line 14.*"
105 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 8.*"
106 gdb_test "c" ".*Breakpoint.*7.*callee.*14.*"
107 gdb_test "cle" ".*Deleted breakpoints 8 7.*" "Clear 2 by default"
108 }
109 -re ".*$gdb_prompt $" {
110 fail "need to fix test for new compile outcome"
111 }
112 }
113
114 send_gdb "i b\n"
115 gdb_expect {
116 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" {
117 fail "didn't clear bps"
118 }
119 -re ".*3.*main.*31.*$gdb_prompt $" {
120 pass "all set to continue"
121 }
122 -re ".*$gdb_prompt $" {
123 fail "missing bp at end"
124 }
125 }
126
127
128 # See if we can step out with control. The "1 2 3" stuff
129 # is output from the program.
130 #
131 gdb_test "cont" ".*Breakpoint.*31.*"
132
133 if ![gdb_skip_stdio_test "Step to return"] {
134 gdb_test "next" ".*1 2 7 14 23 34 47 62 79 Goodbye!.*32.*" \
135 "Step to return"
136 } else {
137 gdb_test "next" "" ""
138 }
139
140 set old_timeout $timeout
141 set timeout 50
142 send_gdb "next\n"
143 gdb_expect {
144 -re "33.*$gdb_prompt $" {
145 # sometimes we stop at the closing brace, if so, do another next
146 send_gdb "next\n"
147 gdb_expect {
148 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
149 fail "Old bug came back!"
150 gdb_test "n" ".*" ""
151 }
152 -re ".*in.*start.*$gdb_prompt $" {
153 pass "step out of main"
154 }
155 -re ".*in.*bsp_trap.*$gdb_prompt $" {
156 pass "step out of main"
157 }
158 -re ".*in.*init.*$gdb_prompt $" {
159 # This is what happens on sparc64-elf ultra.
160 pass "step out of main"
161 }
162 -re ".*in .nope ().*$gdb_prompt $" {
163 # This is what happens on Solaris currently -sts 1999-08-25
164 pass "step out of main on Solaris"
165 }
166 -re ".*in ..change.mode ().*$gdb_prompt $" {
167 # This is what happens on ARM in thumb mode -fn 2000-02-01
168 pass "step out of main on ARM thumb"
169 }
170 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
171 pass "step out of main"
172 }
173 -re ".*$gdb_prompt $" { fail "step at end 2" }
174 timeout { fail "hang or timeout on step at end 2" }
175 }
176 }
177 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
178 fail "Old bug came back!"
179 gdb_test "n" ".*" ""
180 }
181 -re ".*in.*start.*$gdb_prompt $" {
182 pass "step out of main"
183 }
184 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
185 pass "step out of main 2"
186 }
187 -re ".*in.*currently asm.*$gdb_prompt $" {
188 pass "step out of main into assembler"
189 }
190 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
191 pass "Cygmon stopped in ending trap."
192 }
193 -re ".*$gdb_prompt $" { fail "step at end 1" }
194 timeout { fail "hang or timeout on step at end 1" }
195 }
196
197 if {![target_info exists use_cygmon] || ![target_info use_cygmon]} {
198 send_gdb "n\n"
199 gdb_expect {
200 -re "Program exited normally.*$gdb_prompt $" {
201 # If we actually have debug info for the start function,
202 # then we won't get the "Single-stepping until function
203 # exit" message.
204 pass "step to end of run 1"
205 }
206 -re ".*Single.*Program exited.*$gdb_prompt $" {
207 pass "step to end of run 1"
208 }
209 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
210 pass "step to end of run 2"
211 gdb_test "c" ".*" "continue after exit"
212 }
213 timeout { fail "(timeout) step to end of run" }
214 }
215
216 set timeout $old_timeout
217
218 gdb_test "n" ".*The program is not being run.*" "don't step after run"
219
220 set exec_output [remote_exec host "ls core"]
221
222
223 if [ regexp "core not found" $exec_output] {
224 pass "No core dumped on quit"
225 } else {
226 if [ regexp "No such file or directory" $exec_output] {
227 pass "ls: core: No core dumped on quit"
228 } else {
229 remote_exec build "rm -f core"
230 fail "Core dumped on quit"
231 }
232 }
233 }
234
235 #remote_exec build "rm -f ${binfile}"
236 return 0
237
238
239
240
This page took 0.034486 seconds and 4 git commands to generate.