* [PATCH] testsuite: endianness in gnu_vector.exp
@ 2013-10-07 14:31 Jose E. Marchesi
2013-10-07 18:53 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Jose E. Marchesi @ 2013-10-07 14:31 UTC (permalink / raw)
To: gdb-patches
Hi.
Small patch making gnu_vector.exp to work properly in big-endian
machines.
Tested in sparc64-*-linux-gnu.
2013-10-07 Jose E. Marchesi <jose.marchesi@oracle.com>
* gdb.base/gnu_vector.exp: Care about endianness when casting
scalars to vectors.
Index: testsuite/gdb.base/gnu_vector.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/gnu_vector.exp,v
retrieving revision 1.13
diff -u -r1.13 gnu_vector.exp
--- testsuite/gdb.base/gnu_vector.exp 27 Jun 2013 18:50:30 -0000 1.13
+++ testsuite/gdb.base/gnu_vector.exp 7 Oct 2013 14:25:35 -0000
@@ -40,6 +40,14 @@
return -1
}
+# Get endianess for the scalar->vector casts
+gdb_test_multiple "show endian" "show endian" {
+ -re ".* (big|little) endian.*$gdb_prompt $" {
+ set endian $expect_out(1,string)
+ pass "endianness: $endian"
+ }
+}
+
# Test printing of character vector types
gdb_test "print c4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
gdb_test "print c4\[2\]" "\\\$$decimal = 3"
@@ -83,9 +91,14 @@
# When casting to vector the input type must have the same length as
# the total length of the vector.
gdb_test "print (char4) 0x01010101" "\\\$$decimal = \\{1, 1, 1, 1\\}"
-gdb_test "print (char4) ia" "\\\$$decimal = \\{2, 0, 0, 0\\}"
gdb_test "print (int2) lla" "\\\$$decimal = \\{1, 1\\}"
+if { ![string compare $endian big] } then {
+ gdb_test "print (char4) ia" "\\\$$decimal = \\{0, 0, 0, 2\\}"
+} else {
+ gdb_test "print (char4) ia" "\\\$$decimal = \\{2, 0, 0, 0\\}"
+}
+
gdb_test "print (int2) 1" "can only cast scalar to vector of same size"
gdb_test "print (longlong2) 2" "can only cast scalar to vector of same size"
gdb_test "print (float2) 3" "can only cast scalar to vector of same size"
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] testsuite: endianness in gnu_vector.exp
2013-10-07 14:31 [PATCH] testsuite: endianness in gnu_vector.exp Jose E. Marchesi
@ 2013-10-07 18:53 ` Tom Tromey
2013-10-07 19:34 ` Jose E. Marchesi
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2013-10-07 18:53 UTC (permalink / raw)
To: Jose E. Marchesi; +Cc: gdb-patches
>>>>> "Jose" == Jose E Marchesi <jose.marchesi@oracle.com> writes:
Jose> Small patch making gnu_vector.exp to work properly in big-endian
Jose> machines.
The patch looks reasonable enough, but is this how casting to vector
types works? That is, is the gdb result here consistent with what gcc
does? This isn't clear from the existing test.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] testsuite: endianness in gnu_vector.exp
2013-10-07 18:53 ` Tom Tromey
@ 2013-10-07 19:34 ` Jose E. Marchesi
2013-10-07 19:36 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Jose E. Marchesi @ 2013-10-07 19:34 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
Jose> Small patch making gnu_vector.exp to work properly in big-endian
Jose> machines.
The patch looks reasonable enough, but is this how casting to vector
types works? That is, is the gdb result here consistent with what gcc
does? This isn't clear from the existing test.
Well, this is all I can find on the gcc manual on casting vectors:
"It is possible to cast from one vector type to another, provided they
are of the same size (in fact, you can also cast vectors to and from
other datatypes of the same size)."
No explicit mention to the endianness issue. But then the behavior of
gcc indicates that it stores the elements of the vectors in memory
ordering: the following program generates different results in x86_64 (2
0) and SPARC/BE (0 2).
typedef int __attribute__((vector_size(8))) vector_t;
void
main()
{
long i = 2;
vector_t v = (vector_t) i;
printf ("%d %d\n", v[0], v[1]);
}
So it looks like the test is now consistent with what gcc does...
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-21 12:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-07 14:31 [PATCH] testsuite: endianness in gnu_vector.exp Jose E. Marchesi
2013-10-07 18:53 ` Tom Tromey
2013-10-07 19:34 ` Jose E. Marchesi
2013-10-07 19:36 ` Tom Tromey
2013-10-21 12:36 ` Jose E. Marchesi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox