1 # Copyright (C) 1998, 2007, 2008 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/>.
16 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@prep.ai.mit.edu
24 # test special commands
29 if { [skip_hp_tests] } then { continue }
32 set srcfile ${testfile}.c
33 set binfile ${objdir}/${subdir}/${testfile}
34 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
35 untested watch-cmd.exp
40 if [get_compiler_info ${binfile}] {
43 if { $gcc_compiled } then { continue }
49 gdb_reinitialize_dir $srcdir/$subdir
54 proc watchpoint_command_test {} {
57 if [target_info exists noargs] {
58 verbose "Skipping watchpoint_command_test because of noargs."
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"
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.
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.
79 send_gdb "watch local_var\n"
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"
86 -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
87 { pass "begin commands on watch"}
89 {fail "begin commands on watch"}
90 timeout {fail "(timeout) begin commands on watch"}
94 {fail "watch local_var"}
95 timeout {fail "(timeout) watch local_var"}
97 # set wp_id $expect_out(1,string)
98 # send_gdb "commands $wp_id\n"
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"}
106 send_gdb "print value\n"
109 {pass "add print command to watch"}
111 {fail "add print command to watch"}
112 timeout {fail "(timeout) add print command to watch"}
114 send_gdb "continue\n"
117 {pass "add continue command to watch"}
119 {fail "add continue command to watch"}
120 timeout {fail "(timeout) add continue command to watch"}
125 {pass "begin commands on watch"}
126 timeout {fail "(timeout) begin commands on watch"}
128 send_gdb "continue\n"
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"}
133 {fail "continue with watch"}
134 timeout {fail "(timeout) continue with watch"}
136 send_gdb "continue\n"
138 -re "Continuing.*$gdb_prompt $"\
139 {pass "continue until exit"}
141 {fail "continue until exit"}
142 timeout {fail "(timeout) continue until exit"}
146 watchpoint_command_test