1 # Copyright
(C
) 2018-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 # Test access to special purpose registers PPR and DSCR. The test
19 # inferior writes to these registers
, we check that GDB reads the same
20 #
values, then write to the registers trough GDB
, step once
, and check
21 # again
if we read
back the same
values.
23 require
{istarget
"powerpc*-*-linux*"}
27 if {[build_executable
"compile" $binfile $srcfile {debug}] == -1} {
31 proc check_register_access
{ regname
} {
34 set test
"$regname register access"
35 gdb_test_multiple
"info reg $regname" "$test" {
36 -re
"Invalid register.*\r\n$gdb_prompt $" {
40 -re
"\r\n$regname.*\r\n$gdb_prompt $" {
48 #
Do one pass to check
if the instructions in our test programs are
49 # available to this processor
(e.g. mtspr
3, RS
for accessing DSCR
).
50 proc ppr_dscr_available
{} {
52 global inferior_exited_re
54 set test
"PPR/DSCR available to inferior"
55 gdb_test_multiple
"continue" "" {
56 -re
"Illegal instruction.*\r\n$gdb_prompt $" {
60 -re
"$inferior_exited_re normally.*$gdb_prompt $" {
68 with_test_prefix
"check PPR/DSCR access" {
69 clean_restart $binfile
75 if {![check_register_access
"ppr"]} {
79 if {![check_register_access
"dscr"]} {
83 if {![ppr_dscr_available
]} {
88 # Now
do the actual test
89 clean_restart $binfile
95 gdb_breakpoint
[gdb_get_line_number
"marker"]
97 gdb_continue_to_breakpoint
"continue to marker"
99 # At the breakpoint the inferior should have
set the
100 # registers to these expected
values.
102 with_test_prefix
"before write" {
103 gdb_test
"info reg dscr" "dscr.*0x0*20\[ \t\]+.*"
104 gdb_test
"info reg ppr" "ppr.*0x0*8000000000000\[ \t\]+.*"
107 #
Set Store Stream Enable in DSCR and
set PPR to the medium
-low
109 gdb_test_no_output
"set \$dscr = 0x8"
110 gdb_test_no_output
"set \$ppr = 0xC000000000000"
112 gdb_test
"stepi" "asm.*"
114 with_test_prefix
"after write" {
115 gdb_test
"info reg dscr" "dscr.*0x0*8+\[ \t\]+.*"
116 gdb_test
"info reg ppr" "ppr.*0x0*\[cC\]000000000000\[ \t\]+.*"