[gdb/testsuite] Fix gdb.ada/float-bits.exp for powerpc64le
authorTom de Vries <tdevries@suse.de>
Thu, 1 Dec 2022 06:25:04 +0000 (07:25 +0100)
committerTom de Vries <tdevries@suse.de>
Thu, 1 Dec 2022 06:25:04 +0000 (07:25 +0100)
commit32a5aa2625686a709b22db19300a578d96285dd1
tree5096649a85d843746a10da85311c7ece8b54e834
parent8a1c55cdfb2d17208cacfc6c34af4693d6956693
[gdb/testsuite] Fix gdb.ada/float-bits.exp for powerpc64le

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
Approved-By: Tom Tromey <tom@tromey.com>
gdb/testsuite/gdb.ada/float-bits.exp