]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/recurse.exp
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / recurse.exp
1 # Copyright (C) 1992, 1996 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 Jeff Law. (law@cs.utah.edu)
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 set prms_id 0
27 set bug_id 0
28
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}"
34 return -1
35 }
36
37 # Start with a fresh gdb.
38
39 gdb_exit
40 gdb_start
41 gdb_reinitialize_dir $srcdir/$subdir
42 gdb_load ${binfile}
43
44 proc recurse_tests {} {
45
46 if [runto recurse] then {
47 # First we need to step over the assignment of b, so it has a known
48 # value.
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"
52
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 {
57 return
58 }
59
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)"
71
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
74 # value.
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"
78
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 {
83 return
84 }
85
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)"
95
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 {
100 return
101 }
102
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 {
107 return
108 }
109
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 {
114 return
115 }
116
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 {
121 return
122 }
123 }
124 }
125
126 # Only enabled for some targets merely because it has not been tested
127 # elsewhere.
128 if {[istarget "sparc*-*-sunos4*"] || [istarget "hppa*-*-bsd*"] || [istarget "sparclet-*-*"] || [istarget "m32r-*-elf"] || [istarget "mn10200-*-*"]} then {
129
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
135
136 recurse_tests
137
138 # Restore the preserved old timeout value.
139 set timeout $oldtimeout
140 verbose "Timeout is now $timeout seconds" 2
141 }