]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.hp/gdb.aCC/watch-cmd.exp
a65af281caf895e55c512eb5b4458a8ae3edb714
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.hp / gdb.aCC / watch-cmd.exp
1 # Copyright (C) 1998, 2007 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 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@prep.ai.mit.edu
18
19 if $tracelevel then {
20 strace $tracelevel
21 }
22
23 #
24 # test special commands
25 #
26 set prms_id 0
27 set bug_id 0
28
29 if { [skip_hp_tests] } then { continue }
30
31 set testfile "run"
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
36 return -1
37
38 }
39
40 if [get_compiler_info ${binfile}] {
41 return -1;
42 }
43 if { $gcc_compiled } then { continue }
44
45
46 gdb_exit
47 gdb_start
48 delete_breakpoints
49 gdb_reinitialize_dir $srcdir/$subdir
50 gdb_load ${binfile}
51
52
53
54 proc watchpoint_command_test {} {
55 global gdb_prompt
56
57 if [target_info exists noargs] {
58 verbose "Skipping watchpoint_command_test because of noargs."
59 return
60 }
61
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"
66 delete_breakpoints
67
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.
72 #
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.
78 #
79 send_gdb "watch local_var\n"
80 gdb_expect {
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"
85 gdb_expect {
86 -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
87 { pass "begin commands on watch"}
88 -re "$gdb_prompt $"\
89 {fail "begin commands on watch"}
90 timeout {fail "(timeout) begin commands on watch"}
91 }
92 }
93 -re "$gdb_prompt $"\
94 {fail "watch local_var"}
95 timeout {fail "(timeout) watch local_var"}
96 }
97 # set wp_id $expect_out(1,string)
98 # send_gdb "commands $wp_id\n"
99 # gdb_expect {
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"}
105 # }
106 send_gdb "print value\n"
107 gdb_expect {
108 -re ">"\
109 {pass "add print command to watch"}
110 -re "$gdb_prompt $"\
111 {fail "add print command to watch"}
112 timeout {fail "(timeout) add print command to watch"}
113 }
114 send_gdb "continue\n"
115 gdb_expect {
116 -re ">"\
117 {pass "add continue command to watch"}
118 -re "$gdb_prompt $"\
119 {fail "add continue command to watch"}
120 timeout {fail "(timeout) add continue command to watch"}
121 }
122 send_gdb "end\n"
123 gdb_expect {
124 -re "$gdb_prompt $"\
125 {pass "begin commands on watch"}
126 timeout {fail "(timeout) begin commands on watch"}
127 }
128 send_gdb "continue\n"
129 gdb_expect {
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"}
132 -re "$gdb_prompt $"\
133 {fail "continue with watch"}
134 timeout {fail "(timeout) continue with watch"}
135 }
136 send_gdb "continue\n"
137 gdb_expect {
138 -re "Continuing.*$gdb_prompt $"\
139 {pass "continue until exit"}
140 -re "$gdb_prompt $"\
141 {fail "continue until exit"}
142 timeout {fail "(timeout) continue until exit"}
143 }
144 }
145
146 watchpoint_command_test
147
148
149
150
151
152
153
154
155
156
157