1 # Copyright
2017-2019 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 if {[skip_hw_watchpoint_tests
]} {
25 if { [prepare_for_testing $
{testfile
}.exp $
{testfile
} $
{srcfile
}] } {
30 untested
"could not run to main"
34 gdb_breakpoint
[gdb_get_line_number
"start_again"] "Breakpoint $decimal at $hex" "start_again"
37 array
set alignedend
{1 1 2 2 3 4 4 4 5 8 6 8 7 8 8 8}
40 set rwatch_exp
"Hardware read watchpoint"
41 if {[istarget
"s390*-*-*"]} {
42 # Target does not support this type of hardware watchpoint.
"
44 set rwatch_exp
"Hardware watchpoint"
47 foreach wpsize $sizes
{
48 for {set wpoffset
0} {$wpoffset
< 8 / $wpsize
} {incr wpoffset
} {
49 set wpstart
[expr $wpoffset
* $wpsize
]
50 set wpend
[expr
($wpoffset
+ 1) * $wpsize
]
51 set wpendaligned $alignedend
($wpend
)
52 foreach rdsize $sizes
{
53 for {set rdoffset
0} {$rdoffset
< 8 / $rdsize
} {incr rdoffset
} {
54 set rdstart
[expr $rdoffset
* $rdsize
]
55 set rdend
[expr
($rdoffset
+ 1) * $rdsize
]
56 set expect_hit
[expr
max ($wpstart
, $rdstart
) < min ($wpend
, $rdend
)]
57 set test
"$rwatch data.u.size$wpsize\[$wpoffset\]"
59 gdb_test_multiple $test $test
{
60 -re
"$rwatch_exp (\[0-9\]+): .*\r\n$gdb_prompt $" {
61 set wpnum $expect_out
(1,string
)
63 -re
"Expression cannot be implemented with read/access watchpoint.\r\n$gdb_prompt $" {
64 if {$wpsize
== 8 && [istarget
"arm*-*-*"]} {
71 gdb_test_no_output
"set variable size = $rdsize" ""
72 gdb_test_no_output
"set variable offset = $rdoffset" ""
75 gdb_test_multiple $test $test
{
76 -re
"$rwatch_exp $wpnum:.*alue = .*\r\n$gdb_prompt $" {
81 -re
" start_again .*\r\n$gdb_prompt $" {
84 gdb_test_no_output
"delete $wpnum" ""
85 set test
"wp(size=$wpsize offset=$wpoffset) rd(size=$rdsize offset=$rdoffset) expect=$expect_hit"
86 if {$expect_hit
== $got_hit
} {
89 # We
do not know
if we run
on a fixed Linux kernel
90 # or not.
Report XFAIL only in the FAIL case.
91 if {$expect_hit
== 0 && $rdstart
< $wpendaligned
} {
92 setup_xfail external
/20207 "aarch64*-*-linux*"
94 if {!$expect_hit
&& [expr
max ($wpstart
/ 8, $rdstart
/ 8) < min (($wpend
+ 7) / 8, ($rdend
+ 7) / 8)]} {
95 setup_xfail breakpoints
/23131 "powerpc*-*-*"
104 foreach wpcount
{4 7} {
105 array
set wpoffset_to_wpnum
{}
106 for {set wpoffset
1} {$wpoffset
<= $wpcount
} {incr wpoffset
} {
107 set test
"$rwatch data.u.size1\[$wpoffset\]"
109 gdb_test_multiple $test $test
{
110 -re
"$rwatch_exp (\[0-9\]+): .*\r\n$gdb_prompt $" {
111 set wpoffset_to_wpnum
($wpoffset
) $expect_out
(1,string
)
113 -re
"There are not enough available hardware resources for this watchpoint.\r\n$gdb_prompt $" {
115 setup_xfail breakpoints
/23131 "powerpc*-*-*"
116 setup_xfail breakpoints
/23131 "arm*-*-*"
119 set wpoffset_to_wpnum
($wpoffset
) 0
123 gdb_test_no_output
"set variable size = 1" ""
124 gdb_test_no_output
"set variable offset = 1" ""
127 gdb_test_multiple $test $test
{
128 -re
"\r\nCould not insert hardware watchpoint .*\r\n$gdb_prompt $" {
130 -re
"$rwatch_exp $wpoffset_to_wpnum(1):.*alue = .*\r\n$gdb_prompt $" {
132 send_gdb
"continue\n"
135 -re
" start_again .*\r\n$gdb_prompt $" {
138 for {set wpoffset
1} {$wpoffset
<= $wpcount
} {incr wpoffset
} {
139 if {$wpoffset_to_wpnum
($wpoffset
)} {
140 gdb_test_no_output
"delete $wpoffset_to_wpnum($wpoffset)" ""
143 set test
"wpcount($wpcount)"
144 if {!$wpoffset_to_wpnum
([expr $wpcount
- 1])} {
149 if {![istarget
"s390*-*-*"]} {
150 setup_kfail tdep
/22389 *-*-*
153 gdb_assert $got_hit $test
159 gdb_breakpoint
[gdb_get_line_number
"final_return"] "Breakpoint $decimal at $hex" "final_return"
160 set test
{watch data.u.size8twice
[1]}
162 gdb_test_multiple $test $test
{
163 -re
"Hardware watchpoint (\[0-9\]+): .*\r\n$gdb_prompt $" {
164 set wpnum $expect_out
(1,string
)
166 -re
"Watchpoint (\[0-9\]+): .*\r\n$gdb_prompt $" {
167 if {[istarget
"arm*-*-*"]} {
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"