This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC PATCH 1/2] fix implptrpiece.exp test for big endian target
- From: Victor Kamensky <victor dot kamensky at linaro dot org>
- To: gdb-patches at sourceware dot org, Yao Qi <yao at codesourcery dot com>
- Cc: Andrew Pinski <pinskia at gmail dot com>, victor dot kamensky at linaro dot org
- Date: Sun, 26 Oct 2014 20:16:17 -0700
- Subject: [RFC PATCH 1/2] fix implptrpiece.exp test for big endian target
- Authentication-results: sourceware.org; auth=none
- References: <1414379778-5478-1-git-send-email-victor dot kamensky at linaro dot org>
Currently on any big endian target implptrpiece.exp test fails
like this:
FAIL: gdb.dwarf2/implptrpiece.exp: print/d p[-1]
(gdb) print/d p[-1]
$1 = 1
(gdb) FAIL: gdb.dwarf2/implptrpiece.exp: print/d p[-1]
Test expects that value of p[-1] should be 0.
This test creates special DWARF construct with DW_OP_GNU_implicit_pointer:
<1><25c>: Abbrev Number: 10 (DW_TAG_variable)
<25d> DW_AT_name : s
<25f> DW_AT_type : <0x21d>
<263> DW_AT_location : 15 byte block: 8 1 9f 93 2 8 2 9f 93 1 8 3 9f 93 1 (DW_OP_const1u: 1; DW_OP_stack_value; DW_OP_piece: 2; DW_OP_const1u: 2; DW_OP_stack_value
; DW_OP_piece: 1; DW_OP_const1u: 3; DW_OP_stack_value; DW_OP_piece: 1)
<1><273>: Abbrev Number: 11 (DW_TAG_variable)
<274> DW_AT_name : p
<276> DW_AT_type : <0x256>
<27a> DW_AT_location : 6 byte block: f2 0 0 2 5c 2 (DW_OP_GNU_implicit_pointer: <0x25c> 2)
In description of 's' variable note byte constant value of 1, that
will be used as first piece of size 2 bytes, followed by 1 byte
piece with 2, and 1 byte piece with 3. Variable 'p' is implicit
pointer with offset 2 within 's', i.e it points right in the middle
of s. Test looks at p[-1] and expects to get most significant
byte of short type of value 1, which is 0. But in big
endian case such index points to least significant byte which
is 1. So test fails.
Fix the test by checking endianity of the target and selecting
proper index to get most significant byte of first piece.
gdb/testsuite/ChangeLog:
2014-10-24 Victor Kamensky <victor.kamensky@linaro.org>
* gdb.dwarf2/implptrpiece.exp: Fix handling of big
endian target.
---
gdb/testsuite/gdb.dwarf2/implptrpiece.exp | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
index 60a3d9f..5dcc6ea 100644
--- a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
@@ -119,4 +119,15 @@ if ![runto_main] {
return -1
}
-gdb_test "print/d p\[-1\]" " = 0"
+gdb_test_multiple "show endian" "getting target endian" {
+ -re ".*little endian.*$gdb_prompt $" {
+ set check_index "-1"
+ # pass silently
+ }
+ -re ".*big endian.*$gdb_prompt $" {
+ set check_index "-2"
+ # pass silently
+ }
+}
+
+gdb_test "print/d p\[$check_index\]" " = 0"
--
1.8.1.4