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