]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.hp/gdb.aCC/watch-cmd.exp
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.hp / gdb.aCC / watch-cmd.exp
1 # Copyright (C) 1998-2014 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 #
17 # test special commands
18 #
19
20 if { [skip_hp_tests] } then { continue }
21
22 set testfile "run"
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
27 return -1
28
29 }
30
31 if [get_compiler_info] {
32 return -1
33 }
34 if { $gcc_compiled } then { continue }
35
36
37 gdb_exit
38 gdb_start
39 delete_breakpoints
40 gdb_reinitialize_dir $srcdir/$subdir
41 gdb_load ${binfile}
42
43
44
45 proc watchpoint_command_test {} {
46 global gdb_prompt
47
48 if [target_info exists noargs] {
49 verbose "Skipping watchpoint_command_test because of noargs."
50 return
51 }
52
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"
57 delete_breakpoints
58
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.
63 #
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.
69 #
70 send_gdb "watch local_var\n"
71 gdb_expect {
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"
76 gdb_expect {
77 -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
78 { pass "begin commands on watch"}
79 -re "$gdb_prompt $"\
80 {fail "begin commands on watch"}
81 timeout {fail "(timeout) begin commands on watch"}
82 }
83 }
84 -re "$gdb_prompt $"\
85 {fail "watch local_var"}
86 timeout {fail "(timeout) watch local_var"}
87 }
88 # set wp_id $expect_out(1,string)
89 # send_gdb "commands $wp_id\n"
90 # gdb_expect {
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"}
96 # }
97 send_gdb "print value\n"
98 gdb_expect {
99 -re ">"\
100 {pass "add print command to watch"}
101 -re "$gdb_prompt $"\
102 {fail "add print command to watch"}
103 timeout {fail "(timeout) add print command to watch"}
104 }
105 send_gdb "continue\n"
106 gdb_expect {
107 -re ">"\
108 {pass "add continue command to watch"}
109 -re "$gdb_prompt $"\
110 {fail "add continue command to watch"}
111 timeout {fail "(timeout) add continue command to watch"}
112 }
113 send_gdb "end\n"
114 gdb_expect {
115 -re "$gdb_prompt $"\
116 {pass "begin commands on watch"}
117 timeout {fail "(timeout) begin commands on watch"}
118 }
119 send_gdb "continue\n"
120 gdb_expect {
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"}
123 -re "$gdb_prompt $"\
124 {fail "continue with watch"}
125 timeout {fail "(timeout) continue with watch"}
126 }
127 send_gdb "continue\n"
128 gdb_expect {
129 -re "Continuing.*$gdb_prompt $"\
130 {pass "continue until exit"}
131 -re "$gdb_prompt $"\
132 {fail "continue until exit"}
133 timeout {fail "(timeout) continue until exit"}
134 }
135 }
136
137 watchpoint_command_test
138
139
140
141
142
143
144
145
146
147
148