1 # Copyright (C) 2018-2020 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 if {![istarget "powerpc*-*-linux*"]} then {
24 verbose "Skipping PowerPC test for PPR and DSCR registers."
30 if {[build_executable "compile" $binfile $srcfile {debug}] == -1} {
34 proc check_register_access { regname } {
37 set test "$regname register access"
38 gdb_test_multiple "info reg $regname" "$test" {
39 -re "Invalid register.*\r\n$gdb_prompt $" {
43 -re "\r\n$regname.*\r\n$gdb_prompt $" {
51 # Do one pass to check if the instructions in our test programs are
52 # available to this processor (e.g. mtspr 3, RS for accessing DSCR).
53 proc ppr_dscr_available {} {
55 global inferior_exited_re
57 set test "PPR/DSCR available to inferior"
58 gdb_test_multiple "continue" "" {
59 -re "Illegal instruction.*\r\n$gdb_prompt $" {
63 -re "$inferior_exited_re normally.*$gdb_prompt $" {
71 with_test_prefix "check PPR/DSCR access" {
72 clean_restart $binfile
78 if {![check_register_access "ppr"]} {
82 if {![check_register_access "dscr"]} {
86 if {![ppr_dscr_available]} {
91 # Now do the actual test
92 clean_restart $binfile
98 gdb_breakpoint [gdb_get_line_number "marker"]
100 gdb_continue_to_breakpoint "continue to marker"
102 # At the breakpoint the inferior should have set the
103 # registers to these expected values.
105 with_test_prefix "before write" {
106 gdb_test "info reg dscr" "dscr.*0x0*20\[ \t\]+.*"
107 gdb_test "info reg ppr" "ppr.*0x0*8000000000000\[ \t\]+.*"
110 # Set Store Stream Enable in DSCR and set PPR to the medium-low
112 gdb_test_no_output "set \$dscr = 0x8"
113 gdb_test_no_output "set \$ppr = 0xC000000000000"
115 gdb_test "stepi" "asm.*"
117 with_test_prefix "after write" {
118 gdb_test "info reg dscr" "dscr.*0x0*8+\[ \t\]+.*"
119 gdb_test "info reg ppr" "ppr.*0x0*\[cC\]000000000000\[ \t\]+.*"