]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / powerpc-ppr-dscr.exp
1 # Copyright (C) 2018-2024 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 # This file is part of the gdb testsuite.
17
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.
22
23 require {istarget "powerpc*-*-linux*"}
24
25 standard_testfile .c
26
27 if {[build_executable "compile" $binfile $srcfile {debug}] == -1} {
28 return
29 }
30
31 proc check_register_access { regname } {
32 global gdb_prompt
33
34 set test "$regname register access"
35 gdb_test_multiple "info reg $regname" "$test" {
36 -re "Invalid register.*\r\n$gdb_prompt $" {
37 unsupported "$test"
38 return 0
39 }
40 -re "\r\n$regname.*\r\n$gdb_prompt $" {
41 pass "$test"
42 return 1
43 }
44 }
45 return 0
46 }
47
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 {} {
51 global gdb_prompt
52 global inferior_exited_re
53
54 set test "PPR/DSCR available to inferior"
55 gdb_test_multiple "continue" "" {
56 -re "Illegal instruction.*\r\n$gdb_prompt $" {
57 unsupported "$test"
58 return 0
59 }
60 -re "$inferior_exited_re normally.*$gdb_prompt $" {
61 pass "$test"
62 return 1
63 }
64 }
65 return 0
66 }
67
68 with_test_prefix "check PPR/DSCR access" {
69 clean_restart $binfile
70
71 if ![runto_main] {
72 return
73 }
74
75 if {![check_register_access "ppr"]} {
76 return
77 }
78
79 if {![check_register_access "dscr"]} {
80 return
81 }
82
83 if {![ppr_dscr_available]} {
84 return
85 }
86 }
87
88 # Now do the actual test
89 clean_restart $binfile
90
91 if ![runto_main] {
92 return
93 }
94
95 gdb_breakpoint [gdb_get_line_number "marker"]
96
97 gdb_continue_to_breakpoint "continue to marker"
98
99 # At the breakpoint the inferior should have set the
100 # registers to these expected values.
101
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\]+.*"
105 }
106
107 # Set Store Stream Enable in DSCR and set PPR to the medium-low
108 # priority.
109 gdb_test_no_output "set \$dscr = 0x8"
110 gdb_test_no_output "set \$ppr = 0xC000000000000"
111
112 gdb_test "stepi" "asm.*"
113
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\]+.*"
117 }