1 # Copyright (C) 1992 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 ${srcdir}/$subdir/${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if { [compile "${srcfile} -g -o ${binfile}"] != "" } {
33 perror "Couldn't compile ${srcfile}"
37 # Start with a fresh gdb.
41 gdb_reinitialize_dir $srcdir/$subdir
44 # Only enabled for some targets merely because it has not been tested
46 if {[istarget "sparc*-*-sunos4*"] || [istarget "hppa*-*-bsd*"]} then {
48 # Preserve the old timeout, and set a new one that should be
49 # sufficient to avoid timing out during this test.
51 if [runto recurse] then {
52 # First we need to step over the assignment of b, so it has a known
54 gdb_test "next" "if \\(a == 1\\)" "next over b = 0 in first instance"
55 gdb_test "watch b" ".*\[Ww\]atchpoint \[0-9]*: b" \
56 "set first instance watchpoint"
58 # Continue until initial set of b.
59 if [gdb_test "continue" \
60 "Continuing.*\[Ww\]atchpoint.*: b.*Old value = 0.*New value = 10.*" \
61 "continue to first instance watchpoint, first time"] then {
65 # Continue inward for a few iterations
66 gdb_test "continue" "Breakpoint.* recurse \\(a=9\\).*" \
67 "continue to recurse (a = 9)"
68 gdb_test "continue" "Breakpoint.* recurse \\(a=8\\).*" \
69 "continue to recurse (a = 8)"
70 gdb_test "continue" "Breakpoint.* recurse \\(a=7\\).*" \
71 "continue to recurse (a = 7)"
72 gdb_test "continue" "Breakpoint.* recurse \\(a=6\\).*" \
73 "continue to recurse (a = 6)"
74 gdb_test "continue" "Breakpoint.* recurse \\(a=5\\).*" \
75 "continue to recurse (a = 5)"
77 # Put a watchpoint on another instance of b
78 # First we need to step over the assignment of b, so it has a known
80 gdb_test "next" "if \\(a == 1\\)" "next over b = 0 in second instance"
81 gdb_test "watch b" ".*\[Ww\]atchpoint \[0-9]*: b" \
82 "set second instance watchpoint"
84 # Continue until initial set of b (second instance).
85 if [gdb_test "continue" \
86 "Continuing.*\[Ww\]atchpoint.*: b.*Old value = 0.*New value = 5.*"\
87 "continue to second instance watchpoint, first time"] then {
91 # Continue inward for a few iterations
92 gdb_test "continue" "Breakpoint.* recurse \\(a=4\\).*" \
93 "continue to recurse (a = 4)"
94 gdb_test "continue" "Breakpoint.* recurse \\(a=3\\).*" \
95 "continue to recurse (a = 3)"
96 gdb_test "continue" "Breakpoint.* recurse \\(a=2\\).*" \
97 "continue to recurse (a = 2)"
98 gdb_test "continue" "Breakpoint.* recurse \\(a=1\\).*" \
99 "continue to recurse (a = 1)"
101 # Continue until second set of b (second instance).
102 setup_xfail "sparc*-*-sunos4*"
103 if [gdb_test "continue" \
104 "Continuing.*\[Ww\]atchpoint.*: b.*Old value = 5.*New value = 120.*return.*" \
105 "continue to second instance watchpoint, second time"] then {
109 # Continue again. We should have a watchpoint go out of scope now
110 if [gdb_test "continue" \
111 "Continuing.*\[Ww\]atchpoint.*deleted.*recurse \\(a=6\\) .*" \
112 "second instance watchpoint deleted when leaving scope"] then {
116 # Continue until second set of b (first instance).
117 if [gdb_test "continue" \
118 "Continuing.*\[Ww\]atchpoint.*b.*Old value = 10.*New value = 3628800.*return.*" \
119 "continue to first instance watchpoint, second time"] then {
123 # Continue again. We should have a watchpoint go out of scope now
124 if [gdb_test "continue" \
125 "Continuing.*\[Ww\]atchpoint.*deleted.*main \\(\\) .*" \
126 "first instance watchpoint deleted when leaving scope"] then {
131 # Restore the preserved old timeout value.