1 # Copyright (C) 1992, 1994, 1997, 1998 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:
29 set testfile "watchpoint"
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
35 if [get_compiler_info ${binfile}] {
39 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
40 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
43 # Prepare for watchpoint tests by setting up two breakpoints and one
46 # We use breakpoints at marker functions to get past all the startup code,
47 # so we can get to the watchpoints in a reasonable amount of time from a
48 # known starting point.
50 # For simplicity, so we always know how to reference specific breakpoints or
51 # watchpoints by number, we expect a particular ordering and numbering of
52 # each in the combined breakpoint/watchpoint table, as follows:
55 # 1 Breakpoint marker1()
56 # 2 Breakpoint marker2()
66 if [gdb_test "break marker1" "Breakpoint 1 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker1" ] {
71 if [gdb_test "break marker2" "Breakpoint 2 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker2" ] {
76 if [gdb_test "info break" "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*" "info break in watchpoint.exp" ] {
81 # ??rehrauer: To fix DTS #CHFts23014, in which setting a watchpoint
82 # before running can cause the inferior to croak on HP-UX 10.30 and
83 # 11.0 for reasons as yet unknown, we've disabled the ability to set
84 # watches without a running inferior. Verify the restriction.
86 send_gdb "watch ival3\n"
88 -re ".*\[Ww\]atchpoint 3: ival3.*$gdb_prompt $" {
89 pass "set watchpoint on ival3"
91 -re "warning: can't do that without a running program; try \"break main\", \"run\" first.*$gdb_prompt $" {
92 pass "set watchpoint on ival3"
97 fail "(timeout) set watchpoint on ival3"
102 # "info watch" is the same as "info break"
104 if [gdb_test "info watch" "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*\r\n3\[ \]*.*watchpoint.*ival3" "watchpoint found in watchpoint/breakpoint table" ] {
109 # After installing the watchpoint, we disable it until we are ready
110 # to use it. This allows the test program to run at full speed until
111 # we get to the first marker function.
113 if [gdb_test "disable 3" "disable 3\[\r\n\]+" "disable watchpoint" ] {
122 # Test simple watchpoint.
125 proc test_simple_watchpoint {} {
131 # Ensure that the watchpoint is disabled when we startup.
134 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_simple_watchpoint" ] {
140 # Run until we get to the first marker function.
145 -re "Breakpoint 1, marker1 .*$gdb_prompt $" {
146 pass "run to marker1 in test_simple_watchpoint"
148 -re ".*$gdb_prompt $" {
149 fail "run to marker1 in test_simple_watchpoint"
153 fail "run to marker1 in test_simple_watchpoint (timeout)"
159 # ??rehrauer: To fix DTS #CHFts23014, in which setting a watchpoint
160 # before running can cause the inferior to croak on HP-UX 10.30 and
161 # 11.0 for reasons as yet unknown, we've disabled the ability to set
162 # watches without a running inferior. The following testpoints used
163 # to be in [initialize].
165 send_gdb "watch ival3\n"
167 -re ".*\[Ww\]atchpoint 3: ival3\r\n$gdb_prompt $" {
168 pass "set watchpoint on ival3"
170 -re ".*$gdb_prompt $" { fail "set watchpoint on ival3" }
171 timeout { fail "set watchpoint on ival3 (timeout)" }
176 # "info watch" is the same as "info break"
178 send_gdb "info watch\n"
180 -re "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*\r\n3\[ \]*.*watchpoint.*ival3\r\n$gdb_prompt $" {
181 pass "watchpoint found in watchpoint/breakpoint table"
183 -re ".*$gdb_prompt $" {
184 fail "watchpoint found in watchpoint/breakpoint table"
187 fail "watchpoint found in watchpoint/breakpoint table"
191 # After installing the watchpoint, we disable it until we are ready
192 # to use it. This allows the test program to run at full speed until
193 # we get to the first marker function.
195 send_gdb "disable 3\n"
197 -re "disable 3\[\r\n\]+$gdb_prompt $" { pass "disable watchpoint" }
198 -re ".*$gdb_prompt $" { fail "disable watchpoint" }
199 timeout { fail "disable watchpoint (timeout)" }
203 # After reaching the marker function, enable the watchpoint.
205 if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "enable watchpoint" ] {
210 gdb_test "break func1" "Breakpoint.*at.*"
211 gdb_test "set \$func1_breakpoint_number = \$bpnum" ""
213 gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, func1.*" \
214 "continue to breakpoint at func1"
216 # Continue until the first change, from -1 to 0
220 -re "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*$gdb_prompt $" {
221 pass "watchpoint hit, first time"
223 -re "Continuing.*Breakpoint.*func1.*$gdb_prompt $" {
224 setup_xfail "m68*-*-*" 2597
225 fail "thought it hit breakpoint at func1 twice"
226 gdb_test "delete \$func1_breakpoint_number" ""
227 gdb_test "continue" "\
228 Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count;" \
229 "watchpoint hit, first time"
231 -re ".*$gdb_prompt $" { fail "watchpoint hit, first time" ; return }
232 timeout { fail "watchpoint hit, first time (timeout)" ; return }
233 eof { fail "watchpoint hit, first time (eof)" ; return }
236 gdb_test "delete \$func1_breakpoint_number" ""
238 # Continue until the next change, from 0 to 1.
239 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" "watchpoint hit, second time"
241 # Continue until the next change, from 1 to 2.
242 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" "watchpoint hit, third time"
244 # Continue until the next change, from 2 to 3.
245 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" "watchpoint hit, fourth time"
247 # Continue until the next change, from 3 to 4.
248 # Note that this one is outside the loop.
250 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" "watchpoint hit, fifth time"
252 # Continue until we hit the finishing marker function.
253 # Make sure we hit no more watchpoints.
255 gdb_test "cont" "Continuing.*Breakpoint.*marker2 \(\).*" \
256 "continue to marker2"
258 # Disable the watchpoint so we run at full speed until we exit.
260 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "watchpoint disabled" ] {
265 # Run until process exits.
267 if [target_info exists gdb,noresults] { return }
269 gdb_continue_to_end "continue to exit in test_simple_watchpoint"
272 # Test disabling watchpoints.
274 proc test_disabling_watchpoints {} {
281 # "info watch" is the same as "info break"
282 gdb_test "info watch" "\[0-9\]+\[ \]*breakpoint.*marker1.*\r\n\[0-9\]+\[ \]*breakpoint.*marker2.*\r\n\[0-9]+\[ \]*.*watchpoint.*ival3\r\n\.*\[0-9\]+ times.*" "watchpoints found in watchpoint/breakpoint table"
284 # Ensure that the watchpoint is disabled when we startup.
286 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_disabling_watchpoints" ] {
291 # Run until we get to the first marker function.
296 -re "Breakpoint 1, marker1 .*$gdb_prompt $" {
297 pass "run to marker1 in test_disabling_watchpoints"
299 -re ".*$gdb_prompt $" {
300 fail "run to marker1 in test_disabling_watchpoints"
304 fail "run to marker1 in test_disabling_watchpoints (timeout)"
309 # After reaching the marker function, enable the watchpoint.
311 if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "watchpoint enabled" ] {
316 # Continue until the first change, from -1 to 0
317 # Don't check the old value, because on VxWorks the variable value
318 # will not have been reinitialized.
319 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = .*New value = 0.*ival3 = count; ival4 = count;.*" "watchpoint hit in test_disabling_watchpoints, first time"
321 # Continue until the next change, from 0 to 1.
322 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" "watchpoint hit in test_disabling_watchpoints, second time"
324 # Disable the watchpoint but leave breakpoints
326 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint #2 in test_disabling_watchpoints" ] {
331 # Check watchpoint list, looking for the entry that confirms the
332 # watchpoint is disabled.
333 gdb_test "info watchpoints" "\[0-9]+\[ \]*.*watchpoint\[ \]*keep\[ \]*n\[ \]*ival3\r\n.*" "watchpoint disabled in table"
335 # Continue until we hit the finishing marker function.
336 # Make sure we hit no more watchpoints.
337 gdb_test "cont" "Continuing.*Breakpoint.*marker2 \\(\\).*" \
338 "disabled watchpoint skipped"
340 if [target_info exists gdb,noresults] { return }
342 gdb_continue_to_end "continue to exit in test_disabling_watchpoints"
345 # Test stepping and other mundane operations with watchpoints enabled
346 proc test_stepping {} {
349 if [runto marker1] then {
350 gdb_test "watch ival2" ".*\[Ww\]atchpoint \[0-9\]*: ival2"
352 # Well, let's not be too mundane. It should be a *bit* of a challenge
353 gdb_test "break func2 if 0" "Breakpoint.*at.*"
354 gdb_test "p \$func2_breakpoint_number = \$bpnum" " = .*"
356 # The problem is that GDB confuses stepping through the call
357 # dummy with hitting the breakpoint at the end of the call dummy.
358 # Will be fixed once all architectures define
359 # CALL_DUMMY_BREAKPOINT_OFFSET.
361 # This doesn't occur if the call dummy starts with a call,
362 # because we are out of the dummy by the first time the inferior
364 clear_xfail "d10v*-*-*"
365 clear_xfail "m68*-*-*"
366 clear_xfail "i*86*-*-*"
367 clear_xfail "vax-*-*"
368 # The following architectures define CALL_DUMMY_BREAKPOINT_OFFSET.
369 clear_xfail "alpha-*-*"
370 clear_xfail "mips*-*-*"
371 clear_xfail "sparc-*-*"
372 clear_xfail "hppa*-*-*bsd*"
373 # It works with the generic inferior function calling code too.
374 clear_xfail "mn10200*-*-*"
375 clear_xfail "mn10300*-*-*"
376 # The following architectures define CALL_DUMMY_HAS_COMPLETED.
377 clear_xfail "hppa*-*-*hpux*"
378 gdb_test "p func1 ()" "= 73" \
379 "calling function with watchpoint enabled"
382 # "finish" brings us back to main.
383 # On some targets (e.g. alpha) gdb will stop from the finish in midline
384 # of the marker1 call. This is due to register restoring code on
385 # the alpha and might be caused by stack adjustment instructions
386 # on other targets. In this case we will step once more.
391 -re "Run.*exit from.*marker1.* at" { }
392 default { fail "finish from marker1" ; return }
396 -re "marker1 \\(\\);.*$gdb_prompt $" {
400 -re "func1 \\(\\);.*$gdb_prompt $" {
401 pass "finish from marker1"
403 -re ".*$gdb_prompt $" {
404 fail "finish from marker1"
406 default { fail "finish from marker1" ; return }
409 gdb_test "next" "for \\(count = 0.*" "next to `for' in watchpoint.exp"
411 # Now test that "until" works. It's a bit tricky to test
412 # "until", because compilers don't always arrange the code
413 # exactly the same way, and we might get slightly different
414 # sequences of statements. But the following should be true
415 # (if not it is a compiler or a debugger bug): The user who
416 # does "until" at every statement of a loop should end up
417 # stepping through the loop once, and the debugger should not
418 # stop for any of the remaining iterations.
420 gdb_test "until" "ival1 = count.*" "until to ival1 assignment"
421 gdb_test "until" "ival3 = count.*" "until to ival3 assignment"
424 -re "(for \\(count = 0|\}).*$gdb_prompt $" {
425 gdb_test "until" "ival1 = count; /. Outside loop ./" \
428 -re "ival1 = count; /. Outside loop ./.*$gdb_prompt $" {
429 pass "until out of loop"
431 -re ".*$gdb_prompt $" {
432 fail "until out of loop"
434 default { fail "until out of loop" ; return }
437 gdb_test "step" "ival2 = count.*" "step to ival2 assignment"
441 # Test stepping and other mundane operations with watchpoints enabled
442 proc test_watchpoint_triggered_in_syscall {} {
445 if [target_info exists gdb,noinferiorio] {
446 verbose "Skipping test_watchpoint_triggered_in_syscall due to noinferiorio"
449 # Run until we get to the first marker function.
452 set testname "Watch buffer passed to read syscall"
453 if [runto marker2] then {
454 gdb_test "watch buf\[0\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[0\\\]"
455 gdb_test "watch buf\[1\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[1\\\]"
456 gdb_test "watch buf\[2\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[2\\\]"
457 gdb_test "watch buf\[3\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[3\\\]"
458 gdb_test "watch buf\[4\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[4\\\]"
459 gdb_test "break marker4" ".*Breakpoint.*"
461 gdb_test "set doread = 1" ""
463 # If we send_gdb "123\n" before gdb has switched the tty, then it goes
464 # to gdb, not the inferior, and we lose. So that is why we have
465 # watchpoint.c prompt us, so we can wait for that prompt.
466 send_gdb "continue\n";
468 -re "Continuing\\.\r\ntype stuff for buf now:" {
469 pass "continue to read"
472 fail "continue to read";
479 -re ".*\[Ww\]atchpoint.*buf\\\[0\\\].*Old value = 0.*New value = 49\[^\n\]*\n" { set x [expr $x+1] ; exp_continue }
480 -re ".*\[Ww\]atchpoint.*buf\\\[1\\\].*Old value = 0.*New value = 50\[^\n\]*\n" { set x [expr $x+1] ; exp_continue }
481 -re ".*\[Ww\]atchpoint.*buf\\\[2\\\].*Old value = 0.*New value = 51\[^\n\]*\n" { set x [expr $x+1] ; exp_continue }
482 -re ".*\[Ww\]atchpoint.*buf\\\[3\\\].*Old value = 0.*New value = 10\[^\n\]*\n" { set x [expr $x+1] ; exp_continue }
483 -re ".*$gdb_prompt $" { pass "sent 123" }
484 timeout { fail "sent 123 (timeout)" }
487 # Examine the values in buf to see how many watchpoints we
488 # should have printed.
489 send_gdb "print buf\[0\]\n"
491 -re ".*= 49.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[0\]"}
492 -re ".*= 0.*$gdb_prompt $" { pass "print buf\[0\]"}
493 -re ".*$gdb_prompt $" { fail "print buf\[0\]"}
494 default { fail "print buf\[0\]"}
496 send_gdb "print buf\[1\]\n"
498 -re ".*= 50.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[1\]"}
499 -re ".*= 0.*$gdb_prompt $" { pass "print buf\[1\]"}
500 -re ".*$gdb_prompt $" { fail "print buf\[1\]"}
501 default { fail "print buf\[1\]"}
503 send_gdb "print buf\[2\]\n"
505 -re ".*= 51.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[2\]"}
506 -re ".*= 0.*$gdb_prompt $" { pass "print buf\[2\]"}
507 -re ".*$gdb_prompt $" { fail "print buf\[2\]"}
508 default { fail "print buf\[2\]"}
510 send_gdb "print buf\[3\]\n"
512 -re ".*= 10.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[3\]"}
513 -re ".*= 0.*$gdb_prompt $" { pass "print buf\[3\]"}
514 -re ".*$gdb_prompt $" { fail "print buf\[3\]" }
515 default { fail "print buf\[3\]" }
518 # Did we find what we were looking for? If not, flunk it.
519 if [expr $x==$y] then { pass $testname } else { fail "$testname (only triggered $x watchpoints, expected $y)"}
521 # Continue until we hit the finishing marker function.
522 # Make sure we hit no more watchpoints.
523 gdb_test "cont" "Continuing.*Breakpoint.*marker4 \\(\\).*" \
524 "continue to marker4"
526 # Disable everything so we can finish the program at full speed
527 gdb_test "disable" "" "disable in test_watchpoint_triggered_in_syscall"
529 if [target_info exists gdb,noresults] { return }
531 gdb_continue_to_end "continue to exit in test_watchpoint_triggered_in_syscall"
535 # Do a simple test of of watching through a pointer when the pointer
536 # itself changes. Should add some more complicated stuff here.
538 proc test_complex_watchpoint {} {
541 if [runto marker4] then {
542 gdb_test "watch ptr1->val" ".*\[Ww\]atchpoint \[0-9\]*: ptr1->val"
543 gdb_test "break marker5" ".*Breakpoint.*"
545 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ptr1->val.*Old value = 1.*New value = 2.*" "Test complex watchpoint"
547 # Continue until we hit the marker5 function.
548 # Make sure we hit no more watchpoints.
550 gdb_test "cont" "Continuing.*Breakpoint.*marker5 \\(\\).*" \
551 "did not trigger wrong watchpoint"
553 # Test watches of things declared locally in a function.
554 # In particular, test that a watch of stack-based things
555 # is deleted when the stack-based things go out of scope.
557 gdb_test "disable" "" "disable in test_complex_watchpoint"
558 gdb_test "break marker6" ".*Breakpoint.*"
559 gdb_test "cont" "Continuing.*Breakpoint.*marker6 \\(\\).*" \
560 "continue to marker6"
561 gdb_test "break func2" ".*Breakpoint.*"
562 gdb_test "cont" "Continuing.*func2.*"
564 # Test a watch of a single stack-based variable, whose scope
565 # is the function we're now in. This should auto-delete when
566 # execution exits the scope of the watchpoint.
568 gdb_test "watch local_a" ".*\[Ww\]atchpoint \[0-9\]*: local_a" "set local watch"
569 gdb_test "cont" "\[Ww\]atchpoint.*local_a.*" "trigger local watch"
570 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" "self-delete local watch"
572 gdb_test "cont" "Continuing.*func2.*"
573 # We should be in "func2" again now. Test a watch of an
574 # expression which includes both a stack-based local and
575 # something whose scope is larger than this invocation
576 # of "func2". This should also auto-delete.
578 gdb_test "watch local_a + ival5" ".*\[Ww\]atchpoint \[0-9\]*: local_a . ival5" \
579 "set partially local watch"
580 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \
581 "trigger1 partially local watch"
582 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \
583 "trigger2 partially local watch"
584 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \
585 "self-delete partially local watch"
587 # We should be in "func2" again now. Test a watch of a
588 # static (non-stack-based) local. Since this has scope
589 # across any invocations of "func2", it should not auto-
592 gdb_test "cont" "Continuing.*func2.*"
593 gdb_test "watch static_b" ".*\[Ww\]atchpoint \[0-9\]*: static_b" \
594 "set static local watch"
595 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: static_b.*" \
596 "trigger static local watch"
597 gdb_test "cont" "Continuing.*marker6 \\(\\).*" \
598 "continue after trigger static local watch"
599 gdb_test "info break" ".*watchpoint.*static_b.*" \
600 "static local watch did not self-delete"
602 # We should be in "recurser" now. Test a watch of a stack-
603 # based local. Symbols mentioned in a watchpoint are bound
604 # at watchpoint-creation. Thus, a watch of a stack-based
605 # local to a recursing function should be bound only to that
606 # one invocation, and should not trigger for other invocations.
608 gdb_test "tbreak recurser" ".*Breakpoint.*"
609 gdb_test "cont" "Continuing.*recurser.*"
610 gdb_test "watch local_x" ".*\[Ww\]atchpoint \[0-9\]*: local_x" \
611 "set local watch in recursive call"
612 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_x.*New value = 2.*" \
613 "trigger local watch in recursive call"
614 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \
615 "self-delete local watch in recursive call"
617 # Disable everything so we can finish the program at full speed
618 gdb_test "disable" "" "disable in test_complex_watchpoint"
620 if [target_info exists gdb,noresults] { return }
622 gdb_continue_to_end "continue to exit in test_complex_watchpoint"
626 # Start with a fresh gdb.
630 gdb_reinitialize_dir $srcdir/$subdir
633 verbose "Timeout now 600 sec.\n"
635 if [initialize] then {
637 test_simple_watchpoint
639 # The IDT/sim monitor only has 8 (!) open files, of which it uses
640 # 4 (!). So we have to make sure one program exits before
641 # starting another one.
642 if [istarget "mips-idt-*"] then {
645 gdb_reinitialize_dir $srcdir/$subdir
650 test_disabling_watchpoints
653 if [istarget "mips-idt-*"] then {
656 gdb_reinitialize_dir $srcdir/$subdir
661 if ![target_info exists gdb,cannot_call_functions] {
665 if [istarget "mips-idt-*"] then {
668 gdb_reinitialize_dir $srcdir/$subdir
674 # Only enabled for some targets merely because it has not been tested
676 # On sparc-sun-sunos4.1.3, GDB was running all the way to the marker4
677 # breakpoint before stopping for the watchpoint. I don't know why.
678 if {[istarget "hppa*-*-*"]} then {
679 test_watchpoint_triggered_in_syscall
683 if [istarget "mips-idt-*"] then {
686 gdb_reinitialize_dir $srcdir/$subdir
691 # Only enabled for some targets merely because it has not been tested
693 if {[istarget "hppa*-*-*"] || \
694 [istarget "sparc*-*-sunos*"] || \
695 [istarget "m32r-*-*"]} then {
696 test_complex_watchpoint
699 # Verify that a user can force GDB to use "slow" watchpoints.
700 # (This proves rather little on kernels that don't support
701 # fast watchpoints, but still...)
703 if ![runto_main] then { fail "watch tests suppressed" }
705 send_gdb "set can-use-hw-watchpoints 0\n"
708 {pass "disable fast watches"}
709 timeout {fail "(timeout) disable fast watches"}
711 send_gdb "show can-use-hw-watchpoints\n"
713 -re "Debugger's willingness to use watchpoint hardware is 0.*$gdb_prompt $"\
714 {pass "show disable fast watches"}
716 {fail "show disable fast watches"}
717 timeout {fail "(timeout) show disable fast watches"}
719 send_gdb "watch ival3 if count > 1\n"
721 -re "Watchpoint \[0-9\]*: ival3.*$gdb_prompt $"\
722 {pass "set slow conditional watch"}
724 {fail "set slow conditional watch"}
725 timeout {fail "(timeout) set slow conditional watch"}
727 send_gdb "continue\n"
729 -re "Watchpoint \[0-9\]*: ival3.*Old value = 1.*New value = 2.*$gdb_prompt $"\
730 {pass "trigger slow conditional watch"}
732 {fail "trigger slow conditional watch"}
733 timeout {fail "(timeout) trigger slow conditional watch"}
736 # We've explicitly disabled hardware watches. Verify that GDB
739 send_gdb "rwatch ival3\n"
741 -re "Expression cannot be implemented with read/access watchpoint..*$gdb_prompt $"\
742 {pass "rwatch disallowed when can-set-hw-watchpoints cleared"}
744 {fail "rwatch disallowed when can-set-hw-watchpoints cleared"}
745 timeout {fail "(timeout) rwatch disallowed when can-use-hw-watchpoints cleared"}
748 # Read- and access watchpoints are unsupported on HP-UX. Verify
749 # that GDB gracefully responds to requests to create them.
751 if [istarget "hppa*-*-hpux*"] then {
752 send_gdb "set can-use-hw-watchpoints 1\n"
755 {pass "enable fast watches"}
756 timeout {fail "(timeout) enable fast watches"}
758 send_gdb "rwatch ival3\n"
760 -re "Target does not have this type of hardware watchpoint support.*$gdb_prompt $"\
761 {pass "read watches disallowed"}
763 {fail "read watches disallowed"}
764 timeout {fail "(timeout) read watches disallowed"}
767 send_gdb "awatch ival3\n"
769 -re "Target does not have this type of hardware watchpoint support.*$gdb_prompt $"\
770 {pass "access watches disallowed"}
772 {fail "access watches disallowed"}
773 timeout {fail "(timeout) access watches disallowed"}