1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
# Copyright 2003-2017 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Tests for Powerpc E500 register setting and fetching
#
# Test the use of registers, especially E500 registers, for Powerpc.
# This file uses e500-regs.c for input.
#
if ![istarget "powerpc-*eabispe"] then {
verbose "Skipping e500 register tests."
return
}
set testfile "e500-regs"
set binfile ${objdir}/${subdir}/${testfile}
set src1 ${srcdir}/${subdir}/${testfile}.c
if { [gdb_compile ${src1} ${binfile} executable {debug nowarnings}] != "" } {
untested "failed to compile"
return -1
}
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
#
# Run to `main' where we begin our tests.
#
if ![runto_main] then {
gdb_suppress_tests
}
# set all the registers integer portions to 1
for {set i 0} {$i < 32} {incr i 1} {
for {set j 0} {$j < 2} {incr j 1} {
gdb_test "set \$ev$i.v2_int32\[$j\] = 1" "" "set reg ev$i.v4si.f\[$j\]"
}
}
# Now execute some target code, so that GDB's register cache is flushed.
#gdb_test "next" "" ""
set endianness [get_endianness]
# And then read the E500 registers back, to see that
# a) the register write above worked, and
# b) the register read (below) also works.
if {$endianness == "big"} {
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.."
} else {
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.."
}
for {set i 0} {$i < 32} {incr i 1} {
gdb_test "info reg ev$i" "ev$i.*$vector_register" "info reg ev$i"
}
# Test wether the GPRs are updated accordingly. (GPRs are just the lower
# 32 bits of the EV registers.)
set general_register "0x1\[ \t\]+1"
for {set i 0} {$i < 32} {incr i 1} {
gdb_test "info reg r$i" "r$i.*$general_register" "info reg r$i"
}
# Now redo the same tests, but using the print command.
if {$endianness == "big"} {
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.."
} else {
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.."
}
for {set i 0} {$i < 32} {incr i 1} {
gdb_test "print \$ev$i" ".* = $decimal_vector" "print ev$i"
}
for {set i 0} {$i < 32} {incr i 1} {
set pattern$i ".*ev$i.*"
append pattern$i $vector_register
}
send_gdb "info vector\n"
gdb_expect_list "info vector" ".*$gdb_prompt $" {
[$pattern0]
[$pattern1]
[$pattern2]
[$pattern3]
[$pattern4]
[$pattern5]
[$pattern6]
[$pattern7]
[$pattern8]
[$pattern9]
[$pattern10]
[$pattern11]
[$pattern12]
[$pattern13]
[$pattern14]
[$pattern15]
[$pattern16]
[$pattern17]
[$pattern18]
[$pattern19]
[$pattern20]
[$pattern21]
[$pattern22]
[$pattern23]
[$pattern24]
[$pattern25]
[$pattern26]
[$pattern27]
[$pattern28]
[$pattern29]
[$pattern30]
[$pattern31]
}
# We must restart everything, because we have set important registers to
# some unusual values.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
if ![runto_main] then {
gdb_suppress_tests
}
gdb_test "break vector_fun" \
"Breakpoint 2 at.*e500-regs.c, line \[0-9\]+\\." \
"set breakpoint at vector_fun"
# Actually it is nuch easier to see these results printed in hex.
# gdb_test "set output-radix 16" \
# "Output radix now set to decimal 16, hex 10, octal 20." \
# "set output radix to hex"
gdb_test "continue" \
"Breakpoint 2, vector_fun .a=.-2, -2., b=.1, 1.*e500-regs.c.*ev_create_s32 .2, 2.;" \
"continue to vector_fun"
# Do a next over the assignment to vector 'a'.
gdb_test "next" ".*b = \\(vector int\\) __ev_create_s32 \\(3, 3\\);" \
"next (1)"
# Do a next over the assignment to vector 'b'.
gdb_test "next" "c = __ev_and \\(a, b\\);" \
"next (2)"
# Now 'a' should be '0x02020202...' and 'b' should be '0x03030303...'
gdb_test "print/x a" \
".*= .0x2, 0x2." \
"print vector parameter a"
gdb_test "print/x b" \
".*= .0x3, 0x3." \
"print vector parameter b"
# If we do an 'up' now, and print 'x' and 'y' we should see the values they
# have in main, not the values they have in vector_fun.
gdb_test "up" ".1.*main \\(\\) at.*e500-regs.c.*z = vector_fun \\(x, y\\);" \
"up to main"
gdb_test "print x" \
".*= .-2, -2." \
"print vector x"
gdb_test "print y" \
".*= .1, 1." \
"print vector y"
# now go back to vector_func and do a finish, to see if we can print the return
# value correctly.
gdb_test "down" \
".0 vector_fun \\(a=.2, 2., b=.3, 3.\\) at.*e500-regs.c.*c = __ev_and \\(a, b\\);" \
"down to vector_fun"
gdb_test "finish" \
"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." \
"finish returned correct value"
|