]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | # | |
b84b7669 MS |
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.*" | |
c906108c SS |
60 | |
61 | # Set up to go to the next-to-last line of the program | |
62 | # | |
b84b7669 | 63 | gdb_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 | 68 | if [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 |
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" } | |
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 |
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" | |
c906108c | 87 | |
b84b7669 | 88 | send_gdb "inf line ending-run.c:13\n" |
c906108c SS |
89 | gdb_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 | 100 | send_gdb "inf line ending-run.c:14\n" |
c906108c SS |
101 | gdb_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 | ||
114 | send_gdb "i b\n" | |
115 | gdb_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 | 131 | gdb_test "cont" ".*Breakpoint.*31.*" |
085dd6e6 | 132 | gdb_test "next" ".*1 2 7 14 23 34 47 62 79 Goodbye!.*32.*" "Step to return" |
c906108c SS |
133 | |
134 | set old_timeout $timeout | |
135 | set timeout 50 | |
136 | send_gdb "next\n" | |
137 | gdb_expect { | |
085dd6e6 | 138 | -re "33.*$gdb_prompt $" { |
c906108c SS |
139 | # sometimes we stop at the closing brace, if so, do another next |
140 | send_gdb "next\n" | |
141 | gdb_expect { | |
142 | -re ".*Unable to find return pc for this frame.*$gdb_prompt $" { | |
143 | fail "Old bug came back!" | |
144 | gdb_test "n" ".*" "" | |
145 | } | |
146 | -re ".*in.*start.*$gdb_prompt $" { | |
147 | pass "step out of main" | |
148 | } | |
b84b7669 MS |
149 | -re ".*in.*init.*$gdb_prompt $" { |
150 | # This is what happens on sparc64-elf ultra. | |
151 | pass "step out of main" | |
152 | } | |
104c1213 JM |
153 | -re ".*in .nope ().*$gdb_prompt $" { |
154 | # This is what happens on Solaris currently -sts 1999-08-25 | |
155 | pass "step out of main on Solaris" | |
156 | } | |
8b93c638 JM |
157 | -re ".*in ..change.mode ().*$gdb_prompt $" { |
158 | # This is what happens on ARM in thumb mode -fn 2000-02-01 | |
159 | pass "step out of main on ARM thumb" | |
160 | } | |
085dd6e6 JM |
161 | -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { |
162 | pass "step out of main" | |
163 | } | |
0f71a2f6 | 164 | -re ".*$gdb_prompt $" { fail "step at end 2" } |
c906108c SS |
165 | timeout { fail "hang or timeout on step at end 2" } |
166 | } | |
167 | } | |
168 | -re ".*Unable to find return pc for this frame.*$gdb_prompt $" { | |
169 | fail "Old bug came back!" | |
170 | gdb_test "n" ".*" "" | |
171 | } | |
172 | -re ".*in.*start.*$gdb_prompt $" { | |
173 | pass "step out of main" | |
174 | } | |
085dd6e6 JM |
175 | -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { |
176 | pass "step out of main 2" | |
177 | } | |
cce74817 JM |
178 | -re ".*in.*currently asm.*$gdb_prompt $" { |
179 | pass "step out of main into assembler" | |
180 | } | |
181 | -re ".*Program received signal SIGTRAP.*$gdb_prompt $" { | |
7a292a7a | 182 | pass "Cygmon stopped in ending trap." |
cce74817 | 183 | } |
0f71a2f6 | 184 | -re ".*$gdb_prompt $" { fail "step at end 1" } |
c906108c SS |
185 | timeout { fail "hang or timeout on step at end 1" } |
186 | } | |
187 | ||
7a292a7a | 188 | if {![target_info exists use_cygmon] || ![target_info use_cygmon]} { |
085dd6e6 JM |
189 | send_gdb "n\n" |
190 | gdb_expect { | |
c2d11a7d JM |
191 | -re "Program exited normally.*$gdb_prompt $" { |
192 | # If we actually have debug info for the start function, | |
193 | # then we won't get the "Single-stepping until function | |
194 | # exit" message. | |
195 | pass "step to end of run 1" | |
196 | } | |
085dd6e6 JM |
197 | -re ".*Single.*Program exited.*$gdb_prompt $" { |
198 | pass "step to end of run 1" | |
199 | } | |
200 | -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" { | |
201 | pass "step to end of run 2" | |
202 | gdb_test "c" ".*" "continue after exit" | |
203 | } | |
204 | timeout { fail "(timeout) step to end of run" } | |
205 | } | |
206 | ||
7a292a7a SS |
207 | set timeout $old_timeout |
208 | ||
209 | gdb_test "n" ".*The program is not being run.*" "don't step after run" | |
210 | ||
211 | set exec_output [remote_exec host "ls core"] | |
212 | ||
213 | ||
214 | if [ regexp "core not found" $exec_output] { | |
c906108c | 215 | pass "No core dumped on quit" |
c906108c | 216 | } else { |
7a292a7a SS |
217 | if [ regexp "No such file or directory" $exec_output] { |
218 | pass "ls: core: No core dumped on quit" | |
219 | } else { | |
c906108c SS |
220 | remote_exec build "rm -f core" |
221 | fail "Core dumped on quit" | |
7a292a7a | 222 | } |
c906108c SS |
223 | } |
224 | } | |
225 | ||
226 | #remote_exec build "rm -f ${binfile}" | |
227 | return 0 | |
228 | ||
229 | ||
230 | ||
231 |