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