public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Victor Kamensky <victor.kamensky@linaro.org>
To: gdb-patches@sourceware.org,	Yao Qi <yao@codesourcery.com>
Cc: Andrew Pinski <pinskia@gmail.com>,	victor.kamensky@linaro.org
Subject: [RFC PATCH 1/2] fix implptrpiece.exp test for big endian target
Date: Mon, 27 Oct 2014 03:16:00 -0000	[thread overview]
Message-ID: <1414379778-5478-2-git-send-email-victor.kamensky@linaro.org> (raw)
In-Reply-To: <1414379778-5478-1-git-send-email-victor.kamensky@linaro.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

  reply	other threads:[~2014-10-27  3:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-27  3:16 [RFC PATCH 0/2] couple big endian fixes in testsuites Victor Kamensky
2014-10-27  3:16 ` Victor Kamensky [this message]
2014-10-29  8:15   ` [RFC PATCH 1/2] fix implptrpiece.exp test for big endian target Yao Qi
2014-10-27  3:16 ` [RFC PATCH 2/2] fix py-value-cc.exp " Victor Kamensky
2014-10-29  6:40   ` Yao Qi
2014-10-29  9:13     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1414379778-5478-2-git-send-email-victor.kamensky@linaro.org \
    --to=victor.kamensky@linaro.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pinskia@gmail.com \
    --cc=yao@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).