1 # Copyright
2014-2024 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 # This file is part of the gdb testsuite
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
23 # Disable hardware watchpoints
if the target does not support them.
25 set allow_hw_watchpoint_tests_p
[allow_hw_watchpoint_tests
]
29 if {[prepare_for_testing
"failed to prepare" $testfile $srcfile debug]} {
33 #
Set a watchpoint watching EXPR.
37 set expr_re
[string_to_regexp $expr
]
38 gdb_test
"watch $expr" \
39 "\(Hardware \)?\[Ww\]atchpoint $decimal: $expr_re"
42 #
Continue inferior execution
, expecting the watchpoint EXPR to be triggered
43 # having old value OLD and new value NEW.
44 proc expect_watchpoint
{ expr old new
} {
45 with_test_prefix
"$expr: $old->$new" {
46 set expr_re
[string_to_regexp $expr
]
47 gdb_test
"print $expr" "\\$\\d+ = $old" "print expression before"
48 gdb_test
"continue" "$expr_re\\s.*Old value = $old\\s+New value = $new\\s.*"
49 gdb_test
"print $expr" "\\$\\d+ = $new" "print expression after"
53 # Check that
-location watchpoints against bitfields trigger properly.
54 proc test_watch_location
{} {
55 with_test_prefix
"-location watch against bitfields" {
62 expect_watchpoint
"q.a" 0 1
63 expect_watchpoint
"q.e" 0 5
64 expect_watchpoint
"q.a" 1 0
65 expect_watchpoint
"q.e" 5 4
67 # It
'll execute a large amount of code with software watchpoint
68 # enabled, which means GDB will single stepping all the way
69 # through til the inferior exits. Increase the timeout by a
71 with_timeout_factor 4 {
77 # Check that regular watchpoints against expressions involving
78 # bitfields trigger properly.
79 proc test_regular_watch {} {
80 with_test_prefix "regular watch against bitfields" {
85 watch "q.d + q.f + q.g"
86 expect_watchpoint "q.d + q.f + q.g" 0 4
87 expect_watchpoint "q.d + q.f + q.g" 4 10
88 expect_watchpoint "q.d + q.f + q.g" 10 3
89 expect_watchpoint "q.d + q.f + q.g" 3 2
90 expect_watchpoint "q.d + q.f + q.g" 2 1
91 expect_watchpoint "q.d + q.f + q.g" 1 0
93 # It'll
execute a large amount of code with software watchpoint
94 # enabled
, which means GDB will single stepping all the way
95 # through til the inferior exits. Increase the timeout by a
97 with_timeout_factor
4 {
103 # Disable hardware watchpoints
if the target does not support them.
104 if {!$allow_hw_watchpoint_tests_p
} {
105 gdb_test_no_output
"set can-use-hw-watchpoints 0" ""