]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/e500-regs.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / e500-regs.exp
1 # Copyright 2003-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
17 # Tests for Powerpc E500 register setting and fetching
18
19 #
20 # Test the use of registers, especially E500 registers, for Powerpc.
21 # This file uses e500-regs.c for input.
22 #
23
24 require {istarget "powerpc-*eabispe"}
25
26 set testfile "e500-regs"
27 set binfile ${objdir}/${subdir}/${testfile}
28 set src1 ${srcdir}/${subdir}/${testfile}.c
29
30 if { [gdb_compile ${src1} ${binfile} executable {debug nowarnings}] != "" } {
31 untested "failed to compile"
32 return -1
33 }
34
35 gdb_start
36 gdb_reinitialize_dir $srcdir/$subdir
37 gdb_load ${binfile}
38
39 #
40 # Run to `main' where we begin our tests.
41 #
42
43 if {![runto_main]} {
44 return 0
45 }
46
47 # set all the registers integer portions to 1
48 for {set i 0} {$i < 32} {incr i 1} {
49 for {set j 0} {$j < 2} {incr j 1} {
50 gdb_test "set \$ev$i.v2_int32\[$j\] = 1" "" "set reg ev$i.v4si.f\[$j\]"
51 }
52 }
53
54 # Now execute some target code, so that GDB's register cache is flushed.
55
56 #gdb_test "next" "" ""
57
58 set endianness [get_endianness]
59
60 # And then read the E500 registers back, to see that
61 # a) the register write above worked, and
62 # b) the register read (below) also works.
63
64 if {$endianness == "big"} {
65 set vector_register ".uint64 = 0x100000001, v2_float = .0x0, 0x0., v2_int32 = .0x1, 0x1., v4_int16 = .0x0, 0x1, 0x0, 0x1., v8_int8 = .0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1.."
66 } else {
67 set vector_register ".uint64 = 0x100000001, v2_float = .0x0, 0x0., v2_int32 = .0x1, 0x1., v4_int16 = .0x1, 0x0, 0x1, 0x0., v8_int8 = .0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0.."
68 }
69
70 for {set i 0} {$i < 32} {incr i 1} {
71 gdb_test "info reg ev$i" "ev$i.*$vector_register" "info reg ev$i"
72 }
73
74 # Test whether the GPRs are updated accordingly. (GPRs are just the lower
75 # 32 bits of the EV registers.)
76
77 set general_register "0x1\[ \t\]+1"
78
79 for {set i 0} {$i < 32} {incr i 1} {
80 gdb_test "info reg r$i" "r$i.*$general_register" "info reg r$i"
81 }
82
83 # Now redo the same tests, but using the print command.
84
85 if {$endianness == "big"} {
86 set decimal_vector ".uint64 = 4294967297, v2_float = .1.*e-45, 1.*e-45., v2_int32 = .1, 1., v4_int16 = .0, 1, 0, 1., v8_int8 = .0, 0, 0, 1, 0, 0, 0, 1.."
87 } else {
88 set decimal_vector ".uint64 = 4294967297, v2_float = .1.*e-45, 1.*e-45., v2_int32 = .1, 1., v4_int16 = .1, 0, 1, 0., v8_int8 = .1, 0, 0, 0, 1, 0, 0, 0.."
89 }
90
91 for {set i 0} {$i < 32} {incr i 1} {
92 gdb_test "print \$ev$i" ".* = $decimal_vector" "print ev$i"
93 }
94
95 for {set i 0} {$i < 32} {incr i 1} {
96 set pattern$i ".*ev$i.*"
97 append pattern$i $vector_register
98 }
99
100 send_gdb "info vector\n"
101 gdb_expect_list "info vector" ".*$gdb_prompt $" {
102 [$pattern0]
103 [$pattern1]
104 [$pattern2]
105 [$pattern3]
106 [$pattern4]
107 [$pattern5]
108 [$pattern6]
109 [$pattern7]
110 [$pattern8]
111 [$pattern9]
112 [$pattern10]
113 [$pattern11]
114 [$pattern12]
115 [$pattern13]
116 [$pattern14]
117 [$pattern15]
118 [$pattern16]
119 [$pattern17]
120 [$pattern18]
121 [$pattern19]
122 [$pattern20]
123 [$pattern21]
124 [$pattern22]
125 [$pattern23]
126 [$pattern24]
127 [$pattern25]
128 [$pattern26]
129 [$pattern27]
130 [$pattern28]
131 [$pattern29]
132 [$pattern30]
133 [$pattern31]
134 }
135
136 # We must restart everything, because we have set important registers to
137 # some unusual values.
138
139 clean_restart $binfile
140 if {![runto_main]} {
141 return 0
142 }
143
144 gdb_test "break vector_fun" \
145 "Breakpoint 2 at.*e500-regs.c, line \[0-9\]+\\." \
146 "set breakpoint at vector_fun"
147
148 # Actually it is nuch easier to see these results printed in hex.
149 # gdb_test "set output-radix 16" \
150 # "Output radix now set to decimal 16, hex 10, octal 20." \
151 # "set output radix to hex"
152
153 gdb_test "continue" \
154 "Breakpoint 2, vector_fun .a=.-2, -2., b=.1, 1.*e500-regs.c.*ev_create_s32 .2, 2.;" \
155 "continue to vector_fun"
156
157 # Do a next over the assignment to vector 'a'.
158 gdb_test "next" ".*b = \\(vector int\\) __ev_create_s32 \\(3, 3\\);" \
159 "next (1)"
160
161 # Do a next over the assignment to vector 'b'.
162 gdb_test "next" "c = __ev_and \\(a, b\\);" \
163 "next (2)"
164
165 # Now 'a' should be '0x02020202...' and 'b' should be '0x03030303...'
166 gdb_test "print/x a" \
167 ".*= .0x2, 0x2." \
168 "print vector parameter a"
169
170 gdb_test "print/x b" \
171 ".*= .0x3, 0x3." \
172 "print vector parameter b"
173
174 # If we do an 'up' now, and print 'x' and 'y' we should see the values they
175 # have in main, not the values they have in vector_fun.
176 gdb_test "up" ".1.*main \\(\\) at.*e500-regs.c.*z = vector_fun \\(x, y\\);" \
177 "up to main"
178
179 gdb_test "print x" \
180 ".*= .-2, -2." \
181 "print vector x"
182
183 gdb_test "print y" \
184 ".*= .1, 1." \
185 "print vector y"
186
187 # now go back to vector_func and do a finish, to see if we can print the return
188 # value correctly.
189
190 gdb_test "down" \
191 ".0 vector_fun \\(a=.2, 2., b=.3, 3.\\) at.*e500-regs.c.*c = __ev_and \\(a, b\\);" \
192 "down to vector_fun"
193
194 gdb_test "finish" \
195 "Run till exit from .0 vector_fun \\(a=.2, 2., b=.3, 3.\\) at.*e500-regs.c.*main \\(\\) at.*e500-regs.c.*z = vector_fun \\(x, y\\);.*Value returned is.*= .2, 2." \
196 "finish returned correct value"
197
198
199