Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.base / cond-eval-mode.exp
blob49f9fc7746007b4840bb85f174dd2d36b166c232
1 # Copyright 2012-2023 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 3 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, see <http://www.gnu.org/licenses/>.
16 # Test 'set breakpoint condition-evaluation' settings
18 # The allow_hw_watchpoint_tests checks if watchpoints are supported by the
19 # processor. On PowerPC, the check runs a small test program under gdb
20 # to determine if the Power processor supports HW watchpoints. The check
21 # must be done before starting the test so as to not disrupt the execution
22 # of the actual test.
24 set allow_hw_watchpoint_tests_p [allow_hw_watchpoint_tests]
26 standard_testfile
28 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
29 return -1
32 if {![runto_main]} {
33 return 0
36 set test_host "set breakpoint condition-evaluation host"
37 set test_auto "set breakpoint condition-evaluation auto"
38 set test_target "set breakpoint condition-evaluation target"
40 gdb_test_no_output $test_host
41 gdb_test_no_output $test_auto
43 # If target-side condition evaluation is not supported, this warning will be
44 # displayed.
45 set warning "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead."
47 gdb_test_multiple $test_target $test_target {
48 -re "$warning\r\n$gdb_prompt $" {
49 unsupported $test_target
50 return -1
53 -re "^$test_target\r\n$gdb_prompt $" {
54 pass $test_target
58 # We now know that the target supports target-side conditional
59 # evaluation. Now make sure we can force-disable the
60 # ConditionalBreakpoints RSP feature.
61 if [gdb_is_target_remote] {
62 gdb_test \
63 "set remote conditional-breakpoints-packet off" \
64 "Support for the 'ConditionalBreakpoints' packet on the current remote target is set to \"off\"."
66 gdb_test $test_target "$warning" \
67 "set breakpoint condition-evaluation target, with support disabled"
69 # Confirm we can re-enable it.
70 gdb_test \
71 "set remote conditional-breakpoints-packet on" \
72 "Support for the 'ConditionalBreakpoints' packet on the current remote target is set to \"on\"."
74 gdb_test_no_output $test_target "restore $test_target"
77 # Test setting a condition in a breakpoint. BREAK_COMMAND is the
78 # break/hwatch command to test.
80 proc test_break { break_command } {
81 global gdb_prompt
83 with_test_prefix "$break_command" {
84 delete_breakpoints
86 gdb_test "$break_command foo" "reakpoint.* at .*"
88 # A condition that evals true.
89 gdb_test "condition \$bpnum cond_global==0" ".*"
91 set can_do_cmd 0
93 set test "continue"
94 gdb_test_multiple $test $test {
95 -re "You may have requested too many.*$gdb_prompt $" {
96 pass $test
98 -re "Breakpoint .*, foo .*$gdb_prompt $" {
99 pass $test
100 set can_do_cmd 1
104 if { !$can_do_cmd } {
105 unsupported "no target support"
106 return
109 delete_breakpoints
111 gdb_test "$break_command foo" ".*reakpoint .* at .*"
113 # A condition that evals false.
114 gdb_test "condition \$bpnum cond_global==1" ".*"
116 gdb_test "b bar" "Breakpoint .* at .*"
118 gdb_test "continue" "Breakpoint .*, bar .*"
122 # Test setting conditions in watchpoints. WATCH_COMMAND is the watch
123 # command to test.
125 proc test_watch { watch_command } {
126 global gdb_prompt
127 global allow_hw_watchpoint_tests_p
129 with_test_prefix "$watch_command" {
130 if {!$allow_hw_watchpoint_tests_p} {
131 unsupported "no target support"
132 return
135 delete_breakpoints
137 gdb_test "$watch_command global" ".*atchpoint .*: global.*"
139 # A condition that evals true.
140 gdb_test "condition \$bpnum cond_global==0" ".*"
142 set can_do_cmd 0
144 set test "continue"
145 gdb_test_multiple $test $test {
146 -re "You may have requested too many.*$gdb_prompt $" {
147 pass $test
149 -re "atchpoint .*: global.*$gdb_prompt $" {
150 pass $test
151 set can_do_cmd 1
155 if { !$can_do_cmd } {
156 unsupported "no target support"
157 return
160 delete_breakpoints
162 gdb_test "$watch_command global" ".*atchpoint .*: global.*"
164 # A condition that evals false.
165 gdb_test "condition \$bpnum cond_global==1" ".*"
167 gdb_test "b bar" "Breakpoint .* at .*"
169 gdb_test "continue" "Breakpoint .*, bar .*"
173 foreach break_command { "break" "hbreak" } {
174 test_break $break_command
177 foreach watch_command { "watch" "rwatch" "awatch" } {
178 test_watch $watch_command