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