1 # Copyright (C) 1992, 1994, 1997 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:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Fred Fish. (fnf@cygnus.com)
29 set testfile "watch-hp"
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
36 if [get_compiler_info ${binfile}] {
39 if {[skip_hp_tests $gcc_compiled]} then { continue }
41 # Prepare for watchpoint tests by setting up two breakpoints and one
44 # We use breakpoints at marker functions to get past all the startup code,
45 # so we can get to the watchpoints in a reasonable amount of time from a
46 # known starting point.
48 # For simplicity, so we always know how to reference specific breakpoints or
49 # watchpoints by number, we expect a particular ordering and numbering of
50 # each in the combined breakpoint/watchpoint table, as follows:
53 # 1 Breakpoint marker1()
54 # 2 Breakpoint marker2()
63 if [gdb_test "break marker1" "Breakpoint 1 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker1" ] {
68 if [gdb_test "break marker2" "Breakpoint 2 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker2" ] {
73 if [gdb_test "info break" "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*" "info break in watchpoint.exp" ] {
77 # ??rehrauer: To fix DTS #CHFts23014, in which setting a watchpoint
78 # before running can cause the inferior to croak on HP-UX 10.30 and
79 # 11.0 for reasons as yet unknown, we've disabled the ability to set
80 # watches without a running inferior. Verify the restriction.
82 send_gdb "watch ival3\n"
84 -re ".*can't do that without a running program; try \"break main\", \"run\" first.*$gdb_prompt $" {
85 pass "set watchpoint on ival3"
87 -re ".*$gdb_prompt $" { fail "set watchpoint on ival3" }
88 timeout { fail "set watchpoint on ival3 (timeout)" }
92 # if [gdb_test "watch ival3" ".*\[Ww\]atchpoint 3: ival3" "set watchpoint on ival3" ] {
97 # "info watch" is the same as "info break"
99 # if [gdb_test "info watch" "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*\r\n3\[ \]*.*watchpoint.*ival3" "watchpoint found in watchpoint/breakpoint table" ] {
104 # After installing the watchpoint, we disable it until we are ready
105 # to use it. This allows the test program to run at full speed until
106 # we get to the first marker function.
108 # if [gdb_test "disable 3" "disable 3\[\r\n\]+" "disable watchpoint" ] {
117 # Test simple watchpoint.
120 proc test_simple_watchpoint {} {
125 # Ensure that the watchpoint is disabled when we startup.
127 # if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_simple_watchpoint" ] {
132 # Run until we get to the first marker function.
137 -re "Breakpoint 1, marker1 .*$gdb_prompt $" {
138 pass "run to marker1 in test_simple_watchpoint"
140 -re ".*$gdb_prompt $" {
141 fail "run to marker1 in test_simple_watchpoint"
145 fail "run to marker1 in test_simple_watchpoint (timeout)"
149 #************************
151 # ??rehrauer: To fix DTS #CHFts23014, in which setting a watchpoint
152 # before running can cause the inferior to croak on HP-UX 10.30 and
153 # 11.0 for reasons as yet unknown, we've disabled the ability to set
154 # watches without a running inferior. The following testpoints used
155 # to be in [initialize].
157 send_gdb "watch ival3\n"
159 -re ".*\[Ww\]atchpoint 3: ival3\r\n$gdb_prompt $" {
160 pass "set watchpoint on ival3"
162 -re ".*$gdb_prompt $" { fail "set watchpoint on ival3" }
163 timeout { fail "set watchpoint on ival3 (timeout)" }
166 # "info watch" is the same as "info break"
168 send_gdb "info watch\n"
170 -re "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*\r\n3\[ \]*.*watchpoint.*ival3\r\n$gdb_prompt $" {
171 pass "watchpoint found in watchpoint/breakpoint table"
173 -re ".*$gdb_prompt $" {
174 fail "watchpoint found in watchpoint/breakpoint table"
177 fail "watchpoint found in watchpoint/breakpoint table"
181 # After installing the watchpoint, we disable it until we are ready
182 # to use it. This allows the test program to run at full speed until
183 # we get to the first marker function.
185 send_gdb "disable 3\n"
187 -re "disable 3\[\r\n\]+$gdb_prompt $" { pass "disable watchpoint" }
188 -re ".*$gdb_prompt $" { fail "disable watchpoint" }
189 timeout { fail "disable watchpoint (timeout)" }
192 # After reaching the marker function, enable the watchpoint.
194 if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "enable watchpoint" ] {
199 gdb_test "break func1" "Breakpoint.*at.*"
200 gdb_test "set \$func1_breakpoint_number = \$bpnum" ""
202 gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, func1.*" \
203 "continue to breakpoint at func1"
205 # Continue until the first change, from -1 to 0
209 -re "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*$gdb_prompt $" {
210 pass "watchpoint hit, first time"
212 -re "Continuing.*Breakpoint.*func1.*$gdb_prompt $" {
213 setup_xfail "m68*-*-*" 2597
214 fail "thought it hit breakpoint at func1 twice"
215 gdb_test "delete \$func1_breakpoint_number" ""
216 gdb_test "continue" "\
217 Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count;" \
218 "watchpoint hit, first time"
220 -re ".*$gdb_prompt $" { fail "watchpoint hit, first time" ; return }
221 timeout { fail "watchpoint hit, first time (timeout)" ; return }
222 eof { fail "watchpoint hit, first time (eof)" ; return }
225 gdb_test "delete \$func1_breakpoint_number" ""
227 # Continue until the next change, from 0 to 1.
228 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" "watchpoint hit, second time"
230 # Continue until the next change, from 1 to 2.
231 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" "watchpoint hit, third time"
233 # Continue until the next change, from 2 to 3.
234 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" "watchpoint hit, fourth time"
236 # Continue until the next change, from 3 to 4.
237 # Note that this one is outside the loop.
239 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" "watchpoint hit, fifth time"
241 # Continue until we hit the finishing marker function.
242 # Make sure we hit no more watchpoints.
244 gdb_test "cont" "Continuing.*Breakpoint.*marker2 \(\).*" \
245 "continue to marker2"
247 # Disable the watchpoint so we run at full speed until we exit.
249 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "watchpoint disabled" ] {
254 # Run until process exits.
256 if [target_info exists gdb,noresults] { return }
258 gdb_test "cont" "Continuing.*Program exited normally.*" \
259 "continue to exit in test_simple_watchpoint"
262 # Test disabling watchpoints.
264 proc test_disabling_watchpoints {} {
271 # Ensure that the watchpoint is disabled when we startup.
273 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_disabling_watchpoints" ] {
278 # Run until we get to the first marker function.
283 -re "Breakpoint 1, marker1 .*$gdb_prompt $" {
284 pass "run to marker1 in test_disabling_watchpoints"
286 -re ".*$gdb_prompt $" {
287 fail "run to marker1 in test_disabling_watchpoints"
291 fail "run to marker1 in test_disabling_watchpoints (timeout)"
296 # After reaching the marker function, enable the watchpoint.
298 if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "watchpoint enabled" ] {
303 # Continue until the first change, from -1 to 0
304 # Don't check the old value, because on VxWorks the variable value
305 # will not have been reinitialized.
306 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = .*New value = 0.*ival3 = count; ival4 = count;.*" "watchpoint hit in test_disabling_watchpoints, first time"
308 # Continue until the next change, from 0 to 1.
309 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"
311 # Disable the watchpoint but leave breakpoints
313 if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint #2 in test_disabling_watchpoints" ] {
318 # Check watchpoint list, looking for the entry that confirms the
319 # watchpoint is disabled.
320 gdb_test "info watchpoints" "3\[ \]*.*watchpoint\[ \]*keep\[ \]*n\[ \]*ival3\r\n.*" "watchpoint disabled in table"
322 # Continue until we hit the finishing marker function.
323 # Make sure we hit no more watchpoints.
324 gdb_test "cont" "Continuing.*Breakpoint.*marker2 \\(\\).*" \
325 "disabled watchpoint skipped"
327 if [target_info exists gdb,noresults] { return }
329 gdb_test "cont" "Continuing.*Program exited normally.*" \
330 "continue to exit in test_disabling_watchpoints"
333 # Test stepping and other mundane operations with watchpoints enabled
334 proc test_stepping {} {
337 if [runto marker1] then {
338 gdb_test "watch ival2" ".*\[Ww\]atchpoint \[0-9\]*: ival2"
340 # Well, let's not be too mundane. It should be a *bit* of a challenge
341 gdb_test "break func2 if 0" "Breakpoint.*at.*"
342 gdb_test "p \$func2_breakpoint_number = \$bpnum" " = .*"
344 # The HPPA has a problem here if it's not using hardware watchpoints
345 if {[ istarget "hppa*-*-*" ] && ![ istarget "hppa*-*-*bsd*" ]} then {
346 # Don't actually try doing the call, if we do we can't continue.
348 fail "calling function with watchpoint enabled"
350 # The problem is that GDB confuses stepping through the call
351 # dummy with hitting the breakpoint at the end of the call dummy.
352 # Will be fixed once all architectures define
353 # CALL_DUMMY_BREAKPOINT_OFFSET.
355 # This doesn't occur if the call dummy starts with a call,
356 # because we are out of the dummy by the first time the inferior
358 clear_xfail "d10v*-*-*"
359 clear_xfail "m68*-*-*"
360 clear_xfail "i*86*-*-*"
361 clear_xfail "vax-*-*"
362 # The following architectures define CALL_DUMMY_BREAKPOINT_OFFSET.
363 clear_xfail "alpha-*-*"
364 clear_xfail "mips*-*-*"
365 clear_xfail "sparc-*-*"
366 clear_xfail "hppa*-*-*bsd*"
367 # It works with the generic inferior function calling code too.
368 clear_xfail "mn10200*-*-*"
369 clear_xfail "mn10300*-*-*"
370 gdb_test "p func1 ()" "= 73" \
371 "calling function with watchpoint enabled"
375 # "finish" brings us back to main.
376 # On some targets (e.g. alpha) gdb will stop from the finish in midline
377 # of the marker1 call. This is due to register restoring code on
378 # the alpha and might be caused by stack adjustment instructions
379 # on other targets. In this case we will step once more.
384 -re "Run.*exit from.*marker1.* at" { }
385 default { fail "finish from marker1" ; return }
389 -re "marker1 \\(\\);.*$gdb_prompt $" {
393 -re "func1 \\(\\);.*$gdb_prompt $" {
394 pass "finish from marker1"
396 -re ".*$gdb_prompt $" {
397 fail "finish from marker1"
399 default { fail "finish from marker1" ; return }
402 gdb_test "next" "for \\(count = 0.*" "next to `for' in watchpoint.exp"
404 # Now test that "until" works. It's a bit tricky to test
405 # "until", because compilers don't always arrange the code
406 # exactly the same way, and we might get slightly different
407 # sequences of statements. But the following should be true
408 # (if not it is a compiler or a debugger bug): The user who
409 # does "until" at every statement of a loop should end up
410 # stepping through the loop once, and the debugger should not
411 # stop for any of the remaining iterations.
413 gdb_test "until" "ival1 = count.*" "until to ival1 assignment"
414 gdb_test "until" "ival3 = count.*" "until to ival3 assignment"
417 -re "(for \\(count = 0|\}).*$gdb_prompt $" {
418 gdb_test "until" "ival1 = count; /. Outside loop ./" \
421 -re "ival1 = count; /. Outside loop ./.*$gdb_prompt $" {
422 pass "until out of loop"
424 -re ".*$gdb_prompt $" {
425 fail "until out of loop"
427 default { fail "until out of loop" ; return }
430 gdb_test "step" "ival2 = count.*" "step to ival2 assignment"
434 # Test stepping and other mundane operations with watchpoints enabled
435 proc test_watchpoint_triggered_in_syscall {} {
438 if [target_info exists gdb,noinferiorio] {
439 verbose "Skipping test_watchpoint_triggered_in_syscall due to noinferiorio"
442 # Run until we get to the first marker function.
445 set testname "Watch buffer passed to read syscall"
446 if [runto marker2] then {
447 gdb_test "watch buf\[0\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[0\\\]"
448 gdb_test "watch buf\[1\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[1\\\]"
449 gdb_test "watch buf\[2\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[2\\\]"
450 gdb_test "watch buf\[3\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[3\\\]"
451 gdb_test "watch buf\[4\]" ".*\[Ww\]atchpoint \[0-9\]*: buf\\\[4\\\]"
452 gdb_test "break marker4" ".*Breakpoint.*"
454 gdb_test "set doread = 1" ""
456 # If we send_gdb "123\n" before gdb has switched the tty, then it goes
457 # to gdb, not the inferior, and we lose. So that is why we have
458 # watchpoint.c prompt us, so we can wait for that prompt.
459 send_gdb "continue\n";
461 -re "Continuing\\.\r\ntype stuff for buf now:" {
462 pass "continue to read"
465 fail "continue to read";
472 -re ".*\[Ww\]atchpoint.*buf\\\[0\\\].*Old value = 0.*New value = 49\[^\n\]*\n" { set x [expr $x+1] ; exp_continue }
473 -re ".*\[Ww\]atchpoint.*buf\\\[1\\\].*Old value = 0.*New value = 50\[^\n\]*\n" { set x [expr $x+1] ; exp_continue }
474 -re ".*\[Ww\]atchpoint.*buf\\\[2\\\].*Old value = 0.*New value = 51\[^\n\]*\n" { set x [expr $x+1] ; exp_continue }
475 -re ".*\[Ww\]atchpoint.*buf\\\[3\\\].*Old value = 0.*New value = 10\[^\n\]*\n" { set x [expr $x+1] ; exp_continue }
476 -re ".*$gdb_prompt $" { pass "sent 123" }
477 timeout { fail "sent 123 (timeout)" }
480 # Examine the values in buf to see how many watchpoints we
481 # should have printed.
482 send_gdb "print buf\[0\]\n"
484 -re ".*= 49.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[0\]"}
485 -re ".*= 0.*$gdb_prompt $" { pass "print buf\[0\]"}
486 -re ".*$gdb_prompt $" { fail "print buf\[0\]"}
487 default { fail "print buf\[0\]"}
489 send_gdb "print buf\[1\]\n"
491 -re ".*= 50.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[1\]"}
492 -re ".*= 0.*$gdb_prompt $" { pass "print buf\[1\]"}
493 -re ".*$gdb_prompt $" { fail "print buf\[1\]"}
494 default { fail "print buf\[1\]"}
496 send_gdb "print buf\[2\]\n"
498 -re ".*= 51.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[2\]"}
499 -re ".*= 0.*$gdb_prompt $" { pass "print buf\[2\]"}
500 -re ".*$gdb_prompt $" { fail "print buf\[2\]"}
501 default { fail "print buf\[2\]"}
503 send_gdb "print buf\[3\]\n"
505 -re ".*= 10.*$gdb_prompt $" { set y [expr $y+1]; pass "print buf\[3\]"}
506 -re ".*= 0.*$gdb_prompt $" { pass "print buf\[3\]"}
507 -re ".*$gdb_prompt $" { fail "print buf\[3\]" }
508 default { fail "print buf\[3\]" }
511 # Did we find what we were looking for? If not, flunk it.
512 if [expr $x==$y] then { pass $testname } else { fail "$testname (only triggered $x watchpoints, expected $y)"}
514 # Continue until we hit the finishing marker function.
515 # Make sure we hit no more watchpoints.
516 gdb_test "cont" "Continuing.*Breakpoint.*marker4 \\(\\).*" \
517 "continue to marker4"
519 # Disable everything so we can finish the program at full speed
520 gdb_test "disable" "" "disable in test_watchpoint_triggered_in_syscall"
522 if [target_info exists gdb,noresults] { return }
524 gdb_test "cont" "Continuing.*Program exited normally.*" \
525 "continue to exit in test_watchpoint_triggered_in_syscall"
529 # Do a simple test of of watching through a pointer when the pointer
530 # itself changes. Should add some more complicated stuff here.
532 proc test_complex_watchpoint {} {
535 if [runto marker4] then {
536 gdb_test "watch ptr1->val" ".*\[Ww\]atchpoint \[0-9\]*: ptr1->val"
537 gdb_test "break marker5" ".*Breakpoint.*"
539 gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ptr1->val.*Old value = 1.*New value = 2.*" "Test complex watchpoint"
541 # Continue until we hit the marker5 function.
542 # Make sure we hit no more watchpoints.
544 gdb_test "cont" "Continuing.*Breakpoint.*marker5 \\(\\).*" \
545 "did not trigger wrong watchpoint"
546 #********************
547 # Test watches of things declared locally in a function.
548 # In particular, test that a watch of stack-based things
549 # is deleted when the stack-based things go out of scope.
551 gdb_test "disable" "" "disable in test_complex_watchpoint"
552 gdb_test "break marker6" ".*Breakpoint.*"
553 gdb_test "cont" "Continuing.*Breakpoint.*marker6 \\(\\).*" \
554 "continue to marker6"
555 gdb_test "break func2" ".*Breakpoint.*"
556 gdb_test "cont" "Continuing.*func2.*"
558 # Test a watch of a single stack-based variable, whose scope
559 # is the function we're now in. This should auto-delete when
560 # execution exits the scope of the watchpoint.
562 gdb_test "watch local_a" ".*\[Ww\]atchpoint \[0-9\]*: local_a" "set local watch"
563 gdb_test "cont" "\[Ww\]atchpoint.*local_a.*" "trigger local watch"
564 gdb_test "cont" "Continuing.*Watchpoint .* deleted because the program has left the block in.*which its expression is valid.*" "self-delete local watch"
566 # after func2 returned, gdb stopped and deleted the watchpoint
567 # we're now in main, let's get to func2
568 gdb_test "cont" "Continuing.*func2.*"
570 # We should be in "func2" again now. Test a watch of an
571 # expression which includes both a stack-based local and
572 # something whose scope is larger than this invocation
573 # of "func2". This should also auto-delete.
575 gdb_test "watch local_a + ival5" ".*\[Ww\]atchpoint \[0-9\]*: local_a . ival5" \
576 "set partially local watch"
577 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \
578 "trigger1 partially local watch"
579 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \
580 "trigger2 partially local watch"
581 gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \
582 "self-delete partially local watch"
584 # after func2 returned, gdb stopped and deleted the watchpoint
585 # we're now in main, let's get to func2
586 gdb_test "cont" "Continuing.*func2.*"
588 # We should be in "func2" again now. Test a watch of a
589 # static (non-stack-based) local. Since this has scope
590 # across any invocations of "func2", it should not auto-
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"
621 # Disable everything so we can finish the program at full speed
622 gdb_test "disable" "" "disable in test_complex_watchpoint"
624 if [target_info exists gdb,noresults] { return }
627 gdb_test "cont" "Continuing.*Program exited normally.*" \
628 "continue to exit in test_complex_watchpoint"
632 # Start with a fresh gdb.
635 gdb_reinitialize_dir $srcdir/$subdir
638 verbose "Timeout now 600 sec.\n"
640 if [initialize] then {
642 test_simple_watchpoint
644 # The IDT/sim monitor only has 8 (!) open files, of which it uses
645 # 4 (!). So we have to make sure one program exits before
646 # starting another one.
647 if [istarget "mips-idt-*"] then {
650 gdb_reinitialize_dir $srcdir/$subdir
655 test_disabling_watchpoints
658 if [istarget "mips-idt-*"] then {
661 gdb_reinitialize_dir $srcdir/$subdir
666 if ![target_info exists gdb,cannot_call_functions] {
670 if [istarget "mips-idt-*"] then {
673 gdb_reinitialize_dir $srcdir/$subdir
679 # Only enabled for some targets merely because it has not been tested
681 # On sparc-sun-sunos4.1.3, GDB was running all the way to the marker4
682 # breakpoint before stopping for the watchpoint. I don't know why.
683 if {[istarget "hppa*-*-*"]} then {
684 test_watchpoint_triggered_in_syscall
688 if [istarget "mips-idt-*"] then {
691 gdb_reinitialize_dir $srcdir/$subdir
696 # Only enabled for some targets merely because it has not been tested
698 if {[istarget "hppa*-*-*"] || \
699 [istarget "sparc*-*-sunos*"] || \
700 [istarget "m32r-*-*"]} then {
701 test_complex_watchpoint
705 # Verify that a user can force GDB to use "slow" watchpoints.
706 # (This proves rather little on kernels that don't support
707 # fast watchpoints, but still...)
709 if ![runto_main] then { fail "watch tests suppressed" }
711 send_gdb "set can-use-hw-watchpoints 0\n"
714 {pass "disable fast watches"}
715 timeout {fail "(timeout) disable fast watches"}
717 send_gdb "show can-use-hw-watchpoints\n"
719 -re "Debugger's willingness to use watchpoint hardware is 0.*$gdb_prompt $"\
720 {pass "show disable fast watches"}
722 {fail "show disable fast watches"}
723 timeout {fail "(timeout) show disable fast watches"}
725 send_gdb "watch ival3 if count > 1\n"
727 -re "Watchpoint \[0-9\]*: ival3.*$gdb_prompt $"\
728 {pass "set slow conditional watch"}
730 {fail "set slow conditional watch"}
731 timeout {fail "(timeout) set slow conditional watch"}
733 send_gdb "continue\n"
735 -re "Watchpoint \[0-9\]*: ival3.*Old value = 1.*New value = 2.*$gdb_prompt $"\
736 {pass "trigger slow conditional watch"}
738 {fail "trigger slow conditional watch"}
739 timeout {fail "(timeout) trigger slow conditional watch"}
742 # We've explicitly disabled hardware watches. Verify that GDB
745 send_gdb "rwatch ival3\n"
747 -re "Expression cannot be implemented with read/access watchpoint..*$gdb_prompt $"\
748 {pass "rwatch disallowed when can-set-hw-watchpoints cleared"}
750 {fail "rwatch disallowed when can-set-hw-watchpoints cleared"}
751 timeout {fail "(timeout) rwatch disallowed when can-use-hw-watchpoints cleared"}
754 # Read- and access watchpoints are unsupported on HP-UX. Verify
755 # that GDB gracefully responds to requests to create them.
757 if [istarget "hppa*-*-hpux*"] then {
758 send_gdb "set can-use-hw-watchpoints 1\n"
761 {pass "enable fast watches"}
762 timeout {fail "(timeout) enable fast watches"}
764 send_gdb "rwatch ival3\n"
766 -re "Target does not have this type of hardware watchpoint support.*$gdb_prompt $"\
767 {pass "read watches disallowed"}
769 {fail "read watches disallowed"}
770 timeout {fail "(timeout) read watches disallowed"}
773 send_gdb "awatch ival3\n"
775 -re "Target does not have this type of hardware watchpoint support.*$gdb_prompt $"\
776 {pass "access watches disallowed"}
778 {fail "access watches disallowed"}
779 timeout {fail "(timeout) access watches disallowed"}