]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/recurse.exp
90c9d2e80389ea1f450b2f8336165d63ab6b43dc
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / recurse.exp
1 # Copyright (C) 1992 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 ${srcdir}/$subdir/${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if { [compile "${srcfile} -g -o ${binfile}"] != "" } {
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 # Only enabled for some targets merely because it has not been tested
45 # elsewhere.
46 if {[istarget "sparc*-*-sunos4*"] || [istarget "hppa*-*-bsd*"]} then {
47
48 # Preserve the old timeout, and set a new one that should be
49 # sufficient to avoid timing out during this test.
50
51 if [runto recurse] then {
52 # First we need to step over the assignment of b, so it has a known
53 # value.
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"
57
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 {
62 return
63 }
64
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)"
76
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
79 # value.
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"
83
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 {
88 return
89 }
90
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)"
100
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 {
106 return
107 }
108
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 {
113 return
114 }
115
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 {
120 return
121 }
122
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 {
127 return
128 }
129 }
130
131 # Restore the preserved old timeout value.
132 }