Updated copyright notices for most files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.hp / gdb.aCC / watch-cmd.exp
CommitLineData
9b254dd1 1# Copyright (C) 1998, 2007, 2008 Free Software Foundation, Inc.
7be570e7
JM
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
7be570e7 6# (at your option) any later version.
e22f8b7c 7#
7be570e7
JM
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.
e22f8b7c 12#
7be570e7 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
7be570e7
JM
15
16# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@prep.ai.mit.edu
18
19if $tracelevel then {
20 strace $tracelevel
21}
22
23#
24# test special commands
25#
26set prms_id 0
27set bug_id 0
28
29if { [skip_hp_tests] } then { continue }
30
31set testfile "run"
32set srcfile ${testfile}.c
33set binfile ${objdir}/${subdir}/${testfile}
34if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
b60f0898
JB
35 untested watch-cmd.exp
36 return -1
7be570e7
JM
37
38}
39
40if [get_compiler_info ${binfile}] {
41 return -1;
42}
43if { $gcc_compiled } then { continue }
44
45
46gdb_exit
47gdb_start
48delete_breakpoints
49gdb_reinitialize_dir $srcdir/$subdir
50gdb_load ${binfile}
51
52
53
54proc watchpoint_command_test {} {
55 global gdb_prompt
56
57 if [target_info exists noargs] {
58 verbose "Skipping watchpoint_command_test because of noargs."
59 return
60 }
61
62 if { ![runto factorial] } then { gdb_suppress_tests }
63 # Don't depend upon argument passing, since most simulators don't currently
64 # support it. Bash value variable to be what we want.
65 gdb_test "p value=6" "" "set value to 6 in watchpoint_command_test"
66 delete_breakpoints
67
68 # Verify that we can create a watchpoint, and give it a commands
69 # list that continues the inferior. We set the watchpoint on a
70 # local variable, too, so that it self-deletes when the watched
71 # data goes out of scope.
72 #
73 # What should happen is: Each time the watchpoint triggers, it
74 # continues the inferior. Eventually, the watchpoint will self-
75 # delete, when the watched variable is out of scope. But by that
76 # time, the inferior should have exited. GDB shouldn't crash or
77 # anything untoward as a result of this.
78 #
79 send_gdb "watch local_var\n"
80 gdb_expect {
81 -re ".*\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $"\
82 { pass "watch local_var"
83 set wp_id $expect_out(1,string)
84 send_gdb "commands $wp_id\n"
85 gdb_expect {
86 -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
87 { pass "begin commands on watch"}
88 -re "$gdb_prompt $"\
89 {fail "begin commands on watch"}
90 timeout {fail "(timeout) begin commands on watch"}
91 }
92 }
93 -re "$gdb_prompt $"\
94 {fail "watch local_var"}
95 timeout {fail "(timeout) watch local_var"}
96 }
97# set wp_id $expect_out(1,string)
98# send_gdb "commands $wp_id\n"
99# gdb_expect {
100# -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
101# {pass "begin commands on watch"}
102# -re "$gdb_prompt $"\
103# {fail "begin commands on watch"}
104# timeout {fail "(timeout) begin commands on watch"}
105# }
106 send_gdb "print value\n"
107 gdb_expect {
108 -re ">"\
109 {pass "add print command to watch"}
110 -re "$gdb_prompt $"\
111 {fail "add print command to watch"}
112 timeout {fail "(timeout) add print command to watch"}
113 }
114 send_gdb "continue\n"
115 gdb_expect {
116 -re ">"\
117 {pass "add continue command to watch"}
118 -re "$gdb_prompt $"\
119 {fail "add continue command to watch"}
120 timeout {fail "(timeout) add continue command to watch"}
121 }
122 send_gdb "end\n"
123 gdb_expect {
124 -re "$gdb_prompt $"\
125 {pass "begin commands on watch"}
126 timeout {fail "(timeout) begin commands on watch"}
127 }
128 send_gdb "continue\n"
129 gdb_expect {
130 -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*in main.*$gdb_prompt $"\
131 {pass "continue with watch"}
132 -re "$gdb_prompt $"\
133 {fail "continue with watch"}
134 timeout {fail "(timeout) continue with watch"}
135 }
136 send_gdb "continue\n"
137 gdb_expect {
138 -re "Continuing.*$gdb_prompt $"\
139 {pass "continue until exit"}
140 -re "$gdb_prompt $"\
141 {fail "continue until exit"}
142 timeout {fail "(timeout) continue until exit"}
143 }
144}
145
146watchpoint_command_test
147
148
149
150
151
152
153
154
155
156
157
This page took 0.730729 seconds and 4 git commands to generate.