import gdb-1999-06-28 snapshot
[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#
54gdb_test "b 1" ".*Breakpoint.*line 1.*" "bpt at line before routine"
085dd6e6 55gdb_test "b 13" ".*Note.*also.*Breakpoint.*2.*" ""
c906108c
SS
56
57# Set up to go to the next-to-last line of the program
58#
085dd6e6 59gdb_test "b 31" ".*Breakpoint.*3.*" ""
c906108c
SS
60
61# Expect to hit the bp at line "1", but symbolize this
085dd6e6 62# as line "13". Then try to clear it--this should work.
c906108c 63#
7a292a7a 64if [target_info exists use_gdb_stub] {
085dd6e6 65 gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*" ""
7a292a7a 66} else {
085dd6e6 67 gdb_test "r" ".*Breakpoint.*1.*callee.*13.*" ""
7a292a7a 68}
c906108c
SS
69gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked"
70send_gdb "i b\n"
71gdb_expect {
72 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" { fail "clear bp" }
085dd6e6 73 -re ".*3.*main.*31.*$gdb_prompt $" { pass "cleared bp at line before routine" }
c906108c
SS
74 -re ".*$gdb_prompt $" { fail "info b" }
75}
76
77# Test some other "clear" combinations
78#
79gdb_test "b 1" ".*Breakpoint.*4.*" ""
085dd6e6
JM
80gdb_test "b 13" ".*Note.*also.*Breakpoint.*5.*" ""
81gdb_test "cle 13" ".*Deleted breakpoint 5.*" "Only cleared 1 by line"
c906108c 82
085dd6e6 83send_gdb "inf line 13\n"
c906108c
SS
84gdb_expect {
85 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
86 set line_eight $expect_out(1,string)
085dd6e6 87 gdb_test "b 13" ".*Breakpoint.*6.*" ""
c906108c
SS
88 gdb_test "cle *$line_eight" ".*Deleted breakpoints 6 4.*" "Clear 2 by address"
89 }
90 -re ".*$gdb_prompt $" {
91 fail "need to fix test for new compile outcome"
92 }
93}
94
085dd6e6 95send_gdb "inf line 14\n"
c906108c
SS
96gdb_expect {
97 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
98 set line_nine $expect_out(1,string)
085dd6e6 99 gdb_test "b 14" ".*Breakpoint.*7.*" ""
c906108c 100 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint.*8.*" ""
085dd6e6 101 gdb_test "c" ".*Breakpoint.*7.*callee.*14.*" ""
c906108c
SS
102 gdb_test "cle" ".*Deleted breakpoints 8 7.*" "Clear 2 by default"
103 }
104 -re ".*$gdb_prompt $" {
105 fail "need to fix test for new compile outcome"
106 }
107}
108
109send_gdb "i b\n"
110gdb_expect {
111 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" {
112 fail "didn't clear bps"
113 }
085dd6e6 114 -re ".*3.*main.*31.*$gdb_prompt $" {
c906108c
SS
115 pass "all set to continue"
116 }
117 -re ".*$gdb_prompt $" {
118 fail "missing bp at end"
119 }
120}
121
122
123# See if we can step out with control. The "1 2 3" stuff
124# is output from the program.
125#
085dd6e6
JM
126gdb_test "cont" ".*Breakpoint.*32.*" ""
127gdb_test "next" ".*1 2 7 14 23 34 47 62 79 Goodbye!.*32.*" "Step to return"
c906108c
SS
128
129set old_timeout $timeout
130set timeout 50
131send_gdb "next\n"
132gdb_expect {
085dd6e6 133 -re "33.*$gdb_prompt $" {
c906108c
SS
134 # sometimes we stop at the closing brace, if so, do another next
135 send_gdb "next\n"
136 gdb_expect {
137 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
138 fail "Old bug came back!"
139 gdb_test "n" ".*" ""
140 }
141 -re ".*in.*start.*$gdb_prompt $" {
142 pass "step out of main"
143 }
085dd6e6
JM
144 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
145 pass "step out of main"
146 }
0f71a2f6 147 -re ".*$gdb_prompt $" { fail "step at end 2" }
c906108c
SS
148 timeout { fail "hang or timeout on step at end 2" }
149 }
150 }
151 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
152 fail "Old bug came back!"
153 gdb_test "n" ".*" ""
154 }
155 -re ".*in.*start.*$gdb_prompt $" {
156 pass "step out of main"
157 }
085dd6e6
JM
158 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
159 pass "step out of main 2"
160 }
cce74817
JM
161 -re ".*in.*currently asm.*$gdb_prompt $" {
162 pass "step out of main into assembler"
163 }
164 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
7a292a7a 165 pass "Cygmon stopped in ending trap."
cce74817 166 }
0f71a2f6 167 -re ".*$gdb_prompt $" { fail "step at end 1" }
c906108c
SS
168 timeout { fail "hang or timeout on step at end 1" }
169}
170
7a292a7a 171if {![target_info exists use_cygmon] || ![target_info use_cygmon]} {
085dd6e6
JM
172 send_gdb "n\n"
173 gdb_expect {
174 -re ".*Single.*Program exited.*$gdb_prompt $" {
175 pass "step to end of run 1"
176 }
177 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
178 pass "step to end of run 2"
179 gdb_test "c" ".*" "continue after exit"
180 }
181 timeout { fail "(timeout) step to end of run" }
182 }
183
7a292a7a
SS
184 set timeout $old_timeout
185
186 gdb_test "n" ".*The program is not being run.*" "don't step after run"
187
188 set exec_output [remote_exec host "ls core"]
189
190
191 if [ regexp "core not found" $exec_output] {
c906108c 192 pass "No core dumped on quit"
c906108c 193 } else {
7a292a7a
SS
194 if [ regexp "No such file or directory" $exec_output] {
195 pass "ls: core: No core dumped on quit"
196 } else {
c906108c
SS
197 remote_exec build "rm -f core"
198 fail "Core dumped on quit"
7a292a7a 199 }
c906108c
SS
200 }
201}
202
203#remote_exec build "rm -f ${binfile}"
204return 0
205
206
207
208
This page took 0.039898 seconds and 4 git commands to generate.