]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/altivec-regs.exp
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / altivec-regs.exp
CommitLineData
ecd75fc8 1# Copyright (C) 2002-2014 Free Software Foundation, Inc.
57680a24
EZ
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
57680a24
EZ
6# (at your option) any later version.
7#
e22f8b7c 8# This program is distributed in the hope that it will be useful,
57680a24
EZ
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.
e22f8b7c 12#
57680a24 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
57680a24 15#
57680a24
EZ
16
17# Tests for Powerpc AltiVec register setting and fetching
18
57680a24
EZ
19#
20# Test the use of registers, especially AltiVec registers, for Powerpc.
21# This file uses altivec-regs.c for input.
22#
23
57680a24 24
3c95e6af 25if {![istarget "powerpc*"] || [skip_altivec_tests]} then {
57680a24
EZ
26 verbose "Skipping altivec register tests."
27 return
28}
29
30set testfile "altivec-regs"
31set binfile ${objdir}/${subdir}/${testfile}
f2dd3617 32set srcfile ${testfile}.c
57680a24 33
fc91c6c2 34set compile_flags {debug nowarnings}
4c93b1db 35if [get_compiler_info] {
d1779be4
PG
36 warning "get_compiler failed"
37 return -1
38}
39
40if [test_compiler_info gcc*] {
e7b1eae6 41 set compile_flags "$compile_flags additional_flags=-maltivec additional_flags=-mabi=altivec"
d1779be4
PG
42} elseif [test_compiler_info xlc*] {
43 set compile_flags "$compile_flags additional_flags=-qaltivec"
44} else {
45 warning "unknown compiler"
46 return -1
47}
48
49if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $compile_flags] != "" } {
b60f0898
JB
50 untested altivec-regs.exp
51 return -1
57680a24
EZ
52}
53
54gdb_start
55gdb_reinitialize_dir $srcdir/$subdir
56gdb_load ${binfile}
57
58#
59# Run to `main' where we begin our tests.
60#
61
62if ![runto_main] then {
63 gdb_suppress_tests
64}
65
0d8f9b2c
NF
66gdb_test "set print frame-arguments all"
67
57680a24
EZ
68# set all the registers integer portions to 1
69for {set i 0} {$i < 32} {incr i 1} {
70 for {set j 0} {$j < 4} {incr j 1} {
71 gdb_test "set \$vr$i.v4_int32\[$j\] = 1" "" "set reg vr$i.v4si.f\[$j\]"
72 }
73}
74
75gdb_test "set \$vscr = 1" "" ""
76gdb_test "set \$vrsave = 1" "" ""
77
78# Now execute some target code, so that GDB's register cache is flushed.
79
80gdb_test "next" "" ""
81
82send_gdb "show endian\n"
2429decf 83set endianness ""
57680a24
EZ
84gdb_expect {
85 -re "(The target endianness is set automatically .currently )(big|little)( endian.*)$gdb_prompt $" {
86 pass "endianness"
87 set endianness $expect_out(2,string)
88 }
89 -re ".*$gdb_prompt $" {
90 fail "couldn't get endianness"
91 }
92 timeout { fail "(timeout) endianness" }
93}
94
95# And then read the AltiVec registers back, to see that
96# a) the register write above worked, and
97# b) the register read (below) also works.
98
99if {$endianness == "big"} {
100set vector_register ".uint128 = 0x00000001000000010000000100000001, v4_float = .0x0, 0x0, 0x0, 0x0., v4_int32 = .0x1, 0x1, 0x1, 0x1., v8_int16 = .0x0, 0x1, 0x0, 0x1, 0x0, 0x1, 0x0, 0x1., v16_int8 = .0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1.."
101} else {
102set vector_register ".uint128 = 0x00000001000000010000000100000001, v4_float = .0x0, 0x0, 0x0, 0x0., v4_int32 = .0x1, 0x1, 0x1, 0x1., v8_int16 = .0x1, 0x0, 0x1, 0x0, 0x1, 0x0, 0x1, 0x0., v16_int8 = .0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0.."
103}
104
105for {set i 0} {$i < 32} {incr i 1} {
106 gdb_test "info reg vr$i" "vr$i.*$vector_register" "info reg vr$i"
107}
108
f4711d79
PG
109gdb_test "info reg vrsave" "vrsave.*0x1\t1" "info reg vrsave"
110gdb_test "info reg vscr" "vscr.*0x1\t1" "info reg vscr"
57680a24
EZ
111
112# Now redo the same tests, but using the print command.
113# Note: in LE case, the char array is printed WITHOUT the last character.
114# Gdb treats the terminating null char in the array like the terminating
115# null char in a string and doesn't print it. This is not a failure, but
116# the way gdb works.
117
118if {$endianness == "big"} {
c641edcc 119 set decimal_vector ".uint128 = 0x00000001000000010000000100000001, v4_float = .1.*e-45, 1.*e-45, 1.*e-45, 1.*e-45., v4_int32 = .1, 1, 1, 1., v8_int16 = .0, 1, 0, 1, 0, 1, 0, 1., v16_int8 = .0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1.."
57680a24 120} else {
c641edcc 121 set decimal_vector ".uint128 = 0x00000001000000010000000100000001, v4_float = .1.*e-45, 1.*e-45, 1.*e-45, 1.*e-45., v4_int32 = .1, 1, 1, 1., v8_int16 = .1, 0, 1, 0, 1, 0, 1, 0., v16_int8 = .1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.."
57680a24
EZ
122}
123
124for {set i 0} {$i < 32} {incr i 1} {
125 gdb_test "print \$vr$i" ".* = $decimal_vector" "print vr$i"
126}
127
128gdb_test "print \$vrsave" ".* = 1" "print vrsave"
129gdb_test "print \$vscr" ".* = 1" "print vscr"
130
131for {set i 0} {$i < 32} {incr i 1} {
132 set pattern$i ".*vr$i.*"
133 append pattern$i $vector_register
134}
135
561d7a1d
PG
136send_gdb "info vector\n"
137gdb_expect_list "info vector" ".*$gdb_prompt $" {
57680a24
EZ
138[$pattern0]
139[$pattern1]
140[$pattern2]
141[$pattern3]
142[$pattern4]
143[$pattern5]
144[$pattern6]
145[$pattern7]
146[$pattern8]
147[$pattern9]
148[$pattern10]
149[$pattern11]
150[$pattern12]
151[$pattern13]
152[$pattern14]
153[$pattern15]
154[$pattern16]
155[$pattern17]
156[$pattern18]
157[$pattern19]
158[$pattern20]
159[$pattern21]
160[$pattern22]
161[$pattern23]
162[$pattern24]
163[$pattern25]
164[$pattern26]
165[$pattern27]
166[$pattern28]
167[$pattern29]
168[$pattern30]
169[$pattern31]
170"\[ \t\n\r\]+vscr\[ \t\]+0x1"
171"\[ \t\n\r\]+vrsave\[ \t\]+0x1"
172}
173
174gdb_test "break vector_fun" \
175 "Breakpoint 2 at.*altivec-regs.c, line \[0-9\]+\\." \
176 "Set breakpoint at vector_fun"
177
178# Actually it is nuch easier to see these results printed in hex.
179gdb_test "set output-radix 16" \
180 "Output radix now set to decimal 16, hex 10, octal 20." \
181 "Set output radix to hex"
182
183gdb_test "continue" \
184 "Breakpoint 2, vector_fun .a=.0xfefefefe, 0xfefefefe, 0xfefefefe, 0xfefefefe., b=.0x1010101, 0x1010101, 0x1010101, 0x1010101.*altivec-regs.c.*vec_splat_u8.2..;" \
185 "continue to vector_fun"
186
187# Do a next over the assignment to vector 'a'.
188gdb_test "next" ".*b = \\(\\(vector unsigned int\\) vec_splat_u8\\(3\\)\\);" \
189 "next (1)"
190
191# Do a next over the assignment to vector 'b'.
192gdb_test "next" "c = vec_add \\(a, b\\);" \
193 "next (2)"
194
195# Now 'a' should be '0x02020202...' and 'b' should be '0x03030303...'
196gdb_test "print/x a" \
197 ".*= .0x2020202, 0x2020202, 0x2020202, 0x2020202." \
198 "print vector parameter a"
199
200gdb_test "print/x b" \
201 ".*= .0x3030303, 0x3030303, 0x3030303, 0x3030303." \
202 "print vector parameter b"
203
204# If we do an 'up' now, and print 'x' and 'y' we should see the values they
205# have in main, not the values they have in vector_fun.
206gdb_test "up" ".1.*main \\(\\) at.*altivec-regs.c.*z = vector_fun \\(x, y\\);" \
207 "up to main"
208
209gdb_test "print/x x" \
210 ".*= .0xfefefefe, 0xfefefefe, 0xfefefefe, 0xfefefefe." \
211 "print vector x"
212
213gdb_test "print/x y" \
214 ".*= .0x1010101, 0x1010101, 0x1010101, 0x1010101." \
215 "print vector y"
216
217# now go back to vector_func and do a finish, to see if we can print the return
218# value correctly.
219
220gdb_test "down" \
221 ".0 vector_fun \\(a=.0x2020202, 0x2020202, 0x2020202, 0x2020202., b=.0x3030303, 0x3030303, 0x3030303, 0x3030303.\\) at.*altivec-regs.c.*c = vec_add \\(a, b\\);" \
222 "down to vector_fun"
223
224gdb_test "finish" \
225 "Run till exit from .0 vector_fun \\(a=.0x2020202, 0x2020202, 0x2020202, 0x2020202., b=.0x3030303, 0x3030303, 0x3030303, 0x3030303.\\) at.*altivec-regs.c.*in main \\(\\) at.*altivec-regs.c.*z = vector_fun \\(x, y\\);.*Value returned is.*= .0x5050505, 0x5050505, 0x5050505, 0x5050505." \
226 "finish returned correct value"
227
228
229