1 # Copyright (C) 1998-2015 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/>.
17 # test special commands
20 if { [skip_hp_tests] } then { continue }
23 set srcfile ${testfile}.c
24 set binfile ${objdir}/${subdir}/${testfile}
25 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
26 untested watch-cmd.exp
31 if [get_compiler_info] {
34 if { $gcc_compiled } then { continue }
40 gdb_reinitialize_dir $srcdir/$subdir
45 proc watchpoint_command_test {} {
48 if [target_info exists noargs] {
49 verbose "Skipping watchpoint_command_test because of noargs."
53 if { ![runto factorial] } then { gdb_suppress_tests }
54 # Don't depend upon argument passing, since most simulators don't currently
55 # support it. Bash value variable to be what we want.
56 gdb_test "p value=6" "" "set value to 6 in watchpoint_command_test"
59 # Verify that we can create a watchpoint, and give it a commands
60 # list that continues the inferior. We set the watchpoint on a
61 # local variable, too, so that it self-deletes when the watched
62 # data goes out of scope.
64 # What should happen is: Each time the watchpoint triggers, it
65 # continues the inferior. Eventually, the watchpoint will self-
66 # delete, when the watched variable is out of scope. But by that
67 # time, the inferior should have exited. GDB shouldn't crash or
68 # anything untoward as a result of this.
70 send_gdb "watch local_var\n"
72 -re ".*\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $"\
73 { pass "watch local_var"
74 set wp_id $expect_out(1,string)
75 send_gdb "commands $wp_id\n"
77 -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
78 { pass "begin commands on watch"}
80 {fail "begin commands on watch"}
81 timeout {fail "(timeout) begin commands on watch"}
85 {fail "watch local_var"}
86 timeout {fail "(timeout) watch local_var"}
88 # set wp_id $expect_out(1,string)
89 # send_gdb "commands $wp_id\n"
91 # -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
92 # {pass "begin commands on watch"}
93 # -re "$gdb_prompt $"\
94 # {fail "begin commands on watch"}
95 # timeout {fail "(timeout) begin commands on watch"}
97 send_gdb "print value\n"
100 {pass "add print command to watch"}
102 {fail "add print command to watch"}
103 timeout {fail "(timeout) add print command to watch"}
105 send_gdb "continue\n"
108 {pass "add continue command to watch"}
110 {fail "add continue command to watch"}
111 timeout {fail "(timeout) add continue command to watch"}
116 {pass "begin commands on watch"}
117 timeout {fail "(timeout) begin commands on watch"}
119 send_gdb "continue\n"
121 -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*in main.*$gdb_prompt $"\
122 {pass "continue with watch"}
124 {fail "continue with watch"}
125 timeout {fail "(timeout) continue with watch"}
127 send_gdb "continue\n"
129 -re "Continuing.*$gdb_prompt $"\
130 {pass "continue until exit"}
132 {fail "continue until exit"}
133 timeout {fail "(timeout) continue until exit"}
137 watchpoint_command_test