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., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
30 set srcfile $binfile.c
32 if ![file exists $objdir/$subdir/$binfile] then {
33 perror "$objdir/$subdir/$binfile does not exist."
38 # Start with a fresh gdb.
42 gdb_reinitialize_dir $srcdir/$subdir
43 gdb_load $objdir/$subdir/$binfile
45 # For now we only run this on PAs running BSD.
46 if {[file exists $objdir/$subdir/$binfile] && [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 set timeoutsave $timeout
54 if [runto recurse] then {
55 gdb_test "watch b" ".*\[Ww\]atchpoint \[0-9]*: b"
57 # Continue until initial set of b.
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 }
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\[)\]+"
72 # Put a watchpoint on another instance of b
73 gdb_test "watch b" ".*\[Ww\]atchpoint \[0-9]*: b"
75 # Continue until initial set of b (second instance).
78 -re "Continuing.*Watchpoint.*, b.*Old value = 0.*New value = 5.*$prompt $" { pass "watchpoint hit (second instance)" }
80 fail "missed watchpoint (second instance)"
84 fail "missed watchpoint (second instance) (timeout)"
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\[)\]+"
95 # Continue until second set of b (second instance).
98 -re "Continuing.*Watchpoint.*, b.*Old value = 5.*New value = 120.*return.*$prompt $" { pass "watchpoint hit, second time (second instance)" }
100 fail "missed watchpoint, second time (second instance)"
104 fail "missed watchpoint, second time (second instance)(timeout)"
109 # Continue again. We should have a watchpoint go out of scope now
112 -re "Continuing.*Watchpoint.*deleted.*recurse \[(\]+a=6\[)\]+ .*$prompt $" {pass "watchpoint deleted when leaving scope (second instance)" }
114 fail "watchpoint not deleted when leaving scope (second instance)"
118 fail "watchpoint not deleted when leaving scope (second instance) (timeout)"
123 # Continue until second set of b (first instance).
126 -re "Continuing.*Watchpoint.*b.*Old value = 10.*New value = 3628800.*return.*$prompt $" { pass "watchpoint hit, second time" }
128 fail "missed watchpoint, second time)"
132 fail "missed watchpoint, second time (timeout)"
137 # Continue again. We should have a watchpoint go out of scope now
140 -re "Continuing.*Watchpoint.*deleted.*main \[(\]+\[)\]+ .*$prompt $" {pass "watchpoint deleted when leaving scope" }
142 fail "watchpoint not deleted when leaving scope"
146 fail "watchpoint not deleted when leaving scope (timeout)"
152 # Restore the preserved old timeout value.
153 set timeout $timeoutsave
156 if [istarget "a29k-*-udi"] then {
157 # FIXME: If PR 2415 is fixed, this is not needed.