OSDN Git Service

import gdb-19990422 snapshot
[pf3gnuchains/pf3gnuchains4x.git] / gdb / testsuite / gdb.base / break.exp
1 #   Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997, 1998
2 #   Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
20
21 # This file was written by Rob Savoye. (rob@cygnus.com)
22
23 if $tracelevel then {
24     strace $tracelevel
25 }
26
27
28 #
29 # test running programs
30 #
31 set prms_id 0
32 set bug_id 0
33
34 set testfile "break"
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37
38 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
39     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
40 }
41
42 gdb_exit
43 gdb_start
44 gdb_reinitialize_dir $srcdir/$subdir
45 gdb_load ${binfile}
46
47 if [target_info exists gdb_stub] {
48     gdb_step_for_stub;
49 }
50 #
51 # test simple breakpoint setting commands
52 #
53
54 # Test deleting all breakpoints when there are none installed,
55 # GDB should not prompt for confirmation.
56 # Note that gdb-init.exp provides a "delete_breakpoints" proc
57 # for general use elsewhere.
58
59 send_gdb "delete breakpoints\n"
60 gdb_expect {
61      -re "Delete all breakpoints.*$" {
62             send_gdb "y\n"
63             gdb_expect {
64                 -re "$gdb_prompt $" {
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
232 #***********
233
234 # Verify that catchpoints for fork, vfork and exec don't trigger
235 # inappropriately.  (There are no calls to those system functions
236 # in this test program.)
237 #
238 if ![runto_main] then { fail "break tests suppressed" }
239
240 send_gdb "catch\n"
241 gdb_expect {
242   -re "Catch requires an event name.*$gdb_prompt $"\
243           {pass "catch requires an event name"}
244   -re "$gdb_prompt $"\
245           {fail "catch requires an event name"}
246   timeout {fail "(timeout) catch requires an event name"}
247 }
248
249
250 set name "set catch fork, never expected to trigger"
251 send_gdb "catch fork\n"
252 gdb_expect {
253   -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $"
254           {pass $name}
255   -re "Catch of fork not yet implemented.*$gdb_prompt $"
256           {pass $name}
257   -re "$gdb_prompt $"
258           {fail $name}
259   timeout {fail "(timeout) $name"}
260 }
261
262
263 set name "set catch vfork, never expected to trigger"
264 send_gdb "catch vfork\n"
265
266 # If we are on HP-UX 10.20, we expect an error message to be
267 # printed if we type "catch vfork" at the gdb gdb_prompt.  This is
268 # because on HP-UX 10.20, we cannot catch vfork events.
269
270 if [istarget "hppa*-hp-hpux10.20"] then {
271     gdb_expect {
272         -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $"
273                 {pass $name}
274         -re "$gdb_prompt $"
275                 {fail $name}
276         timeout {fail "(timeout) $name"}
277     }
278 } else {
279     gdb_expect {
280         -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $"
281                 {pass $name}
282         -re "Catch of vfork not yet implemented.*$gdb_prompt $"
283                 {pass $name}
284         -re "$gdb_prompt $"
285                 {fail $name}
286         timeout {fail "(timeout) $name"}
287     }
288 }
289
290 set name "set catch exec, never expected to trigger"
291 send_gdb "catch exec\n"
292 gdb_expect {
293   -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $"
294           {pass $name}
295   -re "Catch of exec not yet implemented.*$gdb_prompt $"
296           {pass $name}
297   -re "$gdb_prompt $" {fail $name}
298   timeout {fail "(timeout) $name"}
299 }
300
301 # Verify that "until <location>" works.  (This is really just syntactic
302 # sugar for "tbreak <location>; continue".)
303 #
304 send_gdb "until 64\n"
305 gdb_expect {
306   -re "main .* at .*:64.*$gdb_prompt $"\
307           {pass "until 64"}
308   -re "$gdb_prompt $"\
309           {fail "until 64"}
310   timeout {fail "(timeout) until 64"}
311 }
312
313 # Verify that a malformed "until" is gracefully caught.
314 #
315 send_gdb "until 65 then stop\n"
316 gdb_expect {
317   -re "Junk at end of arguments..*$gdb_prompt $"\
318           {pass "malformed until"}
319   -re "$gdb_prompt $"\
320           {fail "malformed until"}
321   timeout {fail "(timeout) malformed until"}
322 }
323
324 # Verify that GDB responds gracefully when asked to set a breakpoint
325 # on a nonexistent source line.
326 #
327 send_gdb "break 999\n"
328 gdb_expect {
329   -re "No line 999 in file .*$gdb_prompt $"\
330           {pass "break on non-existent source line"}
331   -re "$gdb_prompt $"\
332           {fail "break on non-existent source line"}
333   timeout {fail "(timeout) break on non-existent source line"}
334 }
335
336 # Verify that GDB allows one to just say "break", which is treated
337 # as the "default" breakpoint.  Note that GDB gets cute when printing
338 # the informational message about other breakpoints at the same
339 # location.  We'll hit that bird with this stone too.
340 #
341 send_gdb "break\n"
342 gdb_expect {
343   -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\
344           {pass "break on default location, 1st time"}
345   -re "$gdb_prompt $"\
346           {fail "break on default location, 1st time"}
347   timeout {fail "(timeout) break on default location, 1st time"}
348 }
349
350 send_gdb "break\n"
351 gdb_expect {
352   -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
353           {pass "break on default location, 2nd time"}
354   -re "$gdb_prompt $"\
355           {fail "break on default location, 2nd time"}
356   timeout {fail "(timeout) break on default location, 2nd time"}
357 }
358
359 send_gdb "break\n"
360 gdb_expect {
361   -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
362           {pass "break on default location, 3rd time"}
363   -re "$gdb_prompt $"\
364           {fail "break on default location, 3rd time"}
365   timeout {fail "(timeout) break on default location, 3rd time"}
366 }
367
368 send_gdb "break\n"
369 gdb_expect {
370   -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
371           {pass "break on default location, 4th time"}
372   -re "$gdb_prompt $"\
373           {fail "break on default location, 4th time"}
374   timeout {fail "(timeout) break on default location, 4th time"}
375 }
376
377 # Verify that a "silent" breakpoint can be set, and that GDB is indeed
378 # "silent" about its triggering.
379 #
380 if ![runto_main] then { fail "break tests suppressed" }
381
382 send_gdb "break 64\n"
383 gdb_expect {
384   -re "Breakpoint (\[0-9\]*) at .*, line 64.*$gdb_prompt $"\
385           {pass "set to-be-silent break 64"}
386   -re "$gdb_prompt $"\
387           {fail "set to-be-silent break 64"}
388   timeout {fail "(timeout) set to-be-silent break 64"}
389 }
390
391 send_gdb "commands $expect_out(1,string)\n"
392 send_gdb "silent\n"
393 send_gdb "end\n"
394 gdb_expect {
395   -re ".*$gdb_prompt $"\
396           {pass "set silent break 64"}
397   timeout {fail "(timeout) set silent break 64"}
398 }
399
400 send_gdb "info break $expect_out(1,string)\n"
401 gdb_expect {
402   -re "\[0-9\]*\[ \t\]*breakpoint.*:64\r\n\[ \t\]*silent.*$gdb_prompt $"\
403           {pass "info silent break 64"}
404   -re "$gdb_prompt $"\
405           {fail "info silent break 64"}
406   timeout {fail "(timeout) info silent break 64"}
407 }
408 send_gdb "continue\n"
409 gdb_expect {
410   -re "Continuing.\r\n$gdb_prompt $"\
411           {pass "hit silent break 64"}
412   -re "$gdb_prompt $"\
413           {fail "hit silent break 64"}
414   timeout {fail "(timeout) hit silent break 64"}
415 }
416 send_gdb "bt\n"
417 gdb_expect {
418   -re "#0  main .* at .*:64.*$gdb_prompt $"\
419           {pass "stopped for silent break 64"}
420   -re "$gdb_prompt $"\
421           {fail "stopped for silent break 64"}
422   timeout {fail "(timeout) stopped for silent break 64"}
423 }
424
425 # Verify that GDB can at least parse a breakpoint with the
426 # "thread" keyword.  (We won't attempt to test here that a
427 # thread-specific breakpoint really triggers appropriately.
428 # The gdb.threads subdirectory contains tests for that.)
429 #
430 send_gdb "break 65 thread 999\n"
431 gdb_expect {
432   -re "Unknown thread 999.*$gdb_prompt $"\
433           {pass "thread-specific breakpoint on non-existent thread disallowed"}
434   -re "$gdb_prompt $"\
435           {fail "thread-specific breakpoint on non-existent thread disallowed"}
436   timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"}
437 }
438 send_gdb "break 65 thread foo\n"
439 gdb_expect {
440   -re "Junk after thread keyword..*$gdb_prompt $"\
441           {pass "thread-specific breakpoint on bogus thread ID disallowed"}
442   -re "$gdb_prompt $"\
443           {fail "thread-specific breakpoint on bogus thread ID disallowed"}
444   timeout {fail "(timeout) thread-specific breakpoint on bogus thread ID disallowed"}
445 }
446
447 # Verify that GDB responds gracefully to a breakpoint command with
448 # trailing garbage.
449 #
450 send_gdb "break 65 foo\n"
451 gdb_expect {
452   -re "Junk at end of arguments..*$gdb_prompt $"\
453           {pass "breakpoint with trailing garbage disallowed"}
454   -re "$gdb_prompt $"\
455           {fail "breakpoint with trailing garbage disallowed"}
456   timeout {fail "(timeout) breakpoint with trailing garbage disallowed"}
457 }
458
459 # Verify that GDB responds gracefully to a "clear" command that has
460 # no matching breakpoint.  (First, get us off the current source line,
461 # which we know has a breakpoint.)
462 #
463 send_gdb "next\n"
464 gdb_expect {
465   -re ".*$gdb_prompt $"\
466           {pass "step over breakpoint"}
467   timeout {fail "(timeout) step over breakpoint"}
468 }
469 send_gdb "clear 66\n"
470 gdb_expect {
471   -re "No breakpoint at 66..*$gdb_prompt $"\
472           {pass "clear line has no breakpoint disallowed"}
473   -re "$gdb_prompt $"\
474           {fail "clear line has no breakpoint disallowed"}
475   timeout {fail "(timeout) clear line has no breakpoint disallowed"}
476 }
477 send_gdb "clear\n"
478 gdb_expect {
479   -re "No breakpoint at this line..*$gdb_prompt $"\
480           {pass "clear current line has no breakpoint disallowed"}
481   -re "$gdb_prompt $"\
482           {fail "clear current line has no breakpoint disallowed"}
483   timeout {fail "(timeout) clear current line has no breakpoint disallowed"}
484 }
485
486 # Verify that a breakpoint can be set via a convenience variable.
487 #
488 send_gdb "set \$foo=66\n"
489 gdb_expect {
490   -re "$gdb_prompt $"\
491           {pass "set convenience variable \$foo to 66"}
492   timeout {fail "(timeout) set convenience variable \$foo to 66"}
493 }
494 send_gdb "break \$foo\n"
495 gdb_expect {
496   -re "Breakpoint (\[0-9\]*) at .*, line 66.*$gdb_prompt $"\
497           {pass "set breakpoint via convenience variable"}
498   -re "$gdb_prompt $"\
499           {fail "set breakpoint via convenience variable"}
500   timeout {fail "(timeout) set breakpoint via convenience variable"}
501 }
502
503 # Verify that GDB responds gracefully to an attempt to set a
504 # breakpoint via a convenience variable whose type is not integer.
505 #
506 send_gdb "set \$foo=66.5\n"
507 gdb_expect {
508   -re "$gdb_prompt $"\
509           {pass "set convenience variable \$foo to 66.5"}
510   timeout {fail "(timeout) set convenience variable \$foo to 66.5"}
511 }
512 send_gdb "break \$foo\n"
513 gdb_expect {
514   -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\
515           {pass "set breakpoint via non-integer convenience variable disallowed"}
516   -re "$gdb_prompt $"\
517           {fail "set breakpoint via non-integer convenience variable disallowed"}
518   timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"}
519 }
520
521 # Verify that we can set and trigger a breakpoint in a user-called function.
522 #
523 send_gdb "break marker2\n"
524 gdb_expect {
525   -re "Breakpoint (\[0-9\]*) at .*, line 42.*$gdb_prompt $"\
526           {pass "set breakpoint on to-be-called function"}
527   -re "$gdb_prompt $"\
528           {fail "set breakpoint on to-be-called function"}
529   timeout {fail "(timeout) set breakpoint on to-be-called function"}
530 }
531 send_gdb "print marker2(99)\n"
532 gdb_expect {
533   -re "The program being debugged stopped while in a function called from GDB.\r\nWhen the function .marker2. is done executing, GDB will silently\r\nstop .instead of continuing to evaluate the expression containing\r\nthe function call...*$gdb_prompt $"\
534           {pass "hit breakpoint on called function"}
535   -re "$gdb_prompt $"\
536           {fail "hit breakpoint on called function"}
537   timeout {fail "(timeout) hit breakpoint on called function"}
538 }
539
540 # As long as we're stopped (breakpointed) in a called function,
541 # verify that we can successfully backtrace & such from here.
542 #
543 if [istarget "hppa*-*-hpux*"] then {
544   send_gdb "bt\n"
545   gdb_expect {
546     -re "#0\[ \t\]*marker2.*:42\r\n#1.*_sr4export.*$gdb_prompt $"\
547             {pass "backtrace while in called function"}
548     -re "$gdb_prompt $"\
549             {fail "backtrace while in called function"}
550     timeout {fail "(timeout) backtrace while in called function"}
551   }
552   send_gdb "finish\n"
553   gdb_expect {
554     -re "Run till exit from .*marker2.* at .*42\r\n.* in _sr4export.*$gdb_prompt $"\
555             {pass "finish from called function"}
556     -re "$gdb_prompt $"\
557             {fail "finish from called function"}
558     timeout {fail "(timeout) finish from called function"}
559   }
560 }
561
562 # Verify that GDB responds gracefully to a "finish" command with
563 # arguments.
564 #
565 if ![runto_main] then { fail "break tests suppressed" }
566
567 send_gdb "finish 123\n"
568 gdb_expect {
569   -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\
570           {pass "finish with arguments disallowed"}
571   -re "$gdb_prompt $"\
572           {fail "finish with arguments disallowed"}
573   timeout {fail "(timeout) finish with arguments disallowed"}
574 }
575
576 # Verify that GDB responds gracefully to a request to "finish" from
577 # the outermost frame.  On a stub that never exits, this will just
578 # run to the stubs routine, so we don't get this error...  Thus the 
579 # second condition.
580 #
581
582 send_gdb "finish\n"
583 gdb_expect {
584   -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\
585           {pass "finish from outermost frame disallowed"}
586   -re "Run till exit from.*" {
587      pass "finish from outermost frame disallowed"
588   }
589   -re "$gdb_prompt $"\
590           {fail "finish from outermost frame disallowed"}
591   timeout {fail "(timeout) finish from outermost frame disallowed"}
592 }
593
594 # Verify that we can explicitly ask GDB to stop on all shared library
595 # events, and that it does so.
596 #
597 if [istarget "hppa*-*-hpux*"] then {
598   if ![runto_main] then { fail "break tests suppressed" }
599
600   send_gdb "set stop-on-solib-events 1\n"
601   gdb_expect {
602     -re "$gdb_prompt $"\
603             {pass "set stop-on-solib-events"}
604     timeout {fail "(timeout) set stop-on-solib-events"}
605   }
606
607   send_gdb "run\n"
608   gdb_expect {
609     -re ".*Start it from the beginning.*y or n. $"\
610             {send_gdb "y\n"
611              gdb_expect {
612                -re ".*Stopped due to shared library event.*$gdb_prompt $"\
613                        {pass "triggered stop-on-solib-events"}
614                -re "$gdb_prompt $"\
615                        {fail "triggered stop-on-solib-events"}
616                timeout {fail "(timeout) triggered stop-on-solib-events"}
617              }
618             }
619     -re "$gdb_prompt $"\
620             {fail "rerun for stop-on-solib-events"}
621     timeout {fail "(timeout) rerun for stop-on-solib-events"}
622   }
623
624   send_gdb "set stop-on-solib-events 0\n"
625   gdb_expect {
626     -re "$gdb_prompt $"\
627             {pass "reset stop-on-solib-events"}
628     timeout {fail "(timeout) reset stop-on-solib-events"}
629   }
630 }
631
632 # Hardware breakpoints are unsupported on HP-UX.  Verify that GDB
633 # gracefully responds to requests to create them.
634 #
635 if [istarget "hppa*-*-hpux*"] then {
636   if ![runto_main] then { fail "break tests suppressed" }
637
638   send_gdb "hbreak\n"
639   gdb_expect {
640     -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
641             {pass "hw breaks disallowed"}
642     -re "$gdb_prompt $"\
643             {fail "hw breaks disallowed"}
644     timeout {fail "(timeout) hw breaks disallowed"}
645   }
646
647   send_gdb "thbreak\n"
648   gdb_expect {
649     -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
650             {pass "temporary hw breaks disallowed"}
651     -re "$gdb_prompt $"\
652             {fail "temporary hw breaks disallowed"}
653     timeout {fail "(timeout) temporary hw breaks disallowed"}
654   }
655 }
656
657 #********
658
659
660 proc test_clear_command {} {
661     gdb_test "break main" "Breakpoint.*at.*" "break main #1"
662     gdb_test "break main" "Breakpoint.*at.*" "break main #2"
663
664     # We don't test that it deletes the correct breakpoints.  We do at
665     # least test that it deletes more than one breakpoint.
666     gdb_test "clear main" {Deleted breakpoints [0-9]+ [0-9]+.*}
667 }
668
669 #
670 # Test "next" over recursive function call.
671 #
672
673 proc test_next_with_recursion {} { 
674     global gdb_prompt
675     global decimal
676     global binfile
677
678     if [target_info exists use_gdb_stub] {
679         # Reload the program.
680         delete_breakpoints
681         gdb_load ${binfile};
682     } else {
683         # FIXME: should be using runto
684         gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
685
686         delete_breakpoints
687     }
688
689     gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
690
691     # Run until we call factorial with 6
692
693     if [istarget "*-*-vxworks*"] then {
694         send_gdb "run vxmain \"6\"\n"
695     } else {
696         gdb_run_cmd
697     }
698     gdb_expect {
699         -re "Break.* factorial .value=6. .*$gdb_prompt $" {}
700         -re ".*$gdb_prompt $" {
701             fail "run to factorial(6)";
702             gdb_suppress_tests;
703         }
704         timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests }
705     }
706
707     # Continue until we call factorial recursively with 5.
708
709     if [gdb_test "continue" \
710         "Continuing.*Break.* factorial .value=5. .*" \
711         "continue to factorial(5)"] then { gdb_suppress_tests }
712
713     # Do a backtrace just to confirm how many levels deep we are.
714
715     if [gdb_test "backtrace" \
716         "#0\[ \t\]+ factorial .value=5..*" \
717         "backtrace from factorial(5)"] then { gdb_suppress_tests }
718
719     # Now a "next" should position us at the recursive call, which
720     # we will be performing with 4.
721
722     if [gdb_test "next" \
723         ".* factorial .value - 1.;.*" \
724         "next to recursive call"] then { gdb_suppress_tests }
725
726     # Disable the breakpoint at the entry to factorial by deleting them all.
727     # The "next" should run until we return to the next line from this
728     # recursive call to factorial with 4.
729     # Buggy versions of gdb will stop instead at the innermost frame on
730     # the line where we are trying to "next" to.
731
732     delete_breakpoints
733
734     if [istarget "mips*tx39-*"] {
735         set timeout 60
736     } else {
737         set timeout 20
738     }
739
740     gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \
741             "next over recursive call"
742
743     # OK, we should be back in the same stack frame we started from.
744     # Do a backtrace just to confirm.
745
746     set result [gdb_test "backtrace" \
747             "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \
748             "backtrace from factorial(5.1)"]
749     if { $result != 0 } { gdb_suppress_tests }
750
751     if [target_info exists gdb,noresults] { gdb_suppress_tests }
752   gdb_continue_to_end "recursive next test"
753    gdb_stop_suppressing_tests;
754 }
755
756 test_clear_command
757 test_next_with_recursion
758
759 # Reset the default arguments for VxWorks
760 if [istarget "*-*-vxworks*"] {
761     set timeout 10
762     verbose "Timeout is now $timeout seconds" 2
763     send_gdb "set args main\n"
764     gdb_expect -re ".*$gdb_prompt $" {}
765 }