public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed] [gdb/testsuite] Fix gdb.python/py-value-cc.exp for big endian
Date: Thu, 19 Jan 2023 13:44:49 +0100	[thread overview]
Message-ID: <20230119124449.18628-1-tdevries@suse.de> (raw)

On s390x-linux, I run into:
...
(gdb) python print(u[u_fields[0]])^M
99^M
(gdb) PASS: gdb.python/py-value-cc.exp: u's first field via field
python print(u[u_fields[1]])^M
0 '\000'^M
(gdb) FAIL: gdb.python/py-value-cc.exp: u's second field via field
...

There's a var u of this type:
...
union U {
  int a;
  char c;
};
...
and after assigning 99 to u.a, the test-case expects u.c to contain 99 (which
it does on x86_64), but instead it contains 0.

Fix this by instead assigning 0x63636363, to ensure that u.c == 99 for both
little and big endian.

Tested on x86_64-linux and s390x-linux.
---
 gdb/testsuite/gdb.python/py-value-cc.cc  | 2 +-
 gdb/testsuite/gdb.python/py-value-cc.exp | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.python/py-value-cc.cc b/gdb/testsuite/gdb.python/py-value-cc.cc
index 817b089c35f..d82e385d6c5 100644
--- a/gdb/testsuite/gdb.python/py-value-cc.cc
+++ b/gdb/testsuite/gdb.python/py-value-cc.cc
@@ -77,7 +77,7 @@ func (const A &a)
   Btd &b_td = b1;
 
   U u;
-  u.a = 99;
+  u.a = 0x63636363;
 
   X x;
   x.x = 101;
diff --git a/gdb/testsuite/gdb.python/py-value-cc.exp b/gdb/testsuite/gdb.python/py-value-cc.exp
index 1ea10ad0058..b6571cd8297 100644
--- a/gdb/testsuite/gdb.python/py-value-cc.exp
+++ b/gdb/testsuite/gdb.python/py-value-cc.exp
@@ -80,7 +80,8 @@ gdb_test "python print(b_td\[b_fields\[0\]\].type.target())" "A" \
 gdb_test "python print(b_td\[b_fields\[0\]\]\['a'\])" "100" \
   "b_td.A::a via field"
 
-gdb_test "python print(u\[u_fields\[0\]\])" "99.*" "u's first field via field"
+gdb_test "python print(hex(u\[u_fields\[0\]\]))" "0x63636363.*" \
+    "u's first field via field"
 gdb_test "python print(u\[u_fields\[1\]\])" "99.*" "u's second field via field"
 
 gdb_test "python print(len(x_fields))" "2" "number for fields in u"

base-commit: 75c2efc6f19fe454413aa70d2c37e543f04a67e1
-- 
2.35.3


                 reply	other threads:[~2023-01-19 12:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230119124449.18628-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /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).