This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Big-endian targets: Fix implptrpiece.exp


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=075beec08ae857d918890c30d290863abb3f7f57

commit 075beec08ae857d918890c30d290863abb3f7f57
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
Date:   Tue Feb 14 18:17:19 2017 +0100

    Big-endian targets: Fix implptrpiece.exp
    
    The test case implptrpiece.exp accesses the second byte of the short
    integer number 1 and expects it to be zero.  This is valid for
    little-endian targets, but fails on big-endian targets.
    
    This is fixed by distinguishing the expected value by endianness.
    
    gdb/testsuite/ChangeLog:
    
    	* gdb.dwarf2/implptrpiece.exp: Fix check for big-endian targets.

Diff:
---
 gdb/testsuite/ChangeLog                   |  4 ++++
 gdb/testsuite/gdb.dwarf2/implptrpiece.exp | 17 +++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index bd81ad2..a54eb67 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2017-02-14  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
+	* gdb.dwarf2/implptrpiece.exp: Fix check for big-endian targets.
+
 2017-02-13  Luis Machado  <lgustavo@codesourcery.com>
 
 	* gdb.linespec/explicit.c (my_unique_function_name): New function.
diff --git a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
index af7dd37..ef483c0 100644
--- a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
@@ -80,7 +80,7 @@ Dwarf::assemble $asm_file {
 		{name s}
 		{type :$struct_label}
 		{location {
-		    const1u 1
+		    const2u 0x5678
 		    stack_value
 		    piece 2
 		    const1u 2
@@ -119,4 +119,17 @@ if ![runto_main] {
     return -1
 }
 
-gdb_test "print/d p\[-1\]" " = 0"
+# Determine endianness.
+set endian "little"
+gdb_test_multiple "show endian" "determine endianness" {
+    -re ".* (big|little) endian.*$gdb_prompt $" {
+	set endian $expect_out(1,string)
+	pass "endianness: $endian"
+    }
+}
+
+# Access the second byte of s through an implicit pointer to the third
+# byte of s, using a negative offset.  Compare that to the second byte of
+# the short integer 0x5678 in target byte order.
+switch $endian { little {set val 0x56} big {set val 0x78} }
+gdb_test "p/x p\[-1\]" " = $val"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]