summaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2003-03-17 20:06:16 +0000
committerAndrew Cagney <cagney@redhat.com>2003-03-17 20:06:16 +0000
commit8b6dc7b9195d3c4706dc5d1f4e8edd9b7effe90b (patch)
tree5aee0c21cde323c953e26411964a5d054c20fede /gdb/testsuite
parent181fdcc87f9f2a398ab60157ddd604e37b57afb4 (diff)
downloadgdb-8b6dc7b9195d3c4706dc5d1f4e8edd9b7effe90b.tar.gz
2003-03-17 Andrew Cagney <cagney@redhat.com>
From Elena Zannoni <ezannoni@redhat.com>. Test e500 abi and vector registes. * gdb.arch/e500-regs.c, gdb.arch/e500-regs.exp: New files. * gdb.arch/e500-abi.c, gdb.arch/e500-abi.exp: New files.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.arch/e500-abi.c106
-rw-r--r--gdb/testsuite/gdb.arch/e500-abi.exp90
-rw-r--r--gdb/testsuite/gdb.arch/e500-abi.exp~94
-rw-r--r--gdb/testsuite/gdb.arch/e500-regs.c38
-rw-r--r--gdb/testsuite/gdb.arch/e500-regs.exp229
-rw-r--r--gdb/testsuite/gdb.arch/e500-regs.exp~229
7 files changed, 793 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 89e2462bf9d..8106815c8ca 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2003-03-17 Andrew Cagney <cagney@redhat.com>
+
+ From Elena Zannoni <ezannoni@redhat.com>. Test e500 abi and
+ vector registes.
+ * gdb.arch/e500-regs.c, gdb.arch/e500-regs.exp: New files.
+ * gdb.arch/e500-abi.c, gdb.arch/e500-abi.exp: New files.
+
2003-03-17 David Carlton <carlton@math.stanford.edu>
* gdb.base/watchpoint.exp (test_watchpoint_and_breakpoint): New
diff --git a/gdb/testsuite/gdb.arch/e500-abi.c b/gdb/testsuite/gdb.arch/e500-abi.c
new file mode 100644
index 00000000000..e2156124b11
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/e500-abi.c
@@ -0,0 +1,106 @@
+#include <spe.h>
+
+/* Test PowerPC SPU extensions. */
+
+#define vector __attribute__((vector_size(8)))
+
+vector unsigned short f_vec;
+vector short g_vec;
+vector float h_vec;
+vector float i_vec;
+vector unsigned int l_vec;
+vector int m_vec;
+vector int n_vec;
+
+/* dummy variables used in the testfile */
+vector unsigned int a_vec_d = {1, 1};
+vector int b_vec_d = {0, 0};
+vector float c_vec_d = {1.0, 1.0};
+vector unsigned int d_vec_d = {0, 0};
+vector int e_vec_d = {1, 1};
+vector unsigned short f_vec_d = {1, 1, 1, 1};
+vector short g_vec_d = {1, 1, 1, 1};
+vector float h_vec_d = {1.0, 1.0};
+vector float i_vec_d = {2.0, 2.0};
+vector unsigned int l_vec_d = {0, 0};
+vector int m_vec_d = {0, 0};
+
+
+vector int
+vec_func (vector unsigned int a_vec_f,
+ vector int b_vec_f,
+ vector float c_vec_f,
+ vector unsigned int d_vec_f,
+ vector int e_vec_f,
+ vector unsigned short f_vec_f,
+ vector short g_vec_f,
+ vector float h_vec_f,
+ vector float i_vec_f,
+ vector unsigned int l_vec_f,
+ vector int m_vec_f)
+{
+ vector int n_vec;
+
+
+ int x,y,z;
+ x = 2;
+ y = 3;
+
+ z = x + y;
+ z++;
+ n_vec = __ev_and(a_vec_f, b_vec_f);
+ n_vec = __ev_or(c_vec_f, d_vec_f);
+ n_vec = __ev_or(e_vec_f, f_vec_f);
+ n_vec = __ev_and(g_vec_f, h_vec_f);
+ n_vec = __ev_and(i_vec_f, l_vec_f);
+ n_vec = __ev_or(m_vec_f, a_vec_f);
+
+ return n_vec;
+}
+
+void marker(void) {};
+
+int
+main (void)
+{
+ vector unsigned int a_vec;
+ vector int b_vec;
+ vector float c_vec;
+ vector unsigned int d_vec;
+ vector int e_vec;
+
+ vector int res_vec;
+
+ a_vec = (vector unsigned int)__ev_create_u64 ((uint64_t) 55);
+ b_vec = __ev_create_s64 ((int64_t) 66);
+ c_vec = (vector float) __ev_create_fs (3.14F, 2.18F);
+ d_vec = (vector unsigned int) __ev_create_u32 ((uint32_t) 5, (uint32_t) 4);
+ e_vec = (vector int) __ev_create_s32 ((int32_t) 5, (int32_t) 6);
+ f_vec = (vector unsigned short) __ev_create_u16 ((uint16_t) 6, (uint16_t) 6, (uint16_t) 7, (uint16_t) 1);
+ g_vec = (vector short) __ev_create_s16 ((int16_t) 6, (int16_t) 6, (int16_t) 7, (int16_t) 9);
+ h_vec = (vector float) __ev_create_sfix32_fs (3.0F, 2.0F);
+ i_vec = (vector float) __ev_create_ufix32_fs (3.0F, 2.0F);
+ l_vec = (vector unsigned int) __ev_create_ufix32_u32 (3U, 5U);
+ m_vec = (vector int) __ev_create_sfix32_s32 (6, 9);
+
+ marker ();
+
+#if 0
+/* This line is useful for cut-n-paste from a gdb session. */
+vec_func(a_vec,b_vec,c_vec,d_vec,e_vec,f_vec,g_vec,h_vec,i_vec,l_vec,m_vec)
+#endif
+
+ res_vec = vec_func (a_vec, /* goes in r3 */
+ b_vec, /* goes in r4 */
+ c_vec, /* goes in r5 */
+ d_vec, /* goes in r6 */
+ e_vec, /* goes in r7 */
+ f_vec, /* goes in r8 */
+ g_vec, /* goes in r9 */
+ h_vec, /* goes in r10 */
+ i_vec, /* goes in stack */
+ l_vec, /* goes in stack */
+ m_vec); /* goes in stack */
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/e500-abi.exp b/gdb/testsuite/gdb.arch/e500-abi.exp
new file mode 100644
index 00000000000..0d11ad3e24c
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/e500-abi.exp
@@ -0,0 +1,90 @@
+# Copyright 2003 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+#
+
+# Tests for Powerpc e500 ABI
+
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+#
+# This file uses e500-abi.c for input.
+#
+
+set prms_id 0
+set bug_id 0
+
+if ![istarget "powerpc-*eabispe"] then {
+ verbose "Skipping e500 abi tests."
+ return
+}
+
+set testfile "e500-abi"
+set binfile ${objdir}/${subdir}/${testfile}
+
+set src1 ${srcdir}/${subdir}/${testfile}.c
+
+if { [gdb_compile ${src1} ${binfile} executable {debug additional_flags=-w}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+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
+}
+
+gdb_test "b marker" "Breakpoint 2 at.*file.*e500-abi.c, line \[0-9\]+." "break marker"
+gdb_test "continue" "Breakpoint 2.*marker.*e500-abi.c.*" "continue to marker"
+gdb_test "finish" "Run till exit from .0.*marker.*at.*e500-abi.c.*main \\(\\) at.*e500-abi.c.*res_vec = vec_func \\(a_vec,.*goes in r3.*" "back to main (1)"
+
+# now all the arguments of vec_func are initialized
+
+set pattern "vec_func .a_vec_f=.0, 55., b_vec_f=.0, 66., c_vec_f=.3.14.*2.18.*, d_vec_f=.5, 4., e_vec_f=.5, 6., f_vec_f=.6, 6, 7, 1., g_vec_f=.6, 6, 7, 9., h_vec_f=.3, 2., i_vec_f=.3, 2., l_vec_f=.3, 5., m_vec_f=.6, 9.."
+
+set pattern1 $pattern
+append pattern1 " at.*e500-abi.c.*x = 2;"
+
+# Now let's call the function. This function has > 8 args,
+# the last ones will go on the stack.
+gdb_test "p vec_func(a_vec,b_vec,c_vec,d_vec,e_vec,f_vec,g_vec,h_vec,i_vec,l_vec,m_vec)" \
+".\[0-9\]+ = .6, 63." "call inferior function with vectors (1) "
+
+# Let's call the function again with dummy arguments. This is to clean
+# up the contents of the ev registers before the next call.
+gdb_test "p vec_func(a_vec_d,b_vec_d,c_vec_d,d_vec_d,e_vec_d,f_vec_d,g_vec_d,h_vec_d,i_vec_d,l_vec_d,m_vec_d)" \
+".\[0-9\]+ = .1, 1." "call inferior function with vectors (2) "
+
+# Let's step into the function, to see if the args are printed correctly.
+gdb_test "step" \
+ $pattern1 \
+ "step into vec_func"
+
+# Let's see if the result is returned correctly.
+gdb_test "finish" \
+ "Run till exit from .0.* at.*e500-abi.c.*main.*res_vec = vec_func .a_vec,.*goes in r3.*Value returned is.*= .6, 63." \
+ "vector value returned correctly"
diff --git a/gdb/testsuite/gdb.arch/e500-abi.exp~ b/gdb/testsuite/gdb.arch/e500-abi.exp~
new file mode 100644
index 00000000000..ed13f2ae07f
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/e500-abi.exp~
@@ -0,0 +1,94 @@
+# Copyright 2003 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+#
+
+# Tests for Powerpc e500 ABI
+
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+#
+# This file uses e500-abi.c for input.
+#
+
+set prms_id 0
+set bug_id 0
+
+if ![istarget "powerpc-*eabispe"] then {
+ verbose "Skipping e500 abi tests."
+ return
+}
+
+set testfile "e500-abi"
+set binfile ${objdir}/${subdir}/${testfile}
+
+set src1 ${srcdir}/${subdir}/${testfile}.c
+
+if { [gdb_compile ${src1} ${binfile} executable {debug additional_flags=-w}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+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
+}
+
+gdb_test "b marker" "Breakpoint 2 at.*file.*e500-abi.c, line \[0-9\]+." "break marker"
+gdb_test "continue" "Breakpoint 2.*marker.*e500-abi.c.*" "continue to marker"
+gdb_test "finish" "Run till exit from .0.*marker.*at.*e500-abi.c.*main \\(\\) at.*e500-abi.c.*res_vec = vec_func \\(a_vec,.*goes in r3.*" "back to main (1)"
+
+# now all the arguments of vec_func are initialized
+
+set pattern "vec_func .a_vec_f=.0, 55., b_vec_f=.0, 66., c_vec_f=.3.14.*2.18.*, d_vec_f=.5, 4., e_vec_f=.5, 6., f_vec_f=.6, 6, 7, 1., g_vec_f=.6, 6, 7, 9., h_vec_f=.3, 2., i_vec_f=.3, 2., l_vec_f=.3, 5., m_vec_f=.6, 9.."
+
+set pattern1 $pattern
+append pattern1 " at.*e500-abi.c.*x = 2;"
+
+# Now let's call the function. This function has > 8 args,
+# the last ones will go on the stack.
+gdb_test "p vec_func(a_vec,b_vec,c_vec,d_vec,e_vec,f_vec,g_vec,h_vec,i_vec,l_vec,m_vec)" \
+".\[0-9\]+ = .6, 63." "call inferior function with vectors (1) "
+
+# Let's call the function again with dummy arguments. This is to clean
+# up the contents of the ev registers before the next call.
+gdb_test "p vec_func(a_vec_d,b_vec_d,c_vec_d,d_vec_d,e_vec_d,f_vec_d,g_vec_d,h_vec_d,i_vec_d,l_vec_d,m_vec_d)" \
+".\[0-9\]+ = .1, 1." "call inferior function with vectors (2) "
+
+# Let's step into the function, to see if the args are printed correctly.
+gdb_test "step" \
+ $pattern1 \
+ "step into vec_func"
+
+set pattern2 $pattern
+append pattern2 " at.*e500-abi.c.*main.*res_vec = vec_func .a_vec,.*goes in r3.*Value returned is.*= .6, 63."
+
+# Let's see if the result is returned correctly.
+gdb_test "finish" \
+ "Run till exit from .0.*$pattern2" \
+ "vector value returned correctly"
+
diff --git a/gdb/testsuite/gdb.arch/e500-regs.c b/gdb/testsuite/gdb.arch/e500-regs.c
new file mode 100644
index 00000000000..bae5f3955b4
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/e500-regs.c
@@ -0,0 +1,38 @@
+#include <spe.h>
+#include <stdio.h>
+
+#define vector __attribute__((vector_size(8)))
+
+
+vector int
+vector_fun (vector int a, vector int b)
+{
+ vector int c;
+ a = (vector int) __ev_create_s32 (2, 2);
+ b = (vector int) __ev_create_s32 (3, 3);
+
+ c = __ev_and (a, b);
+ return c;
+}
+
+int
+main ()
+{
+ vector int y;
+ vector int x;
+ vector int z;
+ int a;
+
+ /* This line may look unnecessary but we do need it, because we want to
+ have a line to do a next over (so that gdb refetches the registers)
+ and we don't want the code to change any vector registers.
+ The splat operations below modify the VRs,
+ so we don't want to execute them yet. */
+ a = 9;
+ x = (vector int) __ev_create_s32 (-2, -2);
+ y = (vector int) __ev_create_s32 (1, 1);
+
+ z = vector_fun (x, y);
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/e500-regs.exp b/gdb/testsuite/gdb.arch/e500-regs.exp
new file mode 100644
index 00000000000..9224704b219
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/e500-regs.exp
@@ -0,0 +1,229 @@
+# Copyright 2003 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+#
+
+# Tests for Powerpc E500 register setting and fetching
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+#
+# Test the use of registers, especially E500 registers, for Powerpc.
+# This file uses e500-regs.c for input.
+#
+
+set prms_id 0
+set bug_id 0
+
+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 additional_flags=-w}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+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" "" ""
+
+send_gdb "show endian\n"
+gdb_expect {
+ -re "(The target endianness is set automatically .currently )(big|little)( endian.*)$gdb_prompt $" {
+ pass "endianness"
+ set endianness $expect_out(2,string)
+ }
+ -re ".*$gdb_prompt $" {
+ fail "couldn't get endianness"
+ }
+ timeout { fail "(timeout) 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.
+# Note: in LE case, the char array is printed WITHOUT the last character.
+# Gdb treats the terminating null char in the array like the terminating
+# null char in a string and doesn't print it. This is not a failure, but
+# the way gdb works.
+
+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 = ..000.000.000.001.000.000.000.001.."
+} else {
+ set decimal_vector ".uint64 = 0x0000000100000001, 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.000.001.000.000.000.001.000.000.."
+}
+
+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"
+
+
+
diff --git a/gdb/testsuite/gdb.arch/e500-regs.exp~ b/gdb/testsuite/gdb.arch/e500-regs.exp~
new file mode 100644
index 00000000000..97cb52cb8b1
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/e500-regs.exp~
@@ -0,0 +1,229 @@
+# Copyright 2003 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+#
+
+# Tests for Powerpc E500 register setting and fetching
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+#
+# Test the use of registers, especially E500 registers, for Powerpc.
+# This file uses e500-regs.c for input.
+#
+
+set prms_id 0
+set bug_id 0
+
+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 additional_flags=-w}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+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" "" ""
+
+send_gdb "show endian\n"
+gdb_expect {
+ -re "(The target endianness is set automatically .currently )(big|little)( endian.*)$gdb_prompt $" {
+ pass "endianness"
+ set endianness $expect_out(2,string)
+ }
+ -re ".*$gdb_prompt $" {
+ fail "couldn't get endianness"
+ }
+ timeout { fail "(timeout) 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.
+# Note: in LE case, the char array is printed WITHOUT the last character.
+# Gdb treats the terminating null char in the array like the terminating
+# null char in a string and doesn't print it. This is not a failure, but
+# the way gdb works.
+
+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.001.0.0.0.001.."
+} else {
+ set decimal_vector ".uint64 = 0x0000000100000001, v2_float = .1.*e-45, 1.*e-45., v2_int32 = .1, 1., v4_int16 = .1, 0, 1, 0., v8_int8 = ..001.0.0.0.001.0.0.0.001.0.0.0.001.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 powerpc vector\n"
+gdb_expect_list "info powerpc 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"
+
+
+