1 # Copyright (C) 1992, 1996 Free Software Foundation, Inc.
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.
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.
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. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Jeff Law. (law@cs.utah.edu)
29 set testfile "recurse"
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33 perror "Couldn't compile ${srcfile}"
37 # Start with a fresh gdb.
41 gdb_reinitialize_dir $srcdir/$subdir
44 proc recurse_tests {} {
46 if [runto recurse] then {
47 # First we need to step over the assignment of b, so it has a known
49 gdb_test "next" "if \\(a == 1\\)" "next over b = 0 in first instance"
50 gdb_test "watch b" ".*\[Ww\]atchpoint \[0-9]*: b" \
51 "set first instance watchpoint"
53 # Continue until initial set of b.
54 if [gdb_test "continue" \
55 "Continuing.*\[Ww\]atchpoint.*: b.*Old value = 0.*New value = 10.*" \
56 "continue to first instance watchpoint, first time"] then {
60 # Continue inward for a few iterations
61 gdb_test "continue" "Breakpoint.* recurse \\(a=9\\).*" \
62 "continue to recurse (a = 9)"
63 gdb_test "continue" "Breakpoint.* recurse \\(a=8\\).*" \
64 "continue to recurse (a = 8)"
65 gdb_test "continue" "Breakpoint.* recurse \\(a=7\\).*" \
66 "continue to recurse (a = 7)"
67 gdb_test "continue" "Breakpoint.* recurse \\(a=6\\).*" \
68 "continue to recurse (a = 6)"
69 gdb_test "continue" "Breakpoint.* recurse \\(a=5\\).*" \
70 "continue to recurse (a = 5)"
72 # Put a watchpoint on another instance of b
73 # First we need to step over the assignment of b, so it has a known
75 gdb_test "next" "if \\(a == 1\\)" "next over b = 0 in second instance"
76 gdb_test "watch b" ".*\[Ww\]atchpoint \[0-9]*: b" \
77 "set second instance watchpoint"
79 # Continue until initial set of b (second instance).
80 if [gdb_test "continue" \
81 "Continuing.*\[Ww\]atchpoint.*: b.*Old value = 0.*New value = 5.*"\
82 "continue to second instance watchpoint, first time"] then {
86 # Continue inward for a few iterations
87 gdb_test "continue" "Breakpoint.* recurse \\(a=4\\).*" \
88 "continue to recurse (a = 4)"
89 gdb_test "continue" "Breakpoint.* recurse \\(a=3\\).*" \
90 "continue to recurse (a = 3)"
91 gdb_test "continue" "Breakpoint.* recurse \\(a=2\\).*" \
92 "continue to recurse (a = 2)"
93 gdb_test "continue" "Breakpoint.* recurse \\(a=1\\).*" \
94 "continue to recurse (a = 1)"
96 # Continue until second set of b (second instance).
97 if [gdb_test "continue" \
98 "Continuing.*\[Ww\]atchpoint.*: b.*Old value = 5.*New value = 120.*return.*" \
99 "continue to second instance watchpoint, second time"] then {
103 # Continue again. We should have a watchpoint go out of scope now
104 if [gdb_test "continue" \
105 "Continuing.*\[Ww\]atchpoint.*deleted.*recurse \\(a=6\\) .*" \
106 "second instance watchpoint deleted when leaving scope"] then {
110 # Continue until second set of b (first instance).
111 if [gdb_test "continue" \
112 "Continuing.*\[Ww\]atchpoint.*b.*Old value = 10.*New value = 3628800.*return.*" \
113 "continue to first instance watchpoint, second time"] then {
117 # Continue again. We should have a watchpoint go out of scope now
118 if [gdb_test "continue" \
119 "Continuing.*\[Ww\]atchpoint.*deleted.*main \\(\\) .*" \
120 "first instance watchpoint deleted when leaving scope"] then {
126 # Only enabled for some targets merely because it has not been tested
128 if {[istarget "sparc*-*-sunos4*"] || [istarget "hppa*-*-bsd*"] || [istarget "sparclet-*-*"] || [istarget "m32r-*-elf"] || [istarget "mn10200-*-*"]} then {
130 # Preserve the old timeout, and set a new one that should be
131 # sufficient to avoid timing out during this test.
132 set oldtimeout $timeout
133 set timeout [expr "$timeout + 60"]
134 verbose "Timeout is now $timeout seconds" 2
138 # Restore the preserved old timeout value.
139 set timeout $oldtimeout
140 verbose "Timeout is now $timeout seconds" 2