OLD | NEW |
1 # Copyright 1992, 1994-2000, 2007-2012 Free Software Foundation, Inc. | 1 # Copyright 1992, 1994-2000, 2007-2012 Free Software Foundation, Inc. |
2 | 2 |
3 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
6 # (at your option) any later version. | 6 # (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 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/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 # This file was written by Fred Fish. (fnf@cygnus.com) | 16 # This file was written by Fred Fish. (fnf@cygnus.com) |
17 | 17 |
18 if $tracelevel then { | |
19 strace $tracelevel | |
20 } | |
21 | |
22 | 18 |
23 set testfile "watchpoint" | 19 set testfile "watchpoint" |
24 set srcfile ${testfile}.c | 20 set srcfile ${testfile}.c |
25 set binfile ${objdir}/${subdir}/${testfile} | 21 set binfile ${objdir}/${subdir}/${testfile} |
26 | 22 |
27 set wp_set 1 | 23 if [get_compiler_info] { |
28 | |
29 if [get_compiler_info ${binfile}] { | |
30 return -1 | 24 return -1 |
31 } | 25 } |
32 | 26 |
33 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
ug}] != "" } { | 27 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
ug}] != "" } { |
34 untested watchpoint.exp | 28 untested watchpoint.exp |
35 return -1 | 29 return -1 |
36 } | 30 } |
37 | 31 |
| 32 # True if we're forcing no hardware watchpoints. |
| 33 set no_hw 0 |
| 34 |
38 # Prepare for watchpoint tests by setting up two breakpoints and one | 35 # Prepare for watchpoint tests by setting up two breakpoints and one |
39 # watchpoint. | 36 # watchpoint. |
40 # | 37 # |
41 # We use breakpoints at marker functions to get past all the startup code, | 38 # We use breakpoints at marker functions to get past all the startup code, |
42 # so we can get to the watchpoints in a reasonable amount of time from a | 39 # so we can get to the watchpoints in a reasonable amount of time from a |
43 # known starting point. | 40 # known starting point. |
44 # | 41 # |
45 # For simplicity, so we always know how to reference specific breakpoints or | 42 # For simplicity, so we always know how to reference specific breakpoints or |
46 # watchpoints by number, we expect a particular ordering and numbering of | 43 # watchpoints by number, we expect a particular ordering and numbering of |
47 # each in the combined breakpoint/watchpoint table, as follows: | 44 # each in the combined breakpoint/watchpoint table, as follows: |
48 # | 45 # |
49 # Number What Where | 46 # Number What Where |
50 # 1 Breakpoint marker1() | 47 # 1 Breakpoint marker1() |
51 # 2 Breakpoint marker2() | 48 # 2 Breakpoint marker2() |
52 # 3 Watchpoint ival3 | 49 # 3 Watchpoint ival3 |
53 | 50 |
54 proc initialize {} { | 51 proc initialize {} { |
55 global gdb_prompt | 52 global gdb_prompt |
56 global hex | 53 global hex |
57 global decimal | 54 global decimal |
58 global srcfile | 55 global srcfile |
59 global wp_set | |
60 | |
61 # Disable hardware watchpoints if necessary. | |
62 if [target_info exists gdb,no_hardware_watchpoints] { | |
63 gdb_test_no_output "set can-use-hw-watchpoints 0" "" | |
64 } | |
65 | 56 |
66 if [gdb_test "break marker1" "Breakpoint 1 at $hex: file .*$srcfile, line $d
ecimal.*" "set breakpoint at marker1" ] { | 57 if [gdb_test "break marker1" "Breakpoint 1 at $hex: file .*$srcfile, line $d
ecimal.*" "set breakpoint at marker1" ] { |
67 return 0; | 58 return 0; |
68 } | 59 } |
69 | 60 |
70 | 61 |
71 if [gdb_test "break marker2" "Breakpoint 2 at $hex: file .*$srcfile, line $d
ecimal.*" "set breakpoint at marker2" ] { | 62 if [gdb_test "break marker2" "Breakpoint 2 at $hex: file .*$srcfile, line $d
ecimal.*" "set breakpoint at marker2" ] { |
72 return 0; | 63 return 0; |
73 } | 64 } |
74 | 65 |
75 | 66 |
76 if [gdb_test "info break" "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint
.*marker2.*" "info break in watchpoint.exp" ] { | 67 if [gdb_test "info break" "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint
.*marker2.*" "info break in watchpoint.exp" ] { |
77 return 0; | 68 return 0; |
78 } | 69 } |
79 | 70 |
80 | 71 gdb_test "watch ival3" ".*\[Ww\]atchpoint 3: ival3.*" "set watchpoint on iva
l3" |
81 # ??rehrauer: To fix DTS #CHFts23014, in which setting a watchpoint | |
82 # before running can cause the inferior to croak on HP-UX 11.0 for | |
83 # reasons yet unknown, we've disabled the ability to set watches | |
84 # without a running inferior. Verify the restriction. | |
85 # | |
86 send_gdb "watch ival3\n" | |
87 gdb_expect { | |
88 -re ".*\[Ww\]atchpoint 3: ival3.*$gdb_prompt $" { | |
89 pass "set watchpoint on ival3" | |
90 } | |
91 -re "warning: can't do that without a running program; try \"break main\
", \"run\" first.*$gdb_prompt $" { | |
92 pass "set watchpoint on ival3" | |
93 set wp_set 0 | |
94 return 1 | |
95 } | |
96 timeout { | |
97 fail "(timeout) set watchpoint on ival3" | |
98 return 0 | |
99 } | |
100 } | |
101 | 72 |
102 if [gdb_test "info watch" "3\[ \]*.*watchpoint.*ival3" "watchpoint found in
watchpoint/breakpoint table" ] { | 73 if [gdb_test "info watch" "3\[ \]*.*watchpoint.*ival3" "watchpoint found in
watchpoint/breakpoint table" ] { |
103 return 0; | 74 return 0; |
104 } | 75 } |
105 | 76 |
106 | 77 |
107 # After installing the watchpoint, we disable it until we are ready | 78 # After installing the watchpoint, we disable it until we are ready |
108 # to use it. This allows the test program to run at full speed until | 79 # to use it. This allows the test program to run at full speed until |
109 # we get to the first marker function. | 80 # we get to the first marker function. |
110 | 81 |
111 if [gdb_test "disable 3" "disable 3\[\r\n\]+" "disable watchpoint" ] { | 82 if [gdb_test "disable 3" "disable 3\[\r\n\]+" "disable watchpoint" ] { |
112 return 0; | 83 return 0; |
113 } | 84 } |
114 | 85 |
115 | 86 |
116 return 1 | 87 return 1 |
117 } | 88 } |
118 | 89 |
119 # | 90 # |
120 # Test simple watchpoint. | 91 # Test simple watchpoint. |
121 # | 92 # |
122 | 93 |
123 proc test_simple_watchpoint {} { | 94 proc test_simple_watchpoint {} { |
124 global gdb_prompt | 95 global gdb_prompt |
125 global hex | 96 global hex |
126 global decimal | 97 global decimal |
127 global wp_set | |
128 | 98 |
129 # Ensure that the watchpoint is disabled when we startup. | 99 # Ensure that the watchpoint is disabled when we startup. |
130 | 100 |
131 if { $wp_set } { | 101 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_s
imple_watchpoint" ] { |
132 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in te
st_simple_watchpoint" ] { | 102 return 0; |
133 » return 0; | |
134 » } | |
135 } | 103 } |
136 | 104 |
137 | |
138 # Run until we get to the first marker function. | 105 # Run until we get to the first marker function. |
139 | 106 |
140 gdb_run_cmd | 107 gdb_run_cmd |
141 set timeout 600 | 108 set timeout 600 |
142 gdb_expect { | 109 set test "run to marker1 in test_simple_watchpoint" |
| 110 set retcode [gdb_test_multiple "" $test { |
143 -re "Breakpoint 1, marker1 .*$gdb_prompt $" { | 111 -re "Breakpoint 1, marker1 .*$gdb_prompt $" { |
144 » pass "run to marker1 in test_simple_watchpoint" | 112 » pass $test |
145 } | 113 } |
146 » -re ".*$gdb_prompt $" { | 114 }] |
147 » fail "run to marker1 in test_simple_watchpoint" | |
148 » return | |
149 » } | |
150 » timeout { | |
151 » fail "run to marker1 in test_simple_watchpoint (timeout)" | |
152 » return | |
153 » } | |
154 } | |
155 | 115 |
156 if { !$wp_set } { | 116 if { $retcode != 0 } { |
157 » # ??rehrauer: To fix DTS #CHFts23014, in which setting a watchpoint | 117 » return |
158 » # before running can cause the inferior to croak on HP-UX 11.0 | |
159 » # for reasons yet unknown, we've disabled the ability to set | |
160 » # watches without a running inferior. The following testpoints used | |
161 » # to be in [initialize]. | |
162 » # | |
163 » gdb_test "watch ival3" \ | |
164 » "\[Ww\]atchpoint 3: ival3" \ | |
165 » "set watchpoint on ival3" | |
166 | |
167 set wp_set 1 | |
168 | |
169 » gdb_test "info watch" \ | |
170 » "3\[ \]*.*watchpoint.*ival3" \ | |
171 » "watchpoint found in watchpoint/breakpoint table" | |
172 | |
173 » # After installing the watchpoint, we disable it until we are ready | |
174 » # to use it. This allows the test program to run at full speed until | |
175 » # we get to the first marker function. | |
176 | |
177 » gdb_test "disable 3" "disable 3" "disable watchpoint" | |
178 } | 118 } |
179 | 119 |
180 # After reaching the marker function, enable the watchpoint. | 120 # After reaching the marker function, enable the watchpoint. |
181 | 121 |
182 if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "enable watchpoint" ] { | 122 if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "enable watchpoint" ] { |
183 return ; | 123 return ; |
184 } | 124 } |
185 | 125 |
186 | 126 |
187 gdb_test "break func1" "Breakpoint.*at.*" | 127 gdb_test "break func1" "Breakpoint.*at.*" |
188 gdb_test_no_output "set \$func1_breakpoint_number = \$bpnum" | 128 gdb_test_no_output "set \$func1_breakpoint_number = \$bpnum" |
189 | 129 |
190 gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, func1.*" \ | 130 gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, func1.*" \ |
191 "continue to breakpoint at func1" | 131 "continue to breakpoint at func1" |
192 | 132 |
193 # Continue until the first change, from -1 to 0 | 133 # Continue until the first change, from -1 to 0 |
194 | 134 |
195 send_gdb "cont\n" | 135 set test "watchpoint hit, first time" |
196 gdb_expect { | 136 gdb_test_multiple "cont" $test { |
197 -re "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*
ival3 = count; ival4 = count;.*$gdb_prompt $" { | 137 -re "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*
ival3 = count; ival4 = count;.*$gdb_prompt $" { |
198 » pass "watchpoint hit, first time" | 138 » pass $test |
199 } | 139 } |
200 -re "Continuing.*Breakpoint.*func1.*$gdb_prompt $" { | 140 -re "Continuing.*Breakpoint.*func1.*$gdb_prompt $" { |
201 setup_xfail "m68*-*-*" 2597 | 141 setup_xfail "m68*-*-*" 2597 |
202 fail "thought it hit breakpoint at func1 twice" | 142 fail "thought it hit breakpoint at func1 twice" |
203 gdb_test_no_output "delete \$func1_breakpoint_number" | 143 gdb_test_no_output "delete \$func1_breakpoint_number" |
204 gdb_test "continue" "\ | 144 gdb_test "continue" "\ |
205 Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count
;" \ | 145 Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count
;" \ |
206 » » "watchpoint hit, first time" | 146 » » $test |
207 } | 147 } |
208 -re ".*$gdb_prompt $" { fail "watchpoint hit, first time" ; return } | |
209 timeout { fail "watchpoint hit, first time (timeout)" ; return } | |
210 eof { fail "watchpoint hit, first time (eof)" ; return } | |
211 } | 148 } |
212 | 149 |
213 # Check that the hit count is reported correctly | 150 # Check that the hit count is reported correctly |
214 gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[
\t]+breakpoint already hit 1 time.*" "Watchpoint hit count is 1" | 151 gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[
\t]+breakpoint already hit 1 time.*" "Watchpoint hit count is 1" |
215 | 152 |
216 gdb_test_no_output "delete \$func1_breakpoint_number" | 153 gdb_test_no_output "delete \$func1_breakpoint_number" |
217 | 154 |
218 # Continue until the next change, from 0 to 1. | 155 # Continue until the next change, from 0 to 1. |
219 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 0.*New valu
e = 1.*ival3 = count; ival4 = count;.*" "watchpoint hit, second time" | 156 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 0.*New valu
e = 1.*ival3 = count; ival4 = count;.*" "watchpoint hit, second time" |
220 | 157 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 200 |
264 # Test disabling watchpoints. | 201 # Test disabling watchpoints. |
265 | 202 |
266 proc test_disabling_watchpoints {} { | 203 proc test_disabling_watchpoints {} { |
267 global gdb_prompt | 204 global gdb_prompt |
268 global binfile | 205 global binfile |
269 global srcfile | 206 global srcfile |
270 global decimal | 207 global decimal |
271 global hex | 208 global hex |
272 | 209 |
273 # "info watch" is the same as "info break" | 210 gdb_test "info watch" "\[0-9]+\[ \]*.*watchpoint.*ival3.*" "watchpoints foun
d in watchpoint/breakpoint table" |
274 gdb_test "info watch" "\[0-9]+\[ \]*.*watchpoint.*ival3\r\n\.*\[0-9\]+ times
.*" "watchpoints found in watchpoint/breakpoint table" | |
275 | 211 |
276 # Ensure that the watchpoint is disabled when we startup. | 212 # Ensure that the watchpoint is disabled when we startup. |
277 | 213 |
278 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_d
isabling_watchpoints" ] { | 214 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_d
isabling_watchpoints" ] { |
279 return 0; | 215 return 0; |
280 } | 216 } |
281 | 217 |
282 | 218 |
283 # Run until we get to the first marker function. | 219 # Run until we get to the first marker function. |
284 | 220 |
285 gdb_run_cmd | 221 gdb_run_cmd |
286 set timeout 600 | 222 set timeout 600 |
287 gdb_expect { | 223 set test "run to marker1 in test_disabling_watchpoints" |
| 224 set retcode [gdb_test_multiple "" $test { |
288 -re "Breakpoint 1, marker1 .*$gdb_prompt $" { | 225 -re "Breakpoint 1, marker1 .*$gdb_prompt $" { |
289 » pass "run to marker1 in test_disabling_watchpoints" | 226 » pass $test |
290 } | 227 } |
291 » -re ".*$gdb_prompt $" { | 228 }] |
292 » fail "run to marker1 in test_disabling_watchpoints" | 229 |
293 » return | 230 if { $retcode != 0 } { |
294 » } | 231 » return |
295 » timeout { | |
296 » fail "run to marker1 in test_disabling_watchpoints (timeout)" | |
297 » return | |
298 » } | |
299 } | 232 } |
300 | 233 |
301 # After reaching the marker function, enable the watchpoint. | 234 # After reaching the marker function, enable the watchpoint. |
302 | 235 |
303 if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "watchpoint enabled" ] { | 236 if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "watchpoint enabled" ] { |
304 return ; | 237 return ; |
305 } | 238 } |
306 | 239 |
307 | 240 |
308 # Continue until the first change, from -1 to 0 | 241 # Continue until the first change, from -1 to 0 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 # "until", because compilers don't always arrange the code | 317 # "until", because compilers don't always arrange the code |
385 # exactly the same way, and we might get slightly different | 318 # exactly the same way, and we might get slightly different |
386 # sequences of statements. But the following should be true | 319 # sequences of statements. But the following should be true |
387 # (if not it is a compiler or a debugger bug): The user who | 320 # (if not it is a compiler or a debugger bug): The user who |
388 # does "until" at every statement of a loop should end up | 321 # does "until" at every statement of a loop should end up |
389 # stepping through the loop once, and the debugger should not | 322 # stepping through the loop once, and the debugger should not |
390 # stop for any of the remaining iterations. | 323 # stop for any of the remaining iterations. |
391 | 324 |
392 gdb_test "until" "ival1 = count.*" "until to ival1 assignment" | 325 gdb_test "until" "ival1 = count.*" "until to ival1 assignment" |
393 gdb_test "until" "ival3 = count.*" "until to ival3 assignment" | 326 gdb_test "until" "ival3 = count.*" "until to ival3 assignment" |
394 » send_gdb "until\n" | 327 » set test "until out of loop" |
395 » gdb_expect { | 328 » gdb_test_multiple "until" $test { |
396 -re "(for \\(count = 0|\}).*$gdb_prompt $" { | 329 -re "(for \\(count = 0|\}).*$gdb_prompt $" { |
397 » » gdb_test "until" "ival1 = count; /. Outside loop ./" \ | 330 » » gdb_test "until" "ival1 = count; /. Outside loop ./" $test |
398 » » "until out of loop" | |
399 } | 331 } |
400 -re "ival1 = count; /. Outside loop ./.*$gdb_prompt $" { | 332 -re "ival1 = count; /. Outside loop ./.*$gdb_prompt $" { |
401 » » pass "until out of loop" | 333 » » pass $test |
402 } | 334 } |
403 -re ".*$gdb_prompt $" { | |
404 fail "until out of loop" | |
405 } | |
406 default { fail "until out of loop (timeout)" ; return } | |
407 } | 335 } |
408 | 336 |
409 gdb_test "step" "ival2 = count.*" "step to ival2 assignment" | 337 gdb_test "step" "ival2 = count.*" "step to ival2 assignment" |
410 } | 338 } |
411 } | 339 } |
412 | 340 |
413 # Test stepping and other mundane operations with watchpoints enabled | 341 # Test stepping and other mundane operations with watchpoints enabled |
414 proc test_watchpoint_triggered_in_syscall {} { | 342 proc test_watchpoint_triggered_in_syscall {} { |
415 global gdb_prompt | 343 global gdb_prompt |
416 | 344 |
417 # These tests won't work without printf support. | 345 # These tests won't work without printf support. |
418 if [gdb_skip_stdio_test "watchpoints triggered in syscall"] { | 346 if [gdb_skip_stdio_test "watchpoints triggered in syscall"] { |
419 return; | 347 return; |
420 } | 348 } |
421 # Run until we get to the first marker function. | 349 # Run until we get to the first marker function. |
422 set x 0 | 350 set x 0 |
423 set y 0 | 351 set y 0 |
424 set testname "Watch buffer passed to read syscall" | 352 set testname "Watch buffer passed to read syscall" |
425 if [runto marker2] then { | 353 if [runto marker2] then { |
426 gdb_test "watch buf\[0\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[0\\\]" | 354 gdb_test "watch buf\[0\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[0\\\]" |
427 gdb_test "watch buf\[1\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[1\\\]" | 355 gdb_test "watch buf\[1\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[1\\\]" |
428 gdb_test "watch buf\[2\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[2\\\]" | 356 gdb_test "watch buf\[2\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[2\\\]" |
429 gdb_test "watch buf\[3\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[3\\\]" | 357 gdb_test "watch buf\[3\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[3\\\]" |
430 gdb_test "watch buf\[4\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[4\\\]" | 358 gdb_test "watch buf\[4\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[4\\\]" |
431 gdb_test "break marker4" ".*Breakpoint.*" | 359 gdb_test "break marker4" ".*Breakpoint.*" |
432 | 360 |
433 gdb_test_no_output "set doread = 1" | 361 gdb_test_no_output "set doread = 1" |
434 | 362 |
435 » # If we send_gdb "123\n" before gdb has switched the tty, then it goes | 363 » # If we send gdb "123\n" before gdb has switched the tty, then it goes |
436 # to gdb, not the inferior, and we lose. So that is why we have | 364 # to gdb, not the inferior, and we lose. So that is why we have |
437 # watchpoint.c prompt us, so we can wait for that prompt. | 365 # watchpoint.c prompt us, so we can wait for that prompt. |
438 | 366 |
439 send_gdb "continue\n"; | 367 send_gdb "continue\n"; |
440 gdb_expect { | 368 gdb_expect { |
441 -re "Continuing\\.\r\ntype stuff for buf now:" { | 369 -re "Continuing\\.\r\ntype stuff for buf now:" { |
442 pass "continue to read" | 370 pass "continue to read" |
443 } | 371 } |
444 default { | 372 default { |
445 fail "continue to read"; | 373 fail "continue to read"; |
446 return ; | 374 return ; |
447 } | 375 } |
448 } | 376 } |
449 | 377 |
450 » send_gdb "123\n" | 378 » set test "sent 123" |
451 » gdb_expect { | 379 » gdb_test_multiple "123" $test { |
452 -re ".*\[Ww\]atchpoint.*buf\\\[0\\\].*Old value = 0.*New value = 49\
[^\n\]*\n" { set x [expr $x+1] ; exp_continue } | 380 -re ".*\[Ww\]atchpoint.*buf\\\[0\\\].*Old value = 0.*New value = 49\
[^\n\]*\n" { set x [expr $x+1] ; exp_continue } |
453 -re ".*\[Ww\]atchpoint.*buf\\\[1\\\].*Old value = 0.*New value = 50\
[^\n\]*\n" { set x [expr $x+1] ; exp_continue } | 381 -re ".*\[Ww\]atchpoint.*buf\\\[1\\\].*Old value = 0.*New value = 50\
[^\n\]*\n" { set x [expr $x+1] ; exp_continue } |
454 -re ".*\[Ww\]atchpoint.*buf\\\[2\\\].*Old value = 0.*New value = 51\
[^\n\]*\n" { set x [expr $x+1] ; exp_continue } | 382 -re ".*\[Ww\]atchpoint.*buf\\\[2\\\].*Old value = 0.*New value = 51\
[^\n\]*\n" { set x [expr $x+1] ; exp_continue } |
455 -re ".*\[Ww\]atchpoint.*buf\\\[3\\\].*Old value = 0.*New value = 10\
[^\n\]*\n" { set x [expr $x+1] ; exp_continue } | 383 -re ".*\[Ww\]atchpoint.*buf\\\[3\\\].*Old value = 0.*New value = 10\
[^\n\]*\n" { set x [expr $x+1] ; exp_continue } |
456 » -re ".*$gdb_prompt $" { pass "sent 123" } | 384 » -re ".*$gdb_prompt $" { pass $test } |
457 » timeout { fail "sent 123 (timeout)" } | |
458 } | 385 } |
459 | 386 |
460 # Examine the values in buf to see how many watchpoints we | 387 # Examine the values in buf to see how many watchpoints we |
461 # should have printed. | 388 # should have printed. |
462 » send_gdb "print buf\[0\]\n" | 389 » set test "print buf\[0\]" |
463 » gdb_expect { | 390 » gdb_test_multiple $test $test { |
464 » -re ".*= 49.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[0\
]"} | 391 » -re ".*= 49.*$gdb_prompt $" { set y [expr $y+1]; pass $test } |
465 » -re ".*= 0.*$gdb_prompt $" { pass "print buf\[0\]"} | 392 » -re ".*= 0.*$gdb_prompt $" { $test } |
466 » -re ".*$gdb_prompt $" { fail "print buf\[0\]"} | |
467 » default { fail "print buf\[0\]"} | |
468 } | 393 } |
469 » send_gdb "print buf\[1\]\n" | 394 » set test "print buf\[1\]" |
470 » gdb_expect { | 395 » gdb_test_multiple $test $test { |
471 » -re ".*= 50.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[1\
]"} | 396 » -re ".*= 50.*$gdb_prompt $" { set y [expr $y+1]; pass $test } |
472 » -re ".*= 0.*$gdb_prompt $" { pass "print buf\[1\]"} | 397 » -re ".*= 0.*$gdb_prompt $" { pass $test } |
473 » -re ".*$gdb_prompt $" { fail "print buf\[1\]"} | |
474 » default { fail "print buf\[1\]"} | |
475 } | 398 } |
476 » send_gdb "print buf\[2\]\n" | 399 » set test "print buf\[2\]" |
477 » gdb_expect { | 400 » gdb_test_multiple $test $test { |
478 » -re ".*= 51.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[2\
]"} | 401 » -re ".*= 51.*$gdb_prompt $" { set y [expr $y+1]; pass $test } |
479 » -re ".*= 0.*$gdb_prompt $" { pass "print buf\[2\]"} | 402 » -re ".*= 0.*$gdb_prompt $" { pass $test } |
480 » -re ".*$gdb_prompt $" { fail "print buf\[2\]"} | |
481 » default { fail "print buf\[2\]"} | |
482 } | 403 } |
483 » send_gdb "print buf\[3\]\n" | 404 » set test "print buf\[3\]" |
484 » gdb_expect { | 405 » gdb_test_multiple $test $test { |
485 » -re ".*= 10.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[3\
]"} | 406 » -re ".*= 10.*$gdb_prompt $" { set y [expr $y+1]; pass $test } |
486 » -re ".*= 0.*$gdb_prompt $" { pass "print buf\[3\]"} | 407 » -re ".*= 0.*$gdb_prompt $" { pass $test } |
487 » -re ".*$gdb_prompt $" { fail "print buf\[3\]" } | |
488 » default { fail "print buf\[3\]" } | |
489 } | 408 } |
490 | 409 |
491 # Did we find what we were looking for? If not, flunk it. | 410 # Did we find what we were looking for? If not, flunk it. |
492 if [expr $x==$y] then { pass $testname } else { fail "$testname (only tr
iggered $x watchpoints, expected $y)"} | 411 if [expr $x==$y] then { pass $testname } else { fail "$testname (only tr
iggered $x watchpoints, expected $y)"} |
493 | 412 |
494 # Continue until we hit the finishing marker function. | 413 # Continue until we hit the finishing marker function. |
495 # Make sure we hit no more watchpoints. | 414 # Make sure we hit no more watchpoints. |
496 gdb_test "cont" "Continuing.*Breakpoint.*marker4 \\(\\).*" \ | 415 gdb_test "cont" "Continuing.*Breakpoint.*marker4 \\(\\).*" \ |
497 "continue to marker4" | 416 "continue to marker4" |
498 | 417 |
(...skipping 25 matching lines...) Expand all Loading... |
524 "did not trigger wrong watchpoint" | 443 "did not trigger wrong watchpoint" |
525 | 444 |
526 # Test watches of things declared locally in a function. | 445 # Test watches of things declared locally in a function. |
527 # In particular, test that a watch of stack-based things | 446 # In particular, test that a watch of stack-based things |
528 # is deleted when the stack-based things go out of scope. | 447 # is deleted when the stack-based things go out of scope. |
529 # | 448 # |
530 gdb_test_no_output "disable" "disable in test_complex_watchpoint" | 449 gdb_test_no_output "disable" "disable in test_complex_watchpoint" |
531 gdb_test "break marker6" ".*Breakpoint.*" | 450 gdb_test "break marker6" ".*Breakpoint.*" |
532 gdb_test "cont" "Continuing.*Breakpoint.*marker6 \\(\\).*" \ | 451 gdb_test "cont" "Continuing.*Breakpoint.*marker6 \\(\\).*" \ |
533 "continue to marker6" | 452 "continue to marker6" |
534 gdb_test "break func2" ".*Breakpoint.*" | 453 » gdb_breakpoint [gdb_get_line_number "func2 breakpoint here"] |
535 gdb_test "cont" "Continuing.*func2.*" | 454 » gdb_continue_to_breakpoint "func2 breakpoint here" |
536 | 455 |
537 # Test a watch of a single stack-based variable, whose scope | 456 # Test a watch of a single stack-based variable, whose scope |
538 # is the function we're now in. This should auto-delete when | 457 # is the function we're now in. This should auto-delete when |
539 # execution exits the scope of the watchpoint. | 458 # execution exits the scope of the watchpoint. |
540 # | 459 # |
541 gdb_test "watch local_a" ".*\[Ww\]atchpoint \[0-9\]*: local_a" "set loca
l watch" | 460 gdb_test "watch local_a" ".*\[Ww\]atchpoint \[0-9\]*: local_a" "set loca
l watch" |
542 gdb_test "cont" "\[Ww\]atchpoint.*local_a.*" "trigger local watch" | 461 gdb_test "cont" "\[Ww\]atchpoint.*local_a.*" "trigger local watch" |
543 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the prog
ram has left the block in.*which its expression is valid.*" "self-delete local w
atch" | |
544 | 462 |
545 gdb_test "cont" "Continuing.*func2.*" | 463 » set test "self-delete local watch" |
| 464 gdb_test_multiple "cont" $test { |
| 465 » -re "Continuing.*\[Ww\]atchpoint .* deleted because the program has
left the block in.*which its expression is valid.*\r\n$gdb_prompt $" { |
| 466 » » pass $test |
| 467 » } |
| 468 » -re "can't compute CFA for this frame.*\r\n$gdb_prompt $" { |
| 469 » » global compiler_info no_hw |
| 470 |
| 471 » » # GCC < 4.5.0 does not get LOCATIONS_VALID set by dwarf2read.c. |
| 472 » » # Therefore epilogue unwinder gets applied which is |
| 473 » » # incompatible with dwarf2_frame_cfa. |
| 474 » » verbose -log "compiler_info: $compiler_info" |
| 475 » » if {$no_hw && ([test_compiler_info {gcc-[0-3]-*}] |
| 476 » » » || [test_compiler_info {gcc-4-[0-4]-*}])} { |
| 477 » » xfail "$test (old GCC has broken watchpoints in epilogues)" |
| 478 » » return |
| 479 » » } |
| 480 » » fail $test |
| 481 » } |
| 482 » } |
| 483 |
| 484 » gdb_continue_to_breakpoint "func2 breakpoint here" |
546 # We should be in "func2" again now. Test a watch of an | 485 # We should be in "func2" again now. Test a watch of an |
547 # expression which includes both a stack-based local and | 486 # expression which includes both a stack-based local and |
548 # something whose scope is larger than this invocation | 487 # something whose scope is larger than this invocation |
549 # of "func2". This should also auto-delete. | 488 # of "func2". This should also auto-delete. |
550 # | 489 # |
551 gdb_test "watch local_a + ival5" ".*\[Ww\]atchpoint \[0-9\]*: local_a .
ival5" \ | 490 gdb_test "watch local_a + ival5" ".*\[Ww\]atchpoint \[0-9\]*: local_a .
ival5" \ |
552 "set partially local watch" | 491 "set partially local watch" |
553 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \ | 492 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \ |
554 "trigger1 partially local watch" | 493 "trigger1 partially local watch" |
555 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \ | 494 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \ |
556 "trigger2 partially local watch" | 495 "trigger2 partially local watch" |
557 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the prog
ram has left the block in.*which its expression is valid.*" \ | 496 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the prog
ram has left the block in.*which its expression is valid.*" \ |
558 "self-delete partially local watch" | 497 "self-delete partially local watch" |
559 | 498 |
560 # We should be in "func2" again now. Test a watch of a | 499 # We should be in "func2" again now. Test a watch of a |
561 # static (non-stack-based) local. Since this has scope | 500 # static (non-stack-based) local. Since this has scope |
562 # across any invocations of "func2", it should not auto- | 501 # across any invocations of "func2", it should not auto- |
563 # delete. | 502 # delete. |
564 # | 503 # |
565 gdb_test "cont" "Continuing.*func2.*" | 504 » gdb_continue_to_breakpoint "func2 breakpoint here" |
566 gdb_test "watch static_b" ".*\[Ww\]atchpoint \[0-9\]*: static_b" \ | 505 gdb_test "watch static_b" ".*\[Ww\]atchpoint \[0-9\]*: static_b" \ |
567 "set static local watch" | 506 "set static local watch" |
568 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: static_b.*" \ | 507 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: static_b.*" \ |
569 "trigger static local watch" | 508 "trigger static local watch" |
570 gdb_test "cont" "Continuing.*marker6 \\(\\).*" \ | 509 gdb_test "cont" "Continuing.*marker6 \\(\\).*" \ |
571 "continue after trigger static local watch" | 510 "continue after trigger static local watch" |
572 gdb_test "info break" ".*watchpoint.*static_b.*" \ | 511 gdb_test "info break" ".*watchpoint.*static_b.*" \ |
573 "static local watch did not self-delete" | 512 "static local watch did not self-delete" |
574 | 513 |
575 # We should be in "recurser" now. Test a watch of a stack- | 514 # We should be in "recurser" now. Test a watch of a stack- |
576 # based local. Symbols mentioned in a watchpoint are bound | 515 # based local. Symbols mentioned in a watchpoint are bound |
577 # at watchpoint-creation. Thus, a watch of a stack-based | 516 # at watchpoint-creation. Thus, a watch of a stack-based |
578 # local to a recursing function should be bound only to that | 517 # local to a recursing function should be bound only to that |
579 # one invocation, and should not trigger for other invocations. | 518 # one invocation, and should not trigger for other invocations. |
580 # | 519 # |
581 gdb_test "tbreak recurser" ".*breakpoint.*" | 520 gdb_test "tbreak recurser" ".*breakpoint.*" |
582 gdb_test "cont" "Continuing.*recurser.*" | 521 gdb_test "cont" "Continuing.*recurser.*" |
| 522 gdb_test "next" "if \\(x > 0.*" "next past local_x initialization" |
583 gdb_test "watch local_x" ".*\[Ww\]atchpoint \[0-9\]*: local_x" \ | 523 gdb_test "watch local_x" ".*\[Ww\]atchpoint \[0-9\]*: local_x" \ |
584 "set local watch in recursive call" | 524 "set local watch in recursive call" |
585 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_x.*New value = 2.
*" \ | 525 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_x.*New value = 2.
*" \ |
586 "trigger local watch in recursive call" | 526 "trigger local watch in recursive call" |
587 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the prog
ram has left the block in.*which its expression is valid.*" \ | 527 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the prog
ram has left the block in.*which its expression is valid.*" \ |
588 "self-delete local watch in recursive call" | 528 "self-delete local watch in recursive call" |
589 | 529 |
| 530 # Repeat the preceding test, but this time use "recurser::local_x" as |
| 531 # the variable to track. |
| 532 gdb_test "cont" "Continuing.*marker6.*" |
| 533 gdb_test "tbreak recurser" ".*breakpoint.*" |
| 534 gdb_test "cont" "Continuing.*recurser.*" |
| 535 gdb_test "next" "if \\(x > 0.*" "next past local_x initialization" |
| 536 gdb_test "watch recurser::local_x" ".*\[Ww\]atchpoint \[0-9\]*: recurser
::local_x" \ |
| 537 "set local watch in recursive call with explicit scope" |
| 538 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: recurser::local_x.*New
value = 2.*" \ |
| 539 "trigger local watch with explicit scope in recursive call" |
| 540 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the prog
ram has left the block in.*which its expression is valid.*" \ |
| 541 "self-delete local watch with explicit scope in recursive call
(2)" |
| 542 |
590 # Disable everything so we can finish the program at full speed | 543 # Disable everything so we can finish the program at full speed |
591 gdb_test_no_output "disable" "disable in test_complex_watchpoint" | 544 gdb_test_no_output "disable" "disable in test_complex_watchpoint" |
592 | 545 |
593 if [target_info exists gdb,noresults] { return } | 546 if [target_info exists gdb,noresults] { return } |
594 | 547 |
595 gdb_continue_to_end "continue to exit in test_complex_watchpoint" | 548 gdb_continue_to_end "continue to exit in test_complex_watchpoint" |
596 } | 549 } |
597 } | 550 } |
598 | 551 |
599 proc test_watchpoint_and_breakpoint {} { | 552 proc test_watchpoint_and_breakpoint {} { |
(...skipping 14 matching lines...) Expand all Loading... |
614 kfail "gdb/38" "next after watch x" | 567 kfail "gdb/38" "next after watch x" |
615 } | 568 } |
616 } | 569 } |
617 | 570 |
618 gdb_test_no_output "delete \$bpnum" "delete watch x" | 571 gdb_test_no_output "delete \$bpnum" "delete watch x" |
619 } | 572 } |
620 } | 573 } |
621 | 574 |
622 proc test_constant_watchpoint {} { | 575 proc test_constant_watchpoint {} { |
623 gdb_test "watch 5" "Cannot watch constant value `5'." "number is constant" | 576 gdb_test "watch 5" "Cannot watch constant value `5'." "number is constant" |
| 577 gdb_test "watch (int *)5" "Cannot watch constant value `\\(int \\*\\)5'." \ |
| 578 "number with cast is constant" |
624 gdb_test "watch marker1" "Cannot watch constant value `marker1'." \ | 579 gdb_test "watch marker1" "Cannot watch constant value `marker1'." \ |
625 "marker1 is constant" | 580 "marker1 is constant" |
626 gdb_test "watch count + 6" ".*atchpoint \[0-9\]+: count \\+ 6" | 581 gdb_test "watch count + 6" ".*atchpoint \[0-9\]+: count \\+ 6" |
627 gdb_test_no_output "delete \$bpnum" "delete watchpoint `count + 6'" | 582 gdb_test_no_output "delete \$bpnum" "delete watchpoint `count + 6'" |
628 gdb_test "watch 7 + count" ".*atchpoint \[0-9\]+: 7 \\+ count" | 583 gdb_test "watch 7 + count" ".*atchpoint \[0-9\]+: 7 \\+ count" |
629 gdb_test_no_output "delete \$bpnum" "delete watchpoint `7 + count'" | 584 gdb_test_no_output "delete \$bpnum" "delete watchpoint `7 + count'" |
630 } | 585 } |
631 | 586 |
632 proc test_disable_enable_software_watchpoint {} { | 587 proc test_disable_enable_software_watchpoint {} { |
633 # This is regression test for a bug that caused `enable' to fail | 588 # This is regression test for a bug that caused `enable' to fail |
(...skipping 18 matching lines...) Expand all Loading... |
652 | 607 |
653 gdb_test "watch -location *x" "atchpoint .*: .*" "watch -location .x" | 608 gdb_test "watch -location *x" "atchpoint .*: .*" "watch -location .x" |
654 | 609 |
655 gdb_test "continue" \ | 610 gdb_test "continue" \ |
656 "Continuing.*\[Ww\]atchpoint .*: .*New value = 27.*" \ | 611 "Continuing.*\[Ww\]atchpoint .*: .*New value = 27.*" \ |
657 "continue with watch -location" | 612 "continue with watch -location" |
658 | 613 |
659 gdb_test_no_output "delete \$bpnum" "delete watch -location" | 614 gdb_test_no_output "delete \$bpnum" "delete watch -location" |
660 } | 615 } |
661 | 616 |
| 617 # Tests watching areas larger than a word. |
| 618 |
| 619 proc test_wide_location_1 {} { |
| 620 global no_hw |
| 621 global gdb_prompt |
| 622 |
| 623 # This test watches two words on most 32-bit ABIs, and one word on |
| 624 # most 64-bit ABIs. |
| 625 |
| 626 # Platforms where the target can't watch such a large region |
| 627 # should clear hw_expected below. |
| 628 if { $no_hw || [target_info exists gdb,no_hardware_watchpoints] |
| 629 || [istarget arm*-*-*] |
| 630 || ([istarget powerpc*-*-*] && ![is_lp64_target])} { |
| 631 set hw_expected 0 |
| 632 } else { |
| 633 set hw_expected 1 |
| 634 } |
| 635 |
| 636 gdb_breakpoint [gdb_get_line_number "func6 breakpoint here"] |
| 637 gdb_continue_to_breakpoint "func6 breakpoint here" |
| 638 |
| 639 if { $hw_expected } { |
| 640 gdb_test "watch foo2" "Hardware watchpoint .*: .*" "watch foo2" |
| 641 gdb_test "continue" \ |
| 642 "Continuing.*Hardware watchpoint .*: .*New value = \\\{val = \\\{0,
11\\\}\\\}.*" \ |
| 643 "continue with watch foo2" |
| 644 } else { |
| 645 gdb_test "watch foo2" "atchpoint .*: .*" "watch foo2" |
| 646 set test "continue with watch foo2" |
| 647 gdb_test_multiple "cont" $test { |
| 648 -re "Continuing.*\[Ww\]atchpoint .*: .*New value = \\\{val = \\\{0,
11\\\}\\\}.*$gdb_prompt $" { |
| 649 pass $test |
| 650 } |
| 651 -re "Could not insert hardware breakpoints:.*You may have requested
too many hardware breakpoints/watchpoints.*$gdb_prompt $" { |
| 652 # This may happen with remote targets that support |
| 653 # hardware watchpoints. We only find out the |
| 654 # watchpoint was too large, for example, at insert |
| 655 # time. If GDB is ever adjusted to downgrade the |
| 656 # watchpoint automatically in this case, this match |
| 657 # should be removed. |
| 658 pass $test |
| 659 } |
| 660 } |
| 661 } |
| 662 |
| 663 gdb_test_no_output "delete \$bpnum" "delete watch foo2" |
| 664 } |
| 665 |
| 666 proc test_wide_location_2 {} { |
| 667 global no_hw |
| 668 global gdb_prompt |
| 669 |
| 670 # This test watches four words on most 32-bit ABIs, and two words |
| 671 # on 64-bit ABIs. |
| 672 |
| 673 # Platforms where the target can't watch such a large region |
| 674 # should clear hw_expected below. |
| 675 if { $no_hw || [target_info exists gdb,no_hardware_watchpoints] |
| 676 || [istarget arm*-*-*] |
| 677 || [istarget powerpc*-*-*]} { |
| 678 set hw_expected 0 |
| 679 } else { |
| 680 set hw_expected 1 |
| 681 } |
| 682 |
| 683 gdb_breakpoint [gdb_get_line_number "func7 breakpoint here"] |
| 684 gdb_continue_to_breakpoint "func7 breakpoint here" |
| 685 |
| 686 if { $hw_expected } { |
| 687 gdb_test "watch foo4" "Hardware watchpoint .*: .*" "watch foo4" |
| 688 gdb_test "continue" \ |
| 689 "Continuing.*Hardware watchpoint .*: .*New value = \\\{val = \\\{0,
0, 0, 33\\\}\\\}.*" \ |
| 690 "continue with watch foo4" |
| 691 } else { |
| 692 gdb_test "watch foo4" "atchpoint .*: .*" "watch foo4" |
| 693 set test "continue with watch foo4" |
| 694 gdb_test_multiple "cont" $test { |
| 695 -re "Continuing.*\[Ww\]atchpoint .*: .*New value = \\\{val = \\\{0,
0, 0, 33\\\}\\\}.*$gdb_prompt $" { |
| 696 pass $test |
| 697 } |
| 698 -re "Could not insert hardware breakpoints:.*You may have requested
too many hardware breakpoints/watchpoints.*$gdb_prompt $" { |
| 699 # This may happen with remote targets that support |
| 700 # hardware watchpoints. We only find out the |
| 701 # watchpoint was too large, for example, at insert |
| 702 # time. If GDB is ever adjusted to downgrade the |
| 703 # watchpoint automatically in this case, this match |
| 704 # should be removed. |
| 705 pass $test |
| 706 } |
| 707 } |
| 708 } |
| 709 |
| 710 gdb_test_no_output "delete \$bpnum" "delete watch foo4" |
| 711 } |
| 712 |
662 proc test_inaccessible_watchpoint {} { | 713 proc test_inaccessible_watchpoint {} { |
663 global gdb_prompt | 714 global gdb_prompt |
664 | 715 |
665 # This is a test for watchpoints on currently inaccessible (but later | 716 # This is a test for watchpoints on currently inaccessible (but later |
666 # valid) memory. | 717 # valid) memory. |
667 | 718 |
668 if [runto func4] then { | 719 if [runto func4] then { |
669 # Make sure we only allow memory access errors. | 720 # Make sure we only allow memory access errors. |
670 set msg "watchpoint refused to insert on nonexistent struct member" | 721 set msg "watchpoint refused to insert on nonexistent struct member" |
671 gdb_test_multiple "watch struct1.nosuchmember" $msg { | 722 gdb_test_multiple "watch struct1.nosuchmember" $msg { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 } | 772 } |
722 } | 773 } |
723 gdb_test_multiple "next" "next over buffer set" { | 774 gdb_test_multiple "next" "next over buffer set" { |
724 -re ".*atchpoint \[0-9\]+: \\*global_ptr\r\n\r\nOld value = 3 .*\r\n
New value = 7 .*\r\n.*$gdb_prompt $" { | 775 -re ".*atchpoint \[0-9\]+: \\*global_ptr\r\n\r\nOld value = 3 .*\r\n
New value = 7 .*\r\n.*$gdb_prompt $" { |
725 pass "next over buffer set" | 776 pass "next over buffer set" |
726 } | 777 } |
727 } | 778 } |
728 gdb_test "delete \$global_ptr_breakpoint_number" "" | 779 gdb_test "delete \$global_ptr_breakpoint_number" "" |
729 gdb_test "watch **global_ptr_ptr" ".*atchpoint \[0-9\]+: \\*\\*global_pt
r_ptr" | 780 gdb_test "watch **global_ptr_ptr" ".*atchpoint \[0-9\]+: \\*\\*global_pt
r_ptr" |
730 gdb_test "set \$global_ptr_ptr_breakpoint_number = \$bpnum" "" | 781 gdb_test "set \$global_ptr_ptr_breakpoint_number = \$bpnum" "" |
731 » gdb_test "next" ".*global_ptr_ptr = &global_ptr.*" "gloabl_ptr_ptr next" | 782 » gdb_test "next" ".*global_ptr_ptr = &global_ptr.*" "global_ptr_ptr next" |
732 gdb_test "next" ".*atchpoint \[0-9\]+: \\*\\*global_ptr_ptr\[\r\n\]+Old
value = .*\r\nNew value = 7 .*" "next over global_ptr_ptr init" | 783 gdb_test "next" ".*atchpoint \[0-9\]+: \\*\\*global_ptr_ptr\[\r\n\]+Old
value = .*\r\nNew value = 7 .*" "next over global_ptr_ptr init" |
733 gdb_test "next" ".*atchpoint \[0-9\]+: \\*\\*global_ptr_ptr\[\r\n\]+Old
value = 7 .*\r\nNew value = 9 .*" "next over global_ptr_ptr buffer set" | 784 gdb_test "next" ".*atchpoint \[0-9\]+: \\*\\*global_ptr_ptr\[\r\n\]+Old
value = 7 .*\r\nNew value = 9 .*" "next over global_ptr_ptr buffer set" |
734 gdb_test "next" ".*atchpoint \[0-9\]+: \\*\\*global_ptr_ptr\[\r\n\]+Old
value = 9 .*\r\nNew value = 5 .*" "next over global_ptr_ptr pointer advance" | 785 gdb_test "next" ".*atchpoint \[0-9\]+: \\*\\*global_ptr_ptr\[\r\n\]+Old
value = 9 .*\r\nNew value = 5 .*" "next over global_ptr_ptr pointer advance" |
735 gdb_test_no_output "delete \$global_ptr_ptr_breakpoint_number" | 786 gdb_test_no_output "delete \$global_ptr_ptr_breakpoint_number" |
736 } | 787 } |
737 } | 788 } |
738 | 789 |
| 790 proc test_no_hw_watchpoints {} { |
| 791 global testfile |
| 792 |
| 793 clean_restart $testfile |
| 794 |
| 795 # Verify that a user can force GDB to use "slow" watchpoints. |
| 796 # (This proves rather little on kernels that don't support |
| 797 # fast watchpoints, but still...) |
| 798 # |
| 799 if ![runto_main] then { fail "watch tests suppressed" } |
| 800 |
| 801 gdb_test_no_output "set can-use-hw-watchpoints 0" "disable fast watches" |
| 802 |
| 803 gdb_test "show can-use-hw-watchpoints" \ |
| 804 » "Debugger's willingness to use watchpoint hardware is 0." \ |
| 805 » "show disable fast watches" |
| 806 |
| 807 gdb_test "watch ival3 if count > 1" \ |
| 808 » "Watchpoint \[0-9\]*: ival3.*" \ |
| 809 » "set slow conditional watch" |
| 810 |
| 811 gdb_test "continue" \ |
| 812 » "Watchpoint \[0-9\]*: ival3.*Old value = 1.*New value = 2.*" \ |
| 813 » "trigger slow conditional watch" |
| 814 |
| 815 gdb_test_no_output "delete \$bpnum" "delete watch ival3" |
| 816 |
| 817 # We've explicitly disabled hardware watches. Verify that GDB |
| 818 # refrains from using them. |
| 819 # |
| 820 gdb_test "rwatch ival3" \ |
| 821 » "Expression cannot be implemented with read/access watchpoint..*" \ |
| 822 » "rwatch disallowed when can-set-hw-watchpoints cleared" |
| 823 |
| 824 # Re-enable hardware watchpoints if necessary. |
| 825 if ![target_info exists gdb,no_hardware_watchpoints] { |
| 826 gdb_test_no_output "set can-use-hw-watchpoints 1" "" |
| 827 } |
| 828 } |
| 829 |
739 proc test_watchpoint_in_big_blob {} { | 830 proc test_watchpoint_in_big_blob {} { |
740 global gdb_prompt | 831 global gdb_prompt |
741 | 832 |
742 gdb_test "watch buf" ".*atchpoint \[0-9\]+: buf" | 833 # On native targets where we do hardware resource accounting, this |
743 gdb_test "cont" "Continuing.*atchpoint \[0-9\]+: buf\r\n\r\nOld value = .*te
stte\".*" "watchpoint on buf hit" | 834 # may end up as a software watchpoint. |
| 835 set ok 0 |
| 836 set test "watch buf" |
| 837 gdb_test_multiple "watch buf" $test { |
| 838 » -re "Hardware watchpoint \[0-9\]+: buf.*You may have requested too many
hardware breakpoints/watchpoints.*$gdb_prompt $" { |
| 839 » # This may happen with remote targets (where we don't do |
| 840 » # resource accounting) that support hardware watchpoints, |
| 841 » # when breakpoint always-inserted is on. The watchpoint |
| 842 » # was too large, for example. If GDB is ever adjusted to |
| 843 » # downgrade the watchpoint automatically in this case, |
| 844 » # this match should be removed. Note the breakpoint has |
| 845 » # been created, and is in the list, so it needs deleting. |
| 846 » pass $test |
| 847 » } |
| 848 » -re ".*atchpoint \[0-9\]+: buf.*$gdb_prompt $" { |
| 849 » pass $test |
| 850 » set ok 1 |
| 851 » } |
| 852 } |
| 853 |
| 854 if { $ok } { |
| 855 » set test "watchpoint on buf hit" |
| 856 » gdb_test_multiple "cont" $test { |
| 857 » -re "Continuing.*atchpoint \[0-9\]+: buf\r\n\r\nOld value = .*testte
\".*$gdb_prompt $" { |
| 858 » » pass $test |
| 859 » } |
| 860 » -re "Could not insert hardware breakpoints:.*You may have requested
too many hardware breakpoints/watchpoints.*$gdb_prompt $" { |
| 861 » » # This may happen with remote targets that support |
| 862 » » # hardware watchpoints. We only find out the |
| 863 » » # watchpoint was too large, for example, at insert |
| 864 » » # time. If GDB is ever adjusted to downgrade the |
| 865 » » # watchpoint automatically in this case, this match |
| 866 » » # should be removed. |
| 867 » » pass $test |
| 868 » } |
| 869 » } |
| 870 } |
744 | 871 |
745 gdb_test_no_output "delete \$bpnum" "delete watch buf" | 872 gdb_test_no_output "delete \$bpnum" "delete watch buf" |
746 } | 873 } |
747 | 874 |
748 # Start with a fresh gdb. | 875 # Start with a fresh gdb. |
749 | 876 |
750 gdb_exit | |
751 gdb_start | |
752 gdb_reinitialize_dir $srcdir/$subdir | |
753 gdb_load $binfile | |
754 set prev_timeout $timeout | 877 set prev_timeout $timeout |
755 set timeout 600 | 878 set timeout 600 |
756 verbose "Timeout now 600 sec.\n" | 879 verbose "Timeout now 600 sec.\n" |
757 | 880 |
758 if [initialize] then { | 881 test_no_hw_watchpoints |
759 | 882 |
760 test_simple_watchpoint | 883 proc do_tests {} { |
| 884 global testfile |
| 885 global no_hw |
761 | 886 |
762 # The IDT/sim monitor only has 8 (!) open files, of which it uses | 887 clean_restart $testfile |
763 # 4 (!). So we have to make sure one program exits before | 888 |
764 # starting another one. | 889 if {$no_hw || [target_info exists gdb,no_hardware_watchpoints]} { |
765 if [istarget "mips-idt-*"] then { | 890 » gdb_test_no_output "set can-use-hw-watchpoints 0" "" |
766 » gdb_exit | |
767 » gdb_start | |
768 » gdb_reinitialize_dir $srcdir/$subdir | |
769 » gdb_load $binfile | |
770 » initialize | |
771 } | 891 } |
772 | 892 |
773 test_disabling_watchpoints | 893 if [initialize] then { |
774 | 894 |
775 # See above. | 895 » test_simple_watchpoint |
776 if [istarget "mips-idt-*"] then { | 896 |
777 » gdb_exit | 897 » test_disabling_watchpoints |
778 » gdb_start | 898 |
779 » gdb_reinitialize_dir $srcdir/$subdir | 899 » if ![target_info exists gdb,cannot_call_functions] { |
780 » gdb_load $binfile | 900 » test_stepping |
781 » initialize | 901 » } |
782 } | 902 } |
783 | 903 |
784 if ![target_info exists gdb,cannot_call_functions] { | 904 # Tests below don't rely on the markers and watchpoint set by |
785 » test_stepping | 905 # `initialize' anymore. |
| 906 clean_restart $testfile |
786 | 907 |
787 » # See above. | 908 if {$no_hw || [target_info exists gdb,no_hardware_watchpoints]} { |
788 » if [istarget "mips-idt-*"] then { | 909 » gdb_test_no_output "set can-use-hw-watchpoints 0" "" |
789 » gdb_exit | |
790 » gdb_start | |
791 » gdb_reinitialize_dir $srcdir/$subdir | |
792 » gdb_load $binfile | |
793 » initialize | |
794 » } | |
795 } | 910 } |
796 | 911 |
797 # Only enabled for some targets merely because it has not been tested | 912 # Only enabled for some targets merely because it has not been tested |
798 # elsewhere. | 913 # elsewhere. |
799 # On sparc-sun-sunos4.1.3, GDB was running all the way to the marker4 | 914 # On sparc-sun-sunos4.1.3, GDB was running all the way to the marker4 |
800 # breakpoint before stopping for the watchpoint. I don't know why. | 915 # breakpoint before stopping for the watchpoint. I don't know why. |
801 if {[istarget "hppa*-*-*"]} then { | 916 if {[istarget "hppa*-*-*"]} then { |
802 test_watchpoint_triggered_in_syscall | 917 test_watchpoint_triggered_in_syscall |
803 } | 918 } |
804 | 919 |
805 # See above. | 920 test_complex_watchpoint |
806 if [istarget "mips-idt-*"] then { | |
807 » gdb_exit | |
808 » gdb_start | |
809 » gdb_reinitialize_dir $srcdir/$subdir | |
810 » gdb_load $binfile | |
811 » initialize | |
812 } | |
813 | |
814 # Only enabled for some targets merely because it has not been tested | |
815 # elsewhere. | |
816 if {[istarget "hppa*-*-*"] || \ | |
817 » [istarget "sparc*-*-sunos*"] || \ | |
818 » [istarget "m32r-*-*"]} then { | |
819 » test_complex_watchpoint | |
820 } | |
821 | 921 |
822 test_inaccessible_watchpoint | 922 test_inaccessible_watchpoint |
823 | 923 |
824 # Verify that a user can force GDB to use "slow" watchpoints. | |
825 # (This proves rather little on kernels that don't support | |
826 # fast watchpoints, but still...) | |
827 # | |
828 if ![runto_main] then { fail "watch tests suppressed" } | |
829 | |
830 send_gdb "set can-use-hw-watchpoints 0\n" | |
831 gdb_expect { | |
832 -re "$gdb_prompt $"\ | |
833 {pass "disable fast watches"} | |
834 timeout {fail "(timeout) disable fast watches"} | |
835 } | |
836 send_gdb "show can-use-hw-watchpoints\n" | |
837 gdb_expect { | |
838 -re "Debugger's willingness to use watchpoint hardware is 0.*$gdb_prompt $
"\ | |
839 {pass "show disable fast watches"} | |
840 -re "$gdb_prompt $"\ | |
841 {fail "show disable fast watches"} | |
842 timeout {fail "(timeout) show disable fast watches"} | |
843 } | |
844 send_gdb "watch ival3 if count > 1\n" | |
845 gdb_expect { | |
846 -re "Watchpoint \[0-9\]*: ival3.*$gdb_prompt $"\ | |
847 {pass "set slow conditional watch"} | |
848 -re "$gdb_prompt $"\ | |
849 {fail "set slow conditional watch"} | |
850 timeout {fail "(timeout) set slow conditional watch"} | |
851 } | |
852 send_gdb "continue\n" | |
853 gdb_expect { | |
854 -re "Watchpoint \[0-9\]*: ival3.*Old value = 1.*New value = 2.*$gdb_prompt
$"\ | |
855 {pass "trigger slow conditional watch"} | |
856 -re "$gdb_prompt $"\ | |
857 {fail "trigger slow conditional watch"} | |
858 timeout {fail "(timeout) trigger slow conditional watch"} | |
859 } | |
860 | |
861 # We've explicitly disabled hardware watches. Verify that GDB | |
862 # refrains from using them. | |
863 # | |
864 send_gdb "rwatch ival3\n" | |
865 gdb_expect { | |
866 -re "Expression cannot be implemented with read/access watchpoint..*$gdb_p
rompt $"\ | |
867 {pass "rwatch disallowed when can-set-hw-watchpoints cleared"} | |
868 -re "$gdb_prompt $"\ | |
869 {fail "rwatch disallowed when can-set-hw-watchpoints cleared"} | |
870 timeout {fail "(timeout) rwatch disallowed when can-use-hw-watchpoints cle
ared"} | |
871 } | |
872 | |
873 # Read- and access watchpoints are unsupported on HP-UX. Verify | |
874 # that GDB gracefully responds to requests to create them. | |
875 # | |
876 if [istarget "hppa*-*-hpux*"] then { | |
877 send_gdb "set can-use-hw-watchpoints 1\n" | |
878 gdb_expect { | |
879 -re "$gdb_prompt $"\ | |
880 {pass "enable fast watches"} | |
881 timeout {fail "(timeout) enable fast watches"} | |
882 } | |
883 send_gdb "rwatch ival3\n" | |
884 gdb_expect { | |
885 -re "Target does not have this type of hardware watchpoint support.*$gdb
_prompt $"\ | |
886 {pass "read watches disallowed"} | |
887 -re "$gdb_prompt $"\ | |
888 {fail "read watches disallowed"} | |
889 timeout {fail "(timeout) read watches disallowed"} | |
890 } | |
891 | |
892 send_gdb "awatch ival3\n" | |
893 gdb_expect { | |
894 -re "Target does not have this type of hardware watchpoint support.*$gdb
_prompt $"\ | |
895 {pass "access watches disallowed"} | |
896 -re "$gdb_prompt $"\ | |
897 {fail "access watches disallowed"} | |
898 timeout {fail "(timeout) access watches disallowed"} | |
899 } | |
900 } | |
901 | |
902 # See above. | |
903 if [istarget "mips-idt-*"] then { | |
904 gdb_exit | |
905 gdb_start | |
906 gdb_reinitialize_dir $srcdir/$subdir | |
907 gdb_load $binfile | |
908 initialize | |
909 } | |
910 | |
911 test_watchpoint_and_breakpoint | 924 test_watchpoint_and_breakpoint |
912 | 925 |
913 test_watchpoint_in_big_blob | 926 test_watchpoint_in_big_blob |
914 | 927 |
915 # See above. | |
916 if [istarget "mips-idt-*"] then { | |
917 clean_restart | |
918 } | |
919 | |
920 test_constant_watchpoint | 928 test_constant_watchpoint |
921 | 929 |
922 test_disable_enable_software_watchpoint | 930 test_disable_enable_software_watchpoint |
923 | 931 |
924 test_watch_location | 932 test_watch_location |
| 933 |
| 934 test_wide_location_1 |
| 935 test_wide_location_2 |
| 936 } |
| 937 |
| 938 # On targets that can do hardware watchpoints, run the tests twice: |
| 939 # once with hardware watchpoints enabled; another with hardware |
| 940 # watchpoints force-disabled. |
| 941 |
| 942 do_tests |
| 943 if ![target_info exists gdb,no_hardware_watchpoints] { |
| 944 with_test_prefix "no-hw" { |
| 945 set no_hw 1 |
| 946 do_tests |
| 947 } |
925 } | 948 } |
926 | 949 |
927 # Restore old timeout | 950 # Restore old timeout |
928 set timeout $prev_timeout | 951 set timeout $prev_timeout |
929 verbose "Timeout now $timeout sec.\n" | 952 verbose "Timeout now $timeout sec.\n" |
OLD | NEW |