1 # Copyright (C) 1998, 2007, 2008, 2009, 2010 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 3 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, see <http://www.gnu.org/licenses/>.
21 # test special commands
26 if { [skip_hp_tests] } then { continue }
29 set srcfile ${testfile}.c
30 set binfile ${objdir}/${subdir}/${testfile}
31 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
32 untested watch-cmd.exp
37 if [get_compiler_info ${binfile}] {
40 if { $gcc_compiled } then { continue }
46 gdb_reinitialize_dir $srcdir/$subdir
51 proc watchpoint_command_test {} {
54 if [target_info exists noargs] {
55 verbose "Skipping watchpoint_command_test because of noargs."
59 if { ![runto factorial] } then { gdb_suppress_tests }
60 # Don't depend upon argument passing, since most simulators don't currently
61 # support it. Bash value variable to be what we want.
62 gdb_test "p value=6" "" "set value to 6 in watchpoint_command_test"
65 # Verify that we can create a watchpoint, and give it a commands
66 # list that continues the inferior. We set the watchpoint on a
67 # local variable, too, so that it self-deletes when the watched
68 # data goes out of scope.
70 # What should happen is: Each time the watchpoint triggers, it
71 # continues the inferior. Eventually, the watchpoint will self-
72 # delete, when the watched variable is out of scope. But by that
73 # time, the inferior should have exited. GDB shouldn't crash or
74 # anything untoward as a result of this.
76 send_gdb "watch local_var\n"
78 -re ".*\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $"\
79 { pass "watch local_var"
80 set wp_id $expect_out(1,string)
81 send_gdb "commands $wp_id\n"
83 -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
84 { pass "begin commands on watch"}
86 {fail "begin commands on watch"}
87 timeout {fail "(timeout) begin commands on watch"}
91 {fail "watch local_var"}
92 timeout {fail "(timeout) watch local_var"}
94 # set wp_id $expect_out(1,string)
95 # send_gdb "commands $wp_id\n"
97 # -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
98 # {pass "begin commands on watch"}
99 # -re "$gdb_prompt $"\
100 # {fail "begin commands on watch"}
101 # timeout {fail "(timeout) begin commands on watch"}
103 send_gdb "print value\n"
106 {pass "add print command to watch"}
108 {fail "add print command to watch"}
109 timeout {fail "(timeout) add print command to watch"}
111 send_gdb "continue\n"
114 {pass "add continue command to watch"}
116 {fail "add continue command to watch"}
117 timeout {fail "(timeout) add continue command to watch"}
122 {pass "begin commands on watch"}
123 timeout {fail "(timeout) begin commands on watch"}
125 send_gdb "continue\n"
127 -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*in main.*$gdb_prompt $"\
128 {pass "continue with watch"}
130 {fail "continue with watch"}
131 timeout {fail "(timeout) continue with watch"}
133 send_gdb "continue\n"
135 -re "Continuing.*$gdb_prompt $"\
136 {pass "continue until exit"}
138 {fail "continue until exit"}
139 timeout {fail "(timeout) continue until exit"}
143 watchpoint_command_test