1 # Copyright
2017-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 # This file is part of the gdb testsuite.
18 # Test inserting read watchpoints
on unaligned addresses.
20 require allow_hw_watchpoint_tests
23 if { [prepare_for_testing $
{testfile
}.exp $
{testfile
} $
{srcfile
}] } {
31 gdb_breakpoint
[gdb_get_line_number
"start_again"] "Breakpoint $decimal at $hex" "start_again"
34 array
set alignedend
{1 1 2 2 3 4 4 4 5 8 6 8 7 8 8 8}
37 set rwatch_exp
"Hardware read watchpoint"
38 if {[istarget
"s390*-*-*"]} {
39 # Target does not support this type of hardware watchpoint.
"
41 set rwatch_exp
"Hardware watchpoint"
44 foreach wpsize $sizes
{
45 for {set wpoffset
0} {$wpoffset
< 8 / $wpsize
} {incr wpoffset
} {
46 set wpstart
[expr $wpoffset
* $wpsize
]
47 set wpend
[expr
($wpoffset
+ 1) * $wpsize
]
48 set wpendaligned $alignedend
($wpend
)
49 foreach rdsize $sizes
{
50 for {set rdoffset
0} {$rdoffset
< 8 / $rdsize
} {incr rdoffset
} {
51 set rdstart
[expr $rdoffset
* $rdsize
]
52 set rdend
[expr
($rdoffset
+ 1) * $rdsize
]
53 set expect_hit
[expr
max ($wpstart
, $rdstart
) < min ($wpend
, $rdend
)]
54 set test
"$rwatch data.u.size$wpsize\[$wpoffset\]"
56 gdb_test_multiple $test $test
{
57 -re
"$rwatch_exp (\[0-9\]+): .*\r\n$gdb_prompt $" {
58 set wpnum $expect_out
(1,string
)
60 -re
"Expression cannot be implemented with read/access watchpoint.\r\n$gdb_prompt $" {
61 if {$wpsize
== 8 && [istarget
"arm*-*-*"]} {
68 gdb_test_no_output
-nopass
"set variable size = $rdsize"
69 gdb_test_no_output
-nopass
"set variable offset = $rdoffset"
72 gdb_test_multiple $test $test
{
73 -re
"$rwatch_exp $wpnum:.*alue = .*\r\n$gdb_prompt $" {
78 -re
" start_again .*\r\n$gdb_prompt $" {
81 gdb_test_no_output
-nopass
"delete $wpnum"
82 set test
"wp(size=$wpsize offset=$wpoffset) rd(size=$rdsize offset=$rdoffset) expect=$expect_hit"
83 if {$expect_hit
== $got_hit
} {
86 # We
do not know
if we run
on a fixed Linux kernel
87 # or not.
Report XFAIL only in the FAIL case.
88 if {$expect_hit
== 0 && $rdstart
< $wpendaligned
} {
89 setup_xfail external
/20207 "aarch64*-*-linux*"
91 if {!$expect_hit
&& [expr
max ($wpstart
/ 8, $rdstart
/ 8) < min (($wpend
+ 7) / 8, ($rdend
+ 7) / 8)]} {
92 setup_xfail breakpoints
/23131 "powerpc*-*-*"
101 foreach wpcount
{4 7} {
102 array
set wpoffset_to_wpnum
{}
103 for {set wpoffset
1} {$wpoffset
<= $wpcount
} {incr wpoffset
} {
104 set test
"$rwatch data.u.size1\[$wpoffset\]"
106 # Initialize the result incase the test fails.
107 set wpoffset_to_wpnum
($wpoffset
) 0
108 gdb_test_multiple $test $test
{
109 -re
"$rwatch_exp (\[0-9\]+): .*\r\n$gdb_prompt $" {
110 set wpoffset_to_wpnum
($wpoffset
) $expect_out
(1,string
)
112 -re
"There are not enough available hardware resources for this watchpoint.\r\n$gdb_prompt $" {
114 setup_xfail breakpoints
/23131 "powerpc*-*-*"
115 setup_xfail breakpoints
/23131 "arm*-*-*"
121 gdb_test_no_output
-nopass
"set variable size = 1"
122 gdb_test_no_output
-nopass
"set variable offset = 1"
125 gdb_test_multiple $test $test
{
126 -re
"\r\nCould not insert hardware watchpoint .*\r\n$gdb_prompt $" {
128 -re
"$rwatch_exp $wpoffset_to_wpnum(1):.*alue = .*\r\n$gdb_prompt $" {
130 send_gdb
"continue\n"
133 -re
" start_again .*\r\n$gdb_prompt $" {
136 for {set wpoffset
1} {$wpoffset
<= $wpcount
} {incr wpoffset
} {
137 if {$wpoffset_to_wpnum
($wpoffset
)} {
138 gdb_test_no_output
"delete $wpoffset_to_wpnum($wpoffset)" ""
141 set test
"wpcount($wpcount)"
142 if {!$wpoffset_to_wpnum
([expr $wpcount
- 1])} {
147 if {![istarget
"s390*-*-*"]} {
148 setup_kfail tdep
/22389 *-*-*
151 gdb_assert $got_hit $test
157 gdb_breakpoint
[gdb_get_line_number
"final_return"] "Breakpoint $decimal at $hex" "final_return"
158 set test
{watch data.u.size8twice
[1]}
160 gdb_test_multiple $test $test
{
161 -re
"Hardware watchpoint (\[0-9\]+): .*\r\n$gdb_prompt $" {
162 set wpnum $expect_out
(1,string
)
165 -re
"Watchpoint (\[0-9\]+): .*\r\n$gdb_prompt $" {
166 if {[istarget
"arm*-*-*"]} {
167 untested $gdb_test_name
176 gdb_test_multiple $test $test
{
177 -re
"\r\nCould not insert hardware watchpoint .*\r\n$gdb_prompt $" {
179 -re
"Hardware watchpoint $wpnum:.*New value = .*\r\n$gdb_prompt $" {
181 send_gdb
"continue\n"
184 -re
" final_return .*\r\n$gdb_prompt $" {
187 gdb_assert $got_hit
"size8twice write"