From: "Willgerodt, Felix" <felix.willgerodt@intel.com>
To: Tom Tromey <tom@tromey.com>,
"Willgerodt, Felix via Gdb-patches" <gdb-patches@sourceware.org>
Subject: RE: [PATCH 1/1] gdb, fortran: Fix quad floating-point type for ifort compiler.
Date: Tue, 28 Feb 2023 10:21:21 +0000 [thread overview]
Message-ID: <MN2PR11MB4566AD4785AE6BBEAC37C1A28EAC9@MN2PR11MB4566.namprd11.prod.outlook.com> (raw)
In-Reply-To: <87wn47i26i.fsf@tromey.com>
> -----Original Message-----
> From: Tom Tromey <tom@tromey.com>
> Sent: Freitag, 24. Februar 2023 15:11
> To: Willgerodt, Felix via Gdb-patches <gdb-patches@sourceware.org>
> Cc: Tom Tromey <tom@tromey.com>; Willgerodt, Felix
> <felix.willgerodt@intel.com>
> Subject: Re: [PATCH 1/1] gdb, fortran: Fix quad floating-point type for ifort
> compiler.
>
> > When examining memory for this Fortran test, I see 128-bit values in
> > binary128 format, so I assume that this is just a software/compiler feature.
> > There is also decimal128 support in e.g. gcc. I tried it only briefly,
> > we don't end up in i386_floatformat_for_type for those types, but
> > GDB prints them just fine. I assume as they are marked as
> > DW_ATE_decimal_float instead of DW_ATE_float, but I didn't look into
> > it in detail.
>
> > I am not aware of any other float types that exist with this length.
>
> I wonder, then, if this patch would work?
> This way we would not have to curate a list of names.
>
> Tom
>
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index 476d17f1efd..57e50ffdd73 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -8277,20 +8277,8 @@ static const struct floatformat **
> i386_floatformat_for_type (struct gdbarch *gdbarch,
> const char *name, int len)
> {
> - if (len == 128 && name)
> - if (strcmp (name, "__float128") == 0
> - || strcmp (name, "_Float128") == 0
> - || strcmp (name, "complex _Float128") == 0
> - || strcmp (name, "complex(kind=16)") == 0
> - || strcmp (name, "COMPLEX(16)") == 0
> - || strcmp (name, "complex*32") == 0
> - || strcmp (name, "COMPLEX*32") == 0
> - || strcmp (name, "quad complex") == 0
> - || strcmp (name, "real(kind=16)") == 0
> - || strcmp (name, "real*16") == 0
> - || strcmp (name, "REAL*16") == 0
> - || strcmp (name, "REAL(16)") == 0)
> - return floatformats_ieee_quad;
> + if (len == 128)
> + return floatformats_ieee_quad;
>
> return default_floatformat_for_type (gdbarch, name, len);
> }
I tested this quickly and see some regressions in gdb.base/complex-.parts.exp,
gdb.base/bfp-test.exp and gdb.base/structs.exp (and a handful of others) on x86,
with multiple compilers. Also gcc on Fedora 37 and Ubuntu 22.04.
I didn't have the time to dig too deep. It seems like we return ieee_quad for
some cases where we shouldn’t.
(gdb) bt 5
#0 i386_floatformat_for_type (gdbarch=0x55555848f520, name=0x555558b5c760 "long double",
len=128) at sources/gdb/gdb/i386-tdep.c:8281
#1 0x0000555555cd9e7e in gdbarch_floatformat_for_type (gdbarch=0x55555848f520,
name=0x555558b5c760 "long double", length=128)
at sources/gdb/gdb/gdbarch.c:1679
#2 0x0000555555f6fc9f in dwarf2_init_float_type (objfile=0x7fffe8021d00, bits=128,
name=0x555558b5c760 "long double", name_hint=0x555558b5c760 "long double",
byte_order=BFD_ENDIAN_LITTLE) at sources/gdb/gdb/dwarf2/read.c:15031
#3 0x0000555555f70543 in read_base_type (die=0x555558908f10, cu=0x7fffd8006970)
at sources/gdb/gdb/dwarf2/read.c:15270
#4 0x0000555555f7b2be in read_type_die_1 (die=0x555558908f10, cu=0x7fffd8006970)
at sources/gdb/gdb/dwarf2/read.c:19631
This seems to pass 128 bits for long double, where your patch did expect 80 bits.
The 80 bit length for x86 is only handled in arch-utils.c:default_floatformat_for_type.
I wonder if that could be streamlined a bit, not having to call gdbarch functions twice
to figure out the format.
I don't know why GDB passes 128 bit from the dwarf reader. I was debugging
complex-parts only. In dwarf, we see the type having 256 bits. So maybe GDB splits
it to 128 bit, as it is a complex?
Felix
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
prev parent reply other threads:[~2023-02-28 10:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-14 11:00 Felix Willgerodt
2023-02-14 15:14 ` Tom Tromey
2023-02-15 9:05 ` Willgerodt, Felix
2023-02-15 16:52 ` Tom Tromey
2023-02-20 9:17 ` Willgerodt, Felix
2023-02-24 14:11 ` Tom Tromey
2023-02-28 10:21 ` Willgerodt, Felix [this message]
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=MN2PR11MB4566AD4785AE6BBEAC37C1A28EAC9@MN2PR11MB4566.namprd11.prod.outlook.com \
--to=felix.willgerodt@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.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).