OSDN Git Service

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