]>
Commit | Line | Data |
---|---|---|
3666a048 | 1 | # Copyright (C) 2018-2021 Free Software Foundation, Inc. |
7ca18ed6 EBM |
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 | if {![istarget "powerpc*-*-linux*"]} then { | |
24 | verbose "Skipping PowerPC test for PPR and DSCR registers." | |
25 | return | |
26 | } | |
27 | ||
28 | standard_testfile .c | |
29 | ||
30 | if {[build_executable "compile" $binfile $srcfile {debug}] == -1} { | |
31 | return | |
32 | } | |
33 | ||
34 | proc check_register_access { regname } { | |
35 | global gdb_prompt | |
36 | ||
37 | set test "$regname register access" | |
38 | gdb_test_multiple "info reg $regname" "$test" { | |
39 | -re "Invalid register.*\r\n$gdb_prompt $" { | |
40 | unsupported "$test" | |
41 | return 0 | |
42 | } | |
43 | -re "\r\n$regname.*\r\n$gdb_prompt $" { | |
44 | pass "$test" | |
45 | return 1 | |
46 | } | |
47 | } | |
48 | return 0 | |
49 | } | |
50 | ||
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 {} { | |
54 | global gdb_prompt | |
55 | global inferior_exited_re | |
56 | ||
57 | set test "PPR/DSCR available to inferior" | |
58 | gdb_test_multiple "continue" "" { | |
59 | -re "Illegal instruction.*\r\n$gdb_prompt $" { | |
60 | unsupported "$test" | |
61 | return 0 | |
62 | } | |
63 | -re "$inferior_exited_re normally.*$gdb_prompt $" { | |
64 | pass "$test" | |
65 | return 1 | |
66 | } | |
67 | } | |
68 | return 0 | |
69 | } | |
70 | ||
71 | with_test_prefix "check PPR/DSCR access" { | |
72 | clean_restart $binfile | |
73 | ||
74 | if ![runto_main] { | |
75 | return | |
76 | } | |
77 | ||
78 | if {![check_register_access "ppr"]} { | |
79 | return | |
80 | } | |
81 | ||
82 | if {![check_register_access "dscr"]} { | |
83 | return | |
84 | } | |
85 | ||
86 | if {![ppr_dscr_available]} { | |
87 | return | |
88 | } | |
89 | } | |
90 | ||
91 | # Now do the actual test | |
92 | clean_restart $binfile | |
93 | ||
94 | if ![runto_main] { | |
95 | return | |
96 | } | |
97 | ||
98 | gdb_breakpoint [gdb_get_line_number "marker"] | |
99 | ||
100 | gdb_continue_to_breakpoint "continue to marker" | |
101 | ||
102 | # At the breakpoint the inferior should have set the | |
103 | # registers to these expected values. | |
104 | ||
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\]+.*" | |
108 | } | |
109 | ||
110 | # Set Store Stream Enable in DSCR and set PPR to the medium-low | |
111 | # priority. | |
112 | gdb_test_no_output "set \$dscr = 0x8" | |
113 | gdb_test_no_output "set \$ppr = 0xC000000000000" | |
114 | ||
115 | gdb_test "stepi" "asm.*" | |
116 | ||
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\]+.*" | |
120 | } |