* lib/gdb.exp (gdb_test): Between $pattern and $prompt, expect
[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., 675 Mass Ave, Cambridge, MA 02139, 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 binfile "recurse"
30 set srcfile $binfile.c
31
32 if ![file exists $objdir/$subdir/$binfile] then {
33 perror "$objdir/$subdir/$binfile does not exist."
34 return 0
35 }
36
37
38 # Start with a fresh gdb.
39
40 gdb_exit
41 gdb_start
42 gdb_reinitialize_dir $srcdir/$subdir
43 gdb_load $objdir/$subdir/$binfile
44
45 # For now we only run this on PAs running BSD.
46 if {[file exists $objdir/$subdir/$binfile] && [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 set timeoutsave $timeout
52 set timeout 60
53
54 if [runto recurse] then {
55 gdb_test "watch b" ".*\[Ww\]atchpoint \[0-9]*: b"
56
57 # Continue until initial set of b.
58 send "cont\n"
59 expect {
60 -re "Continuing.*Watchpoint.*, b.*Old value = 0.*New value = 10.*$prompt $" { pass "watchpoint hit, first time" }
61 -re ".*$prompt $" { fail "missed first watchpoint" ; return }
62 timeout { fail "missed first watchpoint (timeout)" ; return }
63 }
64
65 # Continue inward for a few iterations
66 gdb_test "continue" "Breakpoint.* recurse \[(\]+a=9\[)\]+"
67 gdb_test "continue" "Breakpoint.* recurse \[(\]+a=8\[)\]+"
68 gdb_test "continue" "Breakpoint.* recurse \[(\]+a=7\[)\]+"
69 gdb_test "continue" "Breakpoint.* recurse \[(\]+a=6\[)\]+"
70 gdb_test "continue" "Breakpoint.* recurse \[(\]+a=5\[)\]+"
71
72 # Put a watchpoint on another instance of b
73 gdb_test "watch b" ".*\[Ww\]atchpoint \[0-9]*: b"
74
75 # Continue until initial set of b (second instance).
76 send "cont\n"
77 expect {
78 -re "Continuing.*Watchpoint.*, b.*Old value = 0.*New value = 5.*$prompt $" { pass "watchpoint hit (second instance)" }
79 -re ".*$prompt $" {
80 fail "missed watchpoint (second instance)"
81 return
82 }
83 timeout {
84 fail "missed watchpoint (second instance) (timeout)"
85 return
86 }
87 }
88
89 # Continue inward for a few iterations
90 gdb_test "continue" "Breakpoint.* recurse \[(\]+a=4\[)\]+"
91 gdb_test "continue" "Breakpoint.* recurse \[(\]+a=3\[)\]+"
92 gdb_test "continue" "Breakpoint.* recurse \[(\]+a=2\[)\]+"
93 gdb_test "continue" "Breakpoint.* recurse \[(\]+a=1\[)\]+"
94
95 # Continue until second set of b (second instance).
96 send "cont\n"
97 expect {
98 -re "Continuing.*Watchpoint.*, b.*Old value = 5.*New value = 120.*return.*$prompt $" { pass "watchpoint hit, second time (second instance)" }
99 -re ".*$prompt $" {
100 fail "missed watchpoint, second time (second instance)"
101 return
102 }
103 timeout {
104 fail "missed watchpoint, second time (second instance)(timeout)"
105 return
106 }
107 }
108
109 # Continue again. We should have a watchpoint go out of scope now
110 send "cont\n"
111 expect {
112 -re "Continuing.*Watchpoint.*deleted.*recurse \[(\]+a=6\[)\]+ .*$prompt $" {pass "watchpoint deleted when leaving scope (second instance)" }
113 -re ".*prompt $" {
114 fail "watchpoint not deleted when leaving scope (second instance)"
115 return
116 }
117 timeout {
118 fail "watchpoint not deleted when leaving scope (second instance) (timeout)"
119 return
120 }
121 }
122
123 # Continue until second set of b (first instance).
124 send "cont\n"
125 expect {
126 -re "Continuing.*Watchpoint.*b.*Old value = 10.*New value = 3628800.*return.*$prompt $" { pass "watchpoint hit, second time" }
127 -re ".*$prompt $" {
128 fail "missed watchpoint, second time)"
129 return
130 }
131 timeout {
132 fail "missed watchpoint, second time (timeout)"
133 return
134 }
135 }
136
137 # Continue again. We should have a watchpoint go out of scope now
138 send "cont\n"
139 expect {
140 -re "Continuing.*Watchpoint.*deleted.*main \[(\]+\[)\]+ .*$prompt $" {pass "watchpoint deleted when leaving scope" }
141 -re ".*prompt $" {
142 fail "watchpoint not deleted when leaving scope"
143 return
144 }
145 timeout {
146 fail "watchpoint not deleted when leaving scope (timeout)"
147 return
148 }
149 }
150 }
151
152 # Restore the preserved old timeout value.
153 set timeout $timeoutsave
154 }
155
156 if [istarget "a29k-*-udi"] then {
157 # FIXME: If PR 2415 is fixed, this is not needed.
158 gdb_target_udi
159 }