]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2022-2024 Free Software Foundation, Inc. |
e63ae49b LM |
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 | # Check if the W registers have the expected size and if setting/fetching | |
17 | # values from W registers works correctly for both big and little endian. | |
18 | ||
d9050fb8 | 19 | require is_aarch64_target |
e63ae49b LM |
20 | |
21 | standard_testfile | |
22 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile {nodebug}]} { | |
23 | return -1 | |
24 | } | |
25 | ||
26 | if ![runto_main] { | |
27 | untested "could not run to main" | |
28 | return -1 | |
29 | } | |
30 | ||
31 | array set w_values { | |
32 | 0 0x0 | |
33 | 1 0x10 | |
34 | 2 0x2010 | |
35 | 3 0x302010 | |
36 | 4 0x40302010 | |
37 | 5 0x40302010 | |
38 | 6 0x40302010 | |
39 | 7 0x40302010 | |
40 | 8 0x40302010 | |
41 | } | |
42 | ||
43 | array set x_values { | |
44 | 0 0x0 | |
45 | 1 0x10 | |
46 | 2 0x2010 | |
47 | 3 0x302010 | |
48 | 4 0x40302010 | |
49 | 5 0x5040302010 | |
50 | 6 0x605040302010 | |
51 | 7 0x70605040302010 | |
52 | 8 0x8070605040302010 | |
53 | } | |
54 | ||
55 | # Exercise various things for register w<rn> | |
56 | ||
57 | proc test_register { rn } { | |
58 | gdb_test "ptype \$w${rn}" "type = uint32_t" | |
59 | gdb_test "p sizeof(\$w${rn})" " = 4" | |
60 | ||
61 | # Set all bits of x<rn> | |
62 | gdb_test_no_output "set \$x${rn}=0xffffffffffffffff" \ | |
63 | "set all bits of x${rn}" | |
64 | ||
65 | # Test setting/fetching values | |
66 | for {set i 0} {$i < 9} {incr i} { | |
67 | global w_values | |
68 | global x_values | |
69 | ||
70 | with_test_prefix "set w${rn} to $x_values($i)" { | |
71 | # Set value of W and see the effects on W and X. | |
72 | gdb_test_no_output "set \$w${rn}=$x_values($i)" | |
73 | gdb_test "p/x \$w${rn}" "= $w_values($i)" | |
74 | gdb_test "p/x \$x${rn}" "= $w_values($i)" | |
75 | } | |
76 | ||
77 | with_test_prefix "set x${rn} to $x_values($i)" { | |
78 | # Set value of X and see the effects on W and X. | |
79 | gdb_test_no_output "set \$x${rn}=$x_values($i)" | |
80 | gdb_test "p/x \$w${rn}" "= $w_values($i)" | |
81 | gdb_test "p/x \$x${rn}" "= $x_values($i)" | |
82 | ||
83 | # Set all bits of x<rn> | |
84 | gdb_test_no_output "set \$x${rn}=0xffffffffffffffff" \ | |
85 | "set all bits of x${rn}" | |
86 | } | |
87 | } | |
88 | } | |
89 | ||
90 | # Run tests | |
91 | foreach_with_prefix endian {"little" "big"} { | |
92 | gdb_test "set endian ${endian}" "The target is set to ${endian} endian\." | |
93 | ||
94 | for {set i 0} {$i < 31} {incr i} { | |
95 | test_register $i | |
96 | } | |
97 | } |