1248557Sray# Copyright 2012-2020 Free Software Foundation, Inc. 2250357Sray 3248557Sray# This program is free software; you can redistribute it and/or modify 4248557Sray# it under the terms of the GNU General Public License as published by 5248557Sray# the Free Software Foundation; either version 3 of the License, or 6248557Sray# (at your option) any later version. 7248557Sray# 8248557Sray# This program is distributed in the hope that it will be useful, 9248557Sray# but WITHOUT ANY WARRANTY; without even the implied warranty of 10248557Sray# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11248557Sray# GNU General Public License for more details. 12248557Sray# 13248557Sray# You should have received a copy of the GNU General Public License 14248557Sray# along with this program. If not, see <http://www.gnu.org/licenses/>. 15248557Sray 16248557Sray# Test 'set breakpoint condition-evaluation' settings 17248557Sray 18248557Sraystandard_testfile 19248557Sray 20248557Srayif {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { 21248557Sray return -1 22248557Sray} 23248557Sray 24248557Srayif ![runto_main] then { 25248557Sray fail "can't run to main" 26248557Sray return 0 27248557Sray} 28248557Sray 29248557Srayset test_host "set breakpoint condition-evaluation host" 30248557Srayset test_auto "set breakpoint condition-evaluation auto" 31248557Srayset test_target "set breakpoint condition-evaluation target" 32248557Sray 33248557Sraygdb_test_no_output $test_host 34248557Sraygdb_test_no_output $test_auto 35248557Sray 36248557Sray# If target-side condition evaluation is not supported, this warning will be 37248557Sray# displayed. 38248557Srayset warning "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead." 39248557Sray 40248557Sraygdb_test_multiple $test_target $test_target { 41248557Sray -re "$warning\r\n$gdb_prompt $" { 42248557Sray unsupported $test_target 43248557Sray return -1 44248557Sray } 45248557Sray 46248557Sray -re "^$test_target\r\n$gdb_prompt $" { 47248557Sray pass $test_target 48248557Sray } 49248557Sray} 50248557Sray 51248557Sray# We now know that the target supports target-side conditional 52248557Sray# evaluation. Now make sure we can force-disable the 53248557Sray# ConditionalBreakpoints RSP feature. 54248557Srayif [gdb_is_target_remote] { 55248557Sray gdb_test_no_output "set remote conditional-breakpoints-packet off" 56248557Sray 57248557Sray gdb_test $test_target "$warning" \ 58248557Sray "set breakpoint condition-evaluation target, with support disabled" 59248557Sray 60248557Sray # Confirm we can re-enable it. 61248557Sray gdb_test_no_output "set remote conditional-breakpoints-packet on" 62248557Sray gdb_test_no_output $test_target "restore $test_target" 63248557Sray} 64248557Sray 65248557Sray# Test setting a condition in a breakpoint. BREAK_COMMAND is the 66248557Sray# break/hwatch command to test. 67248557Sray# 68248557Srayproc test_break { break_command } { 69248557Sray global gdb_prompt 70248557Sray 71248557Sray with_test_prefix "$break_command" { 72248557Sray delete_breakpoints 73248557Sray 74248557Sray gdb_test "$break_command foo" "reakpoint.* at .*" 75248557Sray 76248557Sray # A condition that evals true. 77248557Sray gdb_test "condition \$bpnum cond_global==0" ".*" 78248557Sray 79248557Sray set can_do_cmd 0 80248557Sray 81248557Sray set test "continue" 82248557Sray gdb_test_multiple $test $test { 83248557Sray -re "You may have requested too many.*$gdb_prompt $" { 84248557Sray pass $test 85248557Sray } 86248557Sray -re "Breakpoint .*, foo .*$gdb_prompt $" { 87248557Sray pass $test 88248557Sray set can_do_cmd 1 89248557Sray } 90248557Sray } 91248557Sray 92248557Sray if { !$can_do_cmd } { 93248557Sray unsupported "no target support" 94248557Sray return 95248557Sray } 96248557Sray 97248557Sray delete_breakpoints 98248557Sray 99248557Sray gdb_test "$break_command foo" ".*reakpoint .* at .*" 100248557Sray 101248557Sray # A condition that evals false. 102248557Sray gdb_test "condition \$bpnum cond_global==1" ".*" 103248557Sray 104248557Sray gdb_test "b bar" "Breakpoint .* at .*" 105248557Sray 106248557Sray gdb_test "continue" "Breakpoint .*, bar .*" 107248557Sray } 108248557Sray} 109248557Sray 110248557Sray# Test setting conditions in watchpoints. WATCH_COMMAND is the watch 111248557Sray# command to test. 112248557Sray# 113248557Srayproc test_watch { watch_command } { 114248557Sray global gdb_prompt 115248557Sray 116248557Sray with_test_prefix "$watch_command" { 117248557Sray if [target_info exists gdb,no_hardware_watchpoints] { 118248557Sray unsupported "no target support" 119248557Sray return 120248557Sray } 121248557Sray 122248557Sray delete_breakpoints 123248557Sray 124248557Sray gdb_test "$watch_command global" ".*atchpoint .*: global.*" 125248557Sray 126248557Sray # A condition that evals true. 127248557Sray gdb_test "condition \$bpnum cond_global==0" ".*" 128248557Sray 129248557Sray set can_do_cmd 0 130248557Sray 131248557Sray set test "continue" 132248557Sray gdb_test_multiple $test $test { 133248557Sray -re "You may have requested too many.*$gdb_prompt $" { 134248557Sray pass $test 135248557Sray } 136248557Sray -re "atchpoint .*: global.*$gdb_prompt $" { 137248557Sray pass $test 138248557Sray set can_do_cmd 1 139248557Sray } 140248557Sray } 141248557Sray 142248557Sray if { !$can_do_cmd } { 143 unsupported "no target support" 144 return 145 } 146 147 delete_breakpoints 148 149 gdb_test "$watch_command global" ".*atchpoint .*: global.*" 150 151 # A condition that evals false. 152 gdb_test "condition \$bpnum cond_global==1" ".*" 153 154 gdb_test "b bar" "Breakpoint .* at .*" 155 156 gdb_test "continue" "Breakpoint .*, bar .*" 157 } 158} 159 160foreach break_command { "break" "hbreak" } { 161 test_break $break_command 162} 163 164foreach watch_command { "watch" "rwatch" "awatch" } { 165 test_watch $watch_command 166} 167