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 2/4] gdb: treat Windows host + Windows target as native
Date: Tue, 14 Jul 2026 01:45:05 +0100	[thread overview]
Message-ID: <20260714004507.1323332-3-pedro@palves.net> (raw)
In-Reply-To: <20260714004507.1323332-1-pedro@palves.net>

Configuring GDB with:

  --host=x86_64-w64-mingw32
  --target=x86_64-pc-windows-msvc

currently results in a cross- or remote-only debugger, with the
Windows native-debug support (windows-nat.o and friends) left out.

This is because gdb/configure currently decides whether GDB is a
native debugger by comparing the host and target triplets for exact
equality:

  if test "${target}" = "${host}"; then
    gdb_native=yes
  else
    gdb_native=no
  fi

That is too strict on Windows.  A GDB built on mingw (host
x86_64-w64-mingw32) that targets binaries produced by a compiler
defaulting to the MSVC ABI (target x86_64-pc-windows-msvc) debugs
processes running on the same machine, so it is native, even though
the two triplets differ in vendor and OS.  With the strict check such
a configuration ends up with gdb_native=no, and configure.nat is not
sourced, and the Windows native-debug support is left out.

Fix this by relaxing the check -- in addition to the exact-match case,
treat the configuration as native when the host and target CPUs match
and both host and target are Windows systems.  Requiring the CPUs to
match makes it so that cross-CPU configurations such as an aarch64
host with an x86_64 target continue to be non-native.

Change-Id: I7f92436b7978b65aec6ba404bc8f7bbb954326f7
---
 gdb/configure    | 19 +++++++++++++++++--
 gdb/configure.ac | 19 +++++++++++++++++--
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/gdb/configure b/gdb/configure
index 3733ef76948..45145a00b63 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -25218,10 +25218,25 @@ CPPFLAGS=$OLD_CPPFLAGS
 # configuration.
 gdb_host_obs=posix-hdep.o
 
+# Check whether the configuration is native -- i.e., whether GDB will
+# debug processes running on the same machine it runs on.  If so, we
+# let configure.host and configure.nat pull in the native-debug
+# support.
+gdb_native=no
 if test "${target}" = "${host}"; then
   gdb_native=yes
-else
-  gdb_native=no
+elif test "${host_cpu}" = "${target_cpu}"; then
+  # Debugging Windows binaries on a Windows host is native even when
+  # the host and target triplets differ across the mingw/cygwin/msvc
+  # ABI boundary.  E.g., a mingw32-hosted GDB targeting binaries
+  # produced by a compiler defaulting to windows-msvc.
+  case ${host_os} in
+    mingw* | cygwin*)
+      case ${target_os} in
+	mingw* | cygwin* | windows*)
+	  gdb_native=yes ;;
+      esac ;;
+  esac
 fi
 
 . $srcdir/configure.host
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 5296d76f2cf..5d71e2bf1a4 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -222,10 +222,25 @@ BFD_64_BIT
 # configuration.
 gdb_host_obs=posix-hdep.o
 
+# Check whether the configuration is native -- i.e., whether GDB will
+# debug processes running on the same machine it runs on.  If so, we
+# let configure.host and configure.nat pull in the native-debug
+# support.
+gdb_native=no
 if test "${target}" = "${host}"; then
   gdb_native=yes
-else
-  gdb_native=no
+elif test "${host_cpu}" = "${target_cpu}"; then
+  # Debugging Windows binaries on a Windows host is native even when
+  # the host and target triplets differ across the mingw/cygwin/msvc
+  # ABI boundary.  E.g., a mingw32-hosted GDB targeting binaries
+  # produced by a compiler defaulting to windows-msvc.
+  case ${host_os} in
+    mingw* | cygwin*)
+      case ${target_os} in
+	mingw* | cygwin* | windows*)
+	  gdb_native=yes ;;
+      esac ;;
+  esac
 fi
 
 . $srcdir/configure.host
-- 
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 ` Pedro Alves [this message]
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 ` [PATCH 4/4] gdb: MSVC "long double" is a 64-bit double Pedro Alves

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-3-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