Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/4] gdb: MSVC "long double" is a 64-bit double
Date: Tue, 14 Jul 2026 01:45:07 +0100	[thread overview]
Message-ID: <20260714004507.1323332-5-pedro@palves.net> (raw)
In-Reply-To: <20260714004507.1323332-1-pedro@palves.net>

The GNU (MinGW) and MSVC ABIs disagree on "long double".

- GCC the 80-bit x87 extended type on x86 (stored in 96 bits on i386
  and 128 bits on amd64), and the 128-bit IEEE quad on AArch64.

- MSVC makes "long double" just an alias for "double", an IEEE 64-bit
  double.

GDB modeled only the GNU sizes, via the per-architecture defaults, so
with an MSVC program it got "long double" wrong.  E.g. on AMD64:

 (gdb) set osabi Windows-MSVC
 (gdb) print sizeof (long double)
 $1 = 16

when an MSVC "long double" should be 8 bytes.

Now that we can distinguish the GNU and MSVC flavors, set the smaller
size and IEEE-double format for the MSVC flavor.  This is done in the
shared windows_init_abi, so it covers i386, amd64 and AArch64 all at
once.

After:

 (gdb) set osabi Windows-MSVC
 (gdb) print sizeof (long double)
 $1 = 8

Change-Id: I0acb2e80027cb7b1fcfd1f39dd050a24438e1662
---
 gdb/windows-tdep.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 78bf49b9c81..a1e44f8aa3f 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -17,6 +17,7 @@
 
 #include "windows-tdep.h"
 #include "extract-store-integer.h"
+#include "gdbtypes.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "xml-support.h"
 #include "gdbarch.h"
@@ -1031,6 +1032,14 @@ windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* On Windows, "long"s are only 32bit.  */
   set_gdbarch_long_bit (gdbarch, 32);
 
+  /* With the MSVC ABI, "long double" is just an IEEE 64-bit double,
+     the same as "double".  */
+  if (info.osabi == GDB_OSABI_WINDOWS_MSVC)
+    {
+      set_gdbarch_long_double_bit (gdbarch, 64);
+      set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
+    }
+
   /* Enable TLS support.  */
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
 					     windows_tls_index_address);
-- 
2.54.0


      parent reply	other threads:[~2026-07-14  0:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14  0:45 [PATCH 0/4] Support the Windows/MSVC target in GDB Pedro Alves
2026-07-14  0:45 ` [PATCH 1/4] gdb: recognize *-*-windows* Windows targets Pedro Alves
2026-07-14  0:45 ` [PATCH 2/4] gdb: treat Windows host + Windows target as native Pedro Alves
2026-07-14  0:45 ` [PATCH 3/4] gdb: distinguish GNU and MSVC flavors of the Windows OS ABI Pedro Alves
2026-07-14 11:57   ` Eli Zaretskii
2026-07-14 22:15     ` Pedro Alves
2026-07-15  1:21       ` Simon Marchi
2026-07-15 11:18         ` Pedro Alves
2026-07-15 13:13           ` Simon Marchi
2026-07-15 14:10             ` Pedro Alves
2026-07-15 15:51               ` Simon Marchi
2026-07-15 11:43       ` Eli Zaretskii
2026-07-14  0:45 ` Pedro Alves [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=20260714004507.1323332-5-pedro@palves.net \
    --to=pedro@palves.net \
    --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