public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Carl Love <cel@us.ibm.com>, Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Subject: [PATCH] [gdb/testsuite] Fix gdb.ada/float-bits.exp for powerpc64le
Date: Wed, 30 Nov 2022 15:00:06 +0100	[thread overview]
Message-ID: <20221130140006.25890-1-tdevries@suse.de> (raw)

On powerpc64le-linux, I run into:
...
(gdb) print 16llf#4000921fb54442d18469898cc51701b8#^M
$9 = <invalid float value>^M
(gdb) FAIL: gdb.ada/float-bits.exp: print \
  16llf#4000921fb54442d18469898cc51701b8#
...

The problem is that we're using a hex string for the 128-bit IEEE quad long
double format, but the actual long double float format is:
...
gdbarch_dump: long_double_format = floatformat_ibm_long_double_little^M
...

Fix this by using the hex string obtained by compiling test.c:
...
long double a = 5.0e+25L;
...
like so:
...
$ gcc -mlittle test.c -c -g
...
and running gdb:
...
$ gdb -q -batch test.o -ex "p /x a"
$1 = 0xc1e1c000000000004544adf4b7320335
...
and likewise for -mbig:
...
$ gdb -q -batch test.o -ex "p /x a"
$1 = 0x4544adf4b7320335c1e1c00000000000
...

Tested on powerpc64le-linux.

I excercised the case of floatformat_ibm_long_double_big by
using "set endian big" in the test-case.

Note that for this patch to work correctly, recent commit aaa79cd62b8 ("[gdb]
Improve printing of float formats") is required.

PR testsuite/29816
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29816
---
 gdb/testsuite/gdb.ada/float-bits.exp | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gdb/testsuite/gdb.ada/float-bits.exp b/gdb/testsuite/gdb.ada/float-bits.exp
index 55a0566580c..921fe36a4bd 100644
--- a/gdb/testsuite/gdb.ada/float-bits.exp
+++ b/gdb/testsuite/gdb.ada/float-bits.exp
@@ -73,12 +73,40 @@ set gdb_long_double_size [float_size "16llf#0#" ]
 # example, IEEE quad versus i387 long doubles.  Account for that in the
 # tests below.
 
+# Get the used long double format.
+set long_double_format ""
+gdb_test_multiple "maint print architecture" "" {
+    -re "\r\ngdbarch_dump: long_double_format = (\[^\r\n\]*)" {
+	set long_double_format $expect_out(1,string)
+	exp_continue
+    }
+    -re -wrap "" {
+	pass $gdb_test_name
+    }
+}
+
 # Set default values for 128-bit IEEE quad long doubles.
 set valid_long_double "16llf#4000921fb54442d18469898cc51701b8#"
 set printed_long_double "3.1415926535897932384626433832795028"
 set invalid_long_double ""
 set has_invalid_long_double 0
 
+switch -glob $long_double_format {
+    floatformat_ibm_long_double_* {
+	set w1 c1e1c00000000000
+	set w2 4544adf4b7320335
+	switch $long_double_format {
+	    floatformat_ibm_long_double_big {
+		set valid_long_double "16llf#$w2$w1#"
+	    }
+	    floatformat_ibm_long_double_little {
+		set valid_long_double "16llf#$w1$w2#"
+	    }
+	}
+	set printed_long_double "50000000000000000000000000.0"
+    }
+}
+
 if { [istarget x86_64-*-* ] || [istarget i?86-*-*] } {
     # i387 long double have invalid values
     set has_invalid_long_double 1

base-commit: aaa79cd62b873be672e3163eb267513c97ec4399
-- 
2.35.3


             reply	other threads:[~2022-11-30 14:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 14:00 Tom de Vries [this message]
2022-11-30 14:51 ` Tom Tromey
2022-11-30 16:18 ` Carl Love
2022-12-01 13:49 ` Luis Machado
2022-12-01 14:40   ` Tom de Vries
2022-12-01 20:51     ` Luis Machado
2022-12-01 21:01       ` Luis Machado
2022-12-02  7:59         ` Tom de Vries

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=20221130140006.25890-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=cel@us.ibm.com \
    --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).