* gdb.base/break.exp: Increase timeout for slow TX39 boards.
[binutils-gdb.git] / gdb / testsuite / gdb.base / break.exp
1 # Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 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 # This file was written by Rob Savoye. (rob@cygnus.com)
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26
27 #
28 # test running programs
29 #
30 set prms_id 0
31 set bug_id 0
32
33 set testfile "break"
34 set srcfile ${testfile}.c
35 set binfile ${objdir}/${subdir}/${testfile}
36 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
37 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
38 }
39
40 gdb_exit
41 gdb_start
42 gdb_reinitialize_dir $srcdir/$subdir
43 gdb_load ${binfile}
44
45 if [target_info exists gdb_stub] {
46 gdb_step_for_stub;
47 }
48 #
49 # test simple breakpoint setting commands
50 #
51
52 # Test deleting all breakpoints when there are none installed.
53 # Between 4.15 and 4.16 a change made gdb stop prompting when
54 # there are no user breakpoints installed.
55 # Note that gdb-init.exp provides a "delete_breakpoints" proc
56 # for general use elsewhere.
57
58 send_gdb "delete breakpoints\n"
59 gdb_expect {
60 -re "Delete all breakpoints.*$" {
61 send_gdb "y\n"
62 gdb_expect {
63 -re "$gdb_prompt $" {
64 setup_xfail "i*86-*-sysv4*" "sparc-sun-sunos4*" "alpha-dec-osf*" "mips-dec-ultrix*"
65 fail "Delete all breakpoints when none (unexpected prompt)"
66 }
67 timeout { fail "Delete all breakpoints when none (timeout after unexpected prompt)" }
68 }
69 }
70 -re ".*$gdb_prompt $" { pass "Delete all breakpoints when none" }
71 timeout { fail "Delete all breakpoints when none (timeout)" }
72 }
73
74 #
75 # test break at function
76 #
77 gdb_test "break main" \
78 "Breakpoint.*at.* file .*$srcfile, line.*" \
79 "breakpoint function"
80
81 #
82 # test break at function in file
83 #
84 gdb_test "break $srcfile:factorial" \
85 "Breakpoint.*at.* file .*$srcfile, line.*" \
86 "breakpoint function in file"
87
88 #
89 # test break at line number
90 #
91 gdb_test "break 64" \
92 "Breakpoint.*at.* file .*$srcfile, line 64\\." \
93 "breakpoint line number"
94
95 #
96 # test duplicate breakpoint
97 #
98 gdb_test "break 64" \
99 "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line 64\\." \
100 "breakpoint duplicate"
101
102 #
103 # test break at line number in file
104 #
105 gdb_test "break $srcfile:70" \
106 "Breakpoint.*at.* file .*$srcfile, line 70\\." \
107 "breakpoint line number in file"
108
109
110 #
111 # check to see what breakpoints are set
112 #
113 if [target_info exists gdb_stub] {
114 set main_line 57
115 } else {
116 set main_line 60
117 }
118
119 gdb_test "info break" \
120 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
121 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
122 \[0-9\]+\[\t \]+breakpoint keep y.* in factorial at .*$srcfile:76.*
123 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:64.*
124 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:64.*
125 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:70" \
126 "breakpoint info"
127
128
129 # FIXME: The rest of this test doesn't work with anything that can't
130 # handle arguments.
131 # Huh? There doesn't *appear* to be anything that passes arguments
132 # below.
133 if [istarget "mips-idt-*"] then {
134 return
135 }
136
137 #
138 # run until the breakpoint at main is hit. For non-stubs-using targets.
139 #
140 if ![target_info exists use_gdb_stub] {
141 if [istarget "*-*-vxworks*"] then {
142 send_gdb "run vxmain \"2\"\n"
143 set timeout 120
144 verbose "Timeout is now $timeout seconds" 2
145 } else {
146 send_gdb "run\n"
147 }
148 gdb_expect {
149 -re "The program .* has been started already.*y or n. $" {
150 send_gdb "y\n"
151 exp_continue
152 }
153 -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:60.*60\[\t \]+if .argc.* \{.*$gdb_prompt $"\
154 { pass "run until function breakpoint" }
155 -re ".*$gdb_prompt $" { fail "run until function breakpoint" }
156 timeout { fail "run until function breakpoint (timeout)" }
157 }
158 } else {
159 if ![target_info exists gdb_stub] {
160 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:60.*60\[\t \]+if .argc.*\{" "stub continue"
161 }
162 }
163
164 #
165 # run until the breakpoint at a line number
166 #
167 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:64.*64\[\t \]+printf.*factorial.*" \
168 "run until breakpoint set at a line number"
169
170 #
171 # Run until the breakpoint set in a function in a file
172 #
173 for {set i 6} {$i >= 1} {incr i -1} {
174 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:76.*76\[\t \]+if .value > 1. \{" \
175 "run until file:function($i) breakpoint"
176 }
177
178 #
179 # run until the file:function breakpoint at a line number in a file
180 #
181 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:70.*70\[\t \]+return 0;" \
182 "run until file:linenum breakpoint"
183
184 #
185 # delete all breakpoints so we can start over, course this can be a test too
186 #
187 delete_breakpoints
188
189 #
190 # test temporary breakpoint at function
191 #
192
193 gdb_test "tbreak main" "Breakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function"
194
195 #
196 # test break at function in file
197 #
198
199 gdb_test "tbreak $srcfile:factorial" "Breakpoint.*at.* file .*$srcfile, line.*" \
200 "Temporary breakpoint function in file"
201
202 #
203 # test break at line number
204 #
205 send_gdb "tbreak 64\n"
206 gdb_expect {
207 -re "Breakpoint.*at.* file .*$srcfile, line 64.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
208 -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
209 timeout { fail "breakpoint line number #1 (timeout)" }
210 }
211
212 gdb_test "tbreak 60" "Breakpoint.*at.* file .*$srcfile, line 60.*" "Temporary breakpoint line number #2"
213
214 #
215 # test break at line number in file
216 #
217 send_gdb "tbreak $srcfile:70\n"
218 gdb_expect {
219 -re "Breakpoint.*at.* file .*$srcfile, line 70.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
220 -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
221 timeout { fail "Temporary breakpoint line number in file #1 (timeout)" }
222 }
223
224 gdb_test "tbreak $srcfile:66" "Breakpoint.*at.* file .*$srcfile, line 66.*" "Temporary breakpoint line number in file #2"
225
226 #
227 # check to see what breakpoints are set (temporary this time)
228 #
229 gdb_test "info break" "Num Type.*Disp Enb Address.*What.*\[\r\n\]\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\]\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial at .*$srcfile:76.*\[\r\n\]\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:64.*\[\r\n\]\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:70.*" "Temporary breakpoint info"
230
231 proc test_clear_command {} {
232 gdb_test "break main" "Breakpoint.*at.*" "break main #1"
233 gdb_test "break main" "Breakpoint.*at.*" "break main #2"
234
235 # We don't test that it deletes the correct breakpoints. We do at
236 # least test that it deletes more than one breakpoint.
237 gdb_test "clear main" {Deleted breakpoints [0-9]+ [0-9]+.*}
238 }
239
240 #
241 # Test "next" over recursive function call.
242 #
243
244 proc test_next_with_recursion {} {
245 global gdb_prompt
246 global decimal
247 global binfile
248
249 if [istarget "d10v-*-*"] {
250 # Doesn't work right now.
251 gdb_suppress_tests;
252 }
253 if [target_info exists use_gdb_stub] {
254 # Reload the program.
255 delete_breakpoints
256 gdb_load ${binfile};
257 } else {
258 # FIXME: should be using runto
259 gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
260
261 delete_breakpoints
262 }
263
264 gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
265
266 # Run until we call factorial with 6
267
268 if [istarget "*-*-vxworks*"] then {
269 send_gdb "run vxmain \"6\"\n"
270 } else {
271 gdb_run_cmd
272 }
273 gdb_expect {
274 -re "Break.* factorial .value=6. .*$gdb_prompt $" {}
275 -re ".*$gdb_prompt $" {
276 fail "run to factorial(6)";
277 gdb_suppress_tests;
278 }
279 timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests }
280 }
281
282 # Continue until we call factorial recursively with 5.
283
284 send_gdb "continue\n"
285 gdb_expect {
286 -re "Continuing.*Break.* factorial .value=5. .*$gdb_prompt $" {}
287 timeout { fail "continue to factorial(5) (timeout)" ; gdb_suppress_tests }
288 }
289
290 # Do a backtrace just to confirm how many levels deep we are.
291
292 set result [gdb_test "backtrace" \
293 "#0\[ \t\]+ factorial .value=5..*" \
294 "backtrace from factorial(5)"]
295 if $result!=0 then { gdb_suppress_tests }
296
297 # Now a "next" should position us at the recursive call, which
298 # we will be performing with 4.
299
300 send_gdb "next\n"
301 gdb_expect {
302 -re ".* factorial .value - 1.;.*$gdb_prompt $" {}
303 timeout { fail "next to recursive call (timeout)" ; gdb_suppress_tests }
304 }
305
306 # Disable the breakpoint at the entry to factorial by deleting them all.
307 # The "next" should run until we return to the next line from this
308 # recursive call to factorial with 4.
309 # Buggy versions of gdb will stop instead at the innermost frame on
310 # the line where we are trying to "next" to.
311
312 delete_breakpoints
313
314 if [istarget "mips*tx39-*"] {
315 set timeout 60
316 } else {
317 set timeout 20
318 }
319
320 gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \
321 "next over recursive call"
322
323 # OK, we should be back in the same stack frame we started from.
324 # Do a backtrace just to confirm.
325
326 set result [gdb_test "backtrace" \
327 "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \
328 "backtrace from factorial(5.1)"]
329 if { $result != 0 } { gdb_suppress_tests }
330
331 if [target_info exists gdb,noresults] { gdb_suppress_tests }
332 if [target_info exists use_gdb_stub] {
333 gdb_breakpoint "exit"
334 gdb_test "continue" "Continuing..*Breakpoint .*exit \[(\].*=0\[)\].*" "continue until exit in recursive next test"
335 } else {
336 # Continue until we exit. Should not stop again.
337 # Don't bother to check the output of the program, that may be
338 # extremely tough for some remote systems.
339 gdb_test "continue"\
340 "Continuing.\[\r\n0-9\]+Program exited normally\\..*"\
341 "continue until exit in recursive next test"
342 }
343 gdb_stop_suppressing_tests;
344 }
345
346 test_clear_command
347 test_next_with_recursion
348
349 # Reset the default arguments for VxWorks
350 if [istarget "*-*-vxworks*"] {
351 set timeout 10
352 verbose "Timeout is now $timeout seconds" 2
353 send_gdb "set args main\n"
354 gdb_expect -re ".*$gdb_prompt $" {}
355 }