1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
# Copyright 2012-2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test 'set breakpoint condition-evaluation' settings
# The allow_hw_watchpoint_tests checks if watchpoints are supported by the
# processor. On PowerPC, the check runs a small test program under gdb
# to determine if the Power processor supports HW watchpoints. The check
# must be done before starting the test so as to not disrupt the execution
# of the actual test.
set allow_hw_watchpoint_tests_p [allow_hw_watchpoint_tests]
standard_testfile
if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
return -1
}
if {![runto_main]} {
return 0
}
set test_host "set breakpoint condition-evaluation host"
set test_auto "set breakpoint condition-evaluation auto"
set test_target "set breakpoint condition-evaluation target"
gdb_test_no_output $test_host
gdb_test_no_output $test_auto
# If target-side condition evaluation is not supported, this warning will be
# displayed.
set warning "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead."
gdb_test_multiple $test_target $test_target {
-re "$warning\r\n$gdb_prompt $" {
unsupported $test_target
return -1
}
-re "^$test_target\r\n$gdb_prompt $" {
pass $test_target
}
}
# We now know that the target supports target-side conditional
# evaluation. Now make sure we can force-disable the
# ConditionalBreakpoints RSP feature.
if [gdb_protocol_is_remote] {
gdb_test \
"set remote conditional-breakpoints-packet off" \
"Support for the 'ConditionalBreakpoints' packet on the current remote target is set to \"off\"."
gdb_test $test_target "$warning" \
"set breakpoint condition-evaluation target, with support disabled"
# Confirm we can re-enable it.
gdb_test \
"set remote conditional-breakpoints-packet on" \
"Support for the 'ConditionalBreakpoints' packet on the current remote target is set to \"on\"."
gdb_test_no_output $test_target "restore $test_target"
}
# 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
with_test_prefix "true condition" {
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
}
}
with_test_prefix "false condition" {
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
global allow_hw_watchpoint_tests_p
with_test_prefix "$watch_command" {
if {!$allow_hw_watchpoint_tests_p} {
unsupported "no target support"
return
}
with_test_prefix "true condition" {
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
}
}
with_test_prefix "false condition" {
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
}
|