+
+# Test setting a condition in a breakpoint. BREAK_COMMAND is the
+# break/hwatch command to test.
+#
+proc test_break { break_command } {
+ global gdb_prompt
+
+ with_test_prefix "$break_command" {
+ delete_breakpoints
+
+ gdb_test "$break_command foo" "reakpoint.* at .*"
+
+ # A condition that evals true.
+ gdb_test "condition \$bpnum cond_global==0" ".*"
+
+ set can_do_cmd 0
+
+ set test "continue"
+ gdb_test_multiple $test $test {
+ -re "You may have requested too many.*$gdb_prompt $" {
+ pass $test
+ }
+ -re "Breakpoint .*, foo .*$gdb_prompt $" {
+ pass $test
+ set can_do_cmd 1
+ }
+ }
+
+ if { !$can_do_cmd } {
+ unsupported "no target support"
+ return
+ }
+
+ delete_breakpoints
+
+ gdb_test "$break_command foo" ".*reakpoint .* at .*"
+
+ # A condition that evals false.
+ gdb_test "condition \$bpnum cond_global==1" ".*"
+
+ gdb_test "b bar" "Breakpoint .* at .*"
+
+ gdb_test "continue" "Breakpoint .*, bar .*"
+ }
+}
+
+# Test setting conditions in watchpoints. WATCH_COMMAND is the watch
+# command to test.
+#
+proc test_watch { watch_command } {
+ global gdb_prompt
+
+ with_test_prefix "$watch_command" {
+ if [target_info exists gdb,no_hardware_watchpoints] {
+ unsupported "no target support"
+ return
+ }
+
+ delete_breakpoints
+
+ gdb_test "$watch_command global" ".*atchpoint .*: global.*"
+
+ # A condition that evals true.
+ gdb_test "condition \$bpnum cond_global==0" ".*"
+
+ set can_do_cmd 0
+
+ set test "continue"
+ gdb_test_multiple $test $test {
+ -re "You may have requested too many.*$gdb_prompt $" {
+ pass $test
+ }
+ -re "atchpoint .*: global.*$gdb_prompt $" {
+ pass $test
+ set can_do_cmd 1
+ }
+ }
+
+ if { !$can_do_cmd } {
+ unsupported "no target support"
+ return
+ }
+
+ delete_breakpoints
+
+ gdb_test "$watch_command global" ".*atchpoint .*: global.*"
+
+ # A condition that evals false.
+ gdb_test "condition \$bpnum cond_global==1" ".*"
+
+ gdb_test "b bar" "Breakpoint .* at .*"
+
+ gdb_test "continue" "Breakpoint .*, bar .*"
+ }
+}
+
+foreach break_command { "break" "hbreak" } {
+ test_break $break_command
+}
+
+foreach watch_command { "watch" "rwatch" "awatch" } {
+ test_watch $watch_command
+}