2000-10-16 Michael Snyder <msnyder@cleaver.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ending-run.exp
CommitLineData
7a292a7a 1# Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
c906108c
SS
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
26if $tracelevel then {
27 strace $tracelevel
28}
29
30set testfile ending-run
31set srcfile ${testfile}.c
32set binfile ${objdir}/${subdir}/${testfile}
33
34remote_exec build "rm -f ${binfile}"
35remote_exec build "rm -f core"
36
37
38if { [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
44gdb_exit
45gdb_start
46gdb_reinitialize_dir $srcdir/$subdir
47gdb_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#
b84b7669
MS
54
55gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \
56 "bpt at line before routine"
57
58gdb_test "b ending-run.c:13" \
59 ".*Note.*also.*Breakpoint 2.*ending-run.c, line 13.*"
c906108c
SS
60
61# Set up to go to the next-to-last line of the program
62#
b84b7669 63gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*"
c906108c
SS
64
65# Expect to hit the bp at line "1", but symbolize this
085dd6e6 66# as line "13". Then try to clear it--this should work.
c906108c 67#
7a292a7a 68if [target_info exists use_gdb_stub] {
a0b3c4fd 69 gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*"
7a292a7a 70} else {
a0b3c4fd 71 gdb_test "r" ".*Breakpoint.*1.*callee.*13.*"
7a292a7a 72}
c906108c
SS
73gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked"
74send_gdb "i b\n"
75gdb_expect {
76 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" { fail "clear bp" }
085dd6e6 77 -re ".*3.*main.*31.*$gdb_prompt $" { pass "cleared bp at line before routine" }
c906108c
SS
78 -re ".*$gdb_prompt $" { fail "info b" }
79}
80
81# Test some other "clear" combinations
82#
b84b7669
MS
83gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
84gdb_test "b ending-run.c:13" ".*Note.*also.*Breakpoint.*5.*"
85gdb_test "cle ending-run.c:13" \
86 ".*Deleted breakpoint 5.*" "Only cleared 1 by line"
c906108c 87
b84b7669 88send_gdb "inf line ending-run.c:13\n"
c906108c
SS
89gdb_expect {
90 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
91 set line_eight $expect_out(1,string)
a0b3c4fd 92 gdb_test "b 13" ".*Breakpoint.*6.*"
c906108c
SS
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
b84b7669 100send_gdb "inf line ending-run.c:14\n"
c906108c
SS
101gdb_expect {
102 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
103 set line_nine $expect_out(1,string)
b84b7669
MS
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.*"
a0b3c4fd 106 gdb_test "c" ".*Breakpoint.*7.*callee.*14.*"
c906108c
SS
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
114send_gdb "i b\n"
115gdb_expect {
116 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" {
117 fail "didn't clear bps"
118 }
085dd6e6 119 -re ".*3.*main.*31.*$gdb_prompt $" {
c906108c
SS
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#
a0b3c4fd 131gdb_test "cont" ".*Breakpoint.*31.*"
13a5e3b8
MS
132
133if ![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}
c906108c
SS
139
140set old_timeout $timeout
141set timeout 50
142send_gdb "next\n"
143gdb_expect {
085dd6e6 144 -re "33.*$gdb_prompt $" {
c906108c
SS
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 }
b84b7669
MS
155 -re ".*in.*init.*$gdb_prompt $" {
156 # This is what happens on sparc64-elf ultra.
157 pass "step out of main"
158 }
104c1213
JM
159 -re ".*in .nope ().*$gdb_prompt $" {
160 # This is what happens on Solaris currently -sts 1999-08-25
161 pass "step out of main on Solaris"
162 }
8b93c638
JM
163 -re ".*in ..change.mode ().*$gdb_prompt $" {
164 # This is what happens on ARM in thumb mode -fn 2000-02-01
165 pass "step out of main on ARM thumb"
166 }
085dd6e6
JM
167 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
168 pass "step out of main"
169 }
0f71a2f6 170 -re ".*$gdb_prompt $" { fail "step at end 2" }
c906108c
SS
171 timeout { fail "hang or timeout on step at end 2" }
172 }
173 }
174 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
175 fail "Old bug came back!"
176 gdb_test "n" ".*" ""
177 }
178 -re ".*in.*start.*$gdb_prompt $" {
179 pass "step out of main"
180 }
085dd6e6
JM
181 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
182 pass "step out of main 2"
183 }
cce74817
JM
184 -re ".*in.*currently asm.*$gdb_prompt $" {
185 pass "step out of main into assembler"
186 }
187 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
7a292a7a 188 pass "Cygmon stopped in ending trap."
cce74817 189 }
0f71a2f6 190 -re ".*$gdb_prompt $" { fail "step at end 1" }
c906108c
SS
191 timeout { fail "hang or timeout on step at end 1" }
192}
193
7a292a7a 194if {![target_info exists use_cygmon] || ![target_info use_cygmon]} {
085dd6e6
JM
195 send_gdb "n\n"
196 gdb_expect {
c2d11a7d
JM
197 -re "Program exited normally.*$gdb_prompt $" {
198 # If we actually have debug info for the start function,
199 # then we won't get the "Single-stepping until function
200 # exit" message.
201 pass "step to end of run 1"
202 }
085dd6e6
JM
203 -re ".*Single.*Program exited.*$gdb_prompt $" {
204 pass "step to end of run 1"
205 }
206 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
207 pass "step to end of run 2"
208 gdb_test "c" ".*" "continue after exit"
209 }
210 timeout { fail "(timeout) step to end of run" }
211 }
212
7a292a7a
SS
213 set timeout $old_timeout
214
215 gdb_test "n" ".*The program is not being run.*" "don't step after run"
216
217 set exec_output [remote_exec host "ls core"]
218
219
220 if [ regexp "core not found" $exec_output] {
c906108c 221 pass "No core dumped on quit"
c906108c 222 } else {
7a292a7a
SS
223 if [ regexp "No such file or directory" $exec_output] {
224 pass "ls: core: No core dumped on quit"
225 } else {
c906108c
SS
226 remote_exec build "rm -f core"
227 fail "Core dumped on quit"
7a292a7a 228 }
c906108c
SS
229 }
230}
231
232#remote_exec build "rm -f ${binfile}"
233return 0
234
235
236
237
This page took 0.091125 seconds and 4 git commands to generate.