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