1 # Copyright (C) 1998, 2007 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
25 # test special commands
30 if { [skip_hp_tests] } then { continue }
33 set srcfile ${testfile}.c
34 set binfile ${objdir}/${subdir}/${testfile}
35 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
36 untested watch-cmd.exp
41 if [get_compiler_info ${binfile}] {
44 if { $gcc_compiled } then { continue }
50 gdb_reinitialize_dir $srcdir/$subdir
55 proc watchpoint_command_test {} {
58 if [target_info exists noargs] {
59 verbose "Skipping watchpoint_command_test because of noargs."
63 if { ![runto factorial] } then { gdb_suppress_tests }
64 # Don't depend upon argument passing, since most simulators don't currently
65 # support it. Bash value variable to be what we want.
66 gdb_test "p value=6" "" "set value to 6 in watchpoint_command_test"
69 # Verify that we can create a watchpoint, and give it a commands
70 # list that continues the inferior. We set the watchpoint on a
71 # local variable, too, so that it self-deletes when the watched
72 # data goes out of scope.
74 # What should happen is: Each time the watchpoint triggers, it
75 # continues the inferior. Eventually, the watchpoint will self-
76 # delete, when the watched variable is out of scope. But by that
77 # time, the inferior should have exited. GDB shouldn't crash or
78 # anything untoward as a result of this.
80 send_gdb "watch local_var\n"
82 -re ".*\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $"\
83 { pass "watch local_var"
84 set wp_id $expect_out(1,string)
85 send_gdb "commands $wp_id\n"
87 -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
88 { pass "begin commands on watch"}
90 {fail "begin commands on watch"}
91 timeout {fail "(timeout) begin commands on watch"}
95 {fail "watch local_var"}
96 timeout {fail "(timeout) watch local_var"}
98 # set wp_id $expect_out(1,string)
99 # send_gdb "commands $wp_id\n"
101 # -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
102 # {pass "begin commands on watch"}
103 # -re "$gdb_prompt $"\
104 # {fail "begin commands on watch"}
105 # timeout {fail "(timeout) begin commands on watch"}
107 send_gdb "print value\n"
110 {pass "add print command to watch"}
112 {fail "add print command to watch"}
113 timeout {fail "(timeout) add print command to watch"}
115 send_gdb "continue\n"
118 {pass "add continue command to watch"}
120 {fail "add continue command to watch"}
121 timeout {fail "(timeout) add continue command to watch"}
126 {pass "begin commands on watch"}
127 timeout {fail "(timeout) begin commands on watch"}
129 send_gdb "continue\n"
131 -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*in main.*$gdb_prompt $"\
132 {pass "continue with watch"}
134 {fail "continue with watch"}
135 timeout {fail "(timeout) continue with watch"}
137 send_gdb "continue\n"
139 -re "Continuing.*$gdb_prompt $"\
140 {pass "continue until exit"}
142 {fail "continue until exit"}
143 timeout {fail "(timeout) continue until exit"}
147 watchpoint_command_test