From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH 02/27] gdb/testsuite: Use unprefixed runtest for a native Windows/MSVC build
Date: Thu, 23 Jul 2026 14:00:53 +0100 [thread overview]
Message-ID: <20260723130118.206735-3-pedro@palves.net> (raw)
In-Reply-To: <20260723130118.206735-1-pedro@palves.net>
This is the first of two pieces making plain "make check" Just Work
when testing a MinGW-hosted GDB targeting the MSVC ABI:
--host=x86_64-w64-mingw32 --target=x86_64-pc-windows-msvc
When running the testsuite for a configuration where the host and
target triplets differ, the testsuite Makefile runs a target-prefixed
runtest -- e.g. x86_64-pc-windows-msvc-runtest, which fails with:
/bin/sh: line 1: x86_64-pc-windows-msvc-runtest: command not found
For a MinGW-hosted GDB targeting the MSVC ABI, the two triplets
differ, but it's still a native configuration and the plain "runtest"
should be used.
This is the same native-vs-cross distinction that gdb/configure.ac
already makes for gdb_native, so fix this by factoring that logic into
a new GDB_AC_NATIVE m4 macro and use it in both places.
gdb/gdb-native.m4 is now included by both gdb/configure.ac (via
acinclude.m4) and gdb/testsuite/configure.ac (via aclocal.m4), the
same way transform.m4 is shared.
Change-Id: Ia2d8cc0c685d8dd0a070f570798817e620857ab1
---
gdb/acinclude.m4 | 3 +++
gdb/configure | 40 +++++++++++++++++++-------------------
gdb/configure.ac | 23 +++-------------------
gdb/gdb-native.m4 | 30 ++++++++++++++++++++++++++++
gdb/testsuite/Makefile.in | 3 ++-
gdb/testsuite/aclocal.m4 | 1 +
gdb/testsuite/configure | 19 ++++++++++++++++++
gdb/testsuite/configure.ac | 5 +++++
8 files changed, 83 insertions(+), 41 deletions(-)
create mode 100644 gdb/gdb-native.m4
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 64cbab0b93a..c74e2d3dcba 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -15,6 +15,9 @@ m4_include(acx_configure_dir.m4)
# This gets GDB_AC_TRANSFORM.
m4_include(transform.m4)
+# This gets GDB_AC_NATIVE.
+m4_include(gdb-native.m4)
+
# This get AM_GDB_COMPILER_TYPE.
m4_include(../gdbsupport/compiler-type.m4)
diff --git a/gdb/configure b/gdb/configure
index 93b2df6f99b..f0f90b6be08 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -25218,26 +25218,26 @@ 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
-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
+# Check whether the configuration is native. 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
+ 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 50d04ff9027..30972e9a442 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -222,26 +222,9 @@ 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
-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
+# Check whether the configuration is native. If so, we let
+# configure.host and configure.nat pull in the native-debug support.
+GDB_AC_NATIVE([gdb_native])
. $srcdir/configure.host
diff --git a/gdb/gdb-native.m4 b/gdb/gdb-native.m4
new file mode 100644
index 00000000000..0849c04d14b
--- /dev/null
+++ b/gdb/gdb-native.m4
@@ -0,0 +1,30 @@
+# Copyright (C) 2026 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# GDB_AC_NATIVE([VAR])
+#
+# Determine whether this is a native configuration -- i.e., whether
+# GDB will debug processes running on the same machine it runs on.
+# Store "yes" or "no" in the output variable.
+
+AC_DEFUN([GDB_AC_NATIVE], [
+ $1=no
+ if test "${target}" = "${host}"; then
+ $1=yes
+ 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*)
+ $1=yes ;;
+ esac ;;
+ esac
+ fi
+])
diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in
index f103d7ddd65..b852dbceb50 100644
--- a/gdb/testsuite/Makefile.in
+++ b/gdb/testsuite/Makefile.in
@@ -28,6 +28,7 @@ program_transform_name = @program_transform_name@
build_canonical = @build@
host_canonical = @host@
target_canonical = @target@
+gdb_native = @gdb_native@
enable_libctf = @enable_libctf@
SHELL = @SHELL@
@@ -66,7 +67,7 @@ RUNTEST_FOR_TARGET = `\
if [ -f $${srcdir}/../../dejagnu/runtest ]; then \
echo $${srcdir}/../../dejagnu/runtest; \
else \
- if [ "$(host_canonical)" = "$(target_canonical)" ]; then \
+ if [ "$(gdb_native)" = yes ]; then \
echo runtest; \
else \
t='$(program_transform_name)'; echo runtest | sed -e $$t; \
diff --git a/gdb/testsuite/aclocal.m4 b/gdb/testsuite/aclocal.m4
index c5d3ba527a7..0fe30d7fc5c 100644
--- a/gdb/testsuite/aclocal.m4
+++ b/gdb/testsuite/aclocal.m4
@@ -2,6 +2,7 @@ m4_include(../../config/acx.m4)
m4_include(../../config/override.m4)
m4_include(../../config/enable.m4)
m4_include(../transform.m4)
+m4_include(../gdb-native.m4)
# AM_CONDITIONAL -*- Autoconf -*-
diff --git a/gdb/testsuite/configure b/gdb/testsuite/configure
index 6ea9686516d..f2818fd0a0c 100755
--- a/gdb/testsuite/configure
+++ b/gdb/testsuite/configure
@@ -626,6 +626,7 @@ NM_TRANSFORM_NAME
GAS_TRANSFORM_NAME
READELF_TRANSFORM_NAME
STRIP_TRANSFORM_NAME
+gdb_native
EXTRA_RULES
EGREP
GREP
@@ -3449,6 +3450,24 @@ if test "${build}" = "${host}" -a "${host}" = "${target}"; then
fi
+# Whether this is a native configuration. When it is, the testsuite
+# runs the unprefixed "runtest" rather than a target-prefixed one.
+
+ gdb_native=no
+ if test "${target}" = "${host}"; then
+ gdb_native=yes
+ elif test "${host_cpu}" = "${target_cpu}"; then
+ case ${host_os} in
+ mingw* | cygwin*)
+ case ${target_os} in
+ mingw* | cygwin* | windows*)
+ gdb_native=yes ;;
+ esac ;;
+ esac
+ fi
+
+
+
# Transform the name of some programs and generate the lib/pdtrace
# test tool.
test "$program_prefix" != NONE &&
diff --git a/gdb/testsuite/configure.ac b/gdb/testsuite/configure.ac
index 6eae19656df..8e64b216f95 100644
--- a/gdb/testsuite/configure.ac
+++ b/gdb/testsuite/configure.ac
@@ -86,6 +86,11 @@ if test "${build}" = "${host}" -a "${host}" = "${target}"; then
fi
AC_SUBST(EXTRA_RULES)
+# Whether this is a native configuration. When it is, the testsuite
+# runs the unprefixed "runtest" rather than a target-prefixed one.
+GDB_AC_NATIVE([gdb_native])
+AC_SUBST(gdb_native)
+
# Transform the name of some programs and generate the lib/pdtrace
# test tool.
AC_ARG_PROGRAM
--
2.54.0
next prev parent reply other threads:[~2026-07-23 13:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 13:00 [PATCH 00/27] Teach the testsuite about the Windows/MSVC target Pedro Alves
2026-07-23 13:00 ` [PATCH 01/27] gdb/testsuite: Don't link with -lm on windows-msvc Pedro Alves
2026-07-23 13:00 ` Pedro Alves [this message]
2026-07-23 13:00 ` [PATCH 03/27] gdb/testsuite: Find host binutils in a native Windows/MSVC config Pedro Alves
2026-07-23 13:00 ` [PATCH 04/27] gdb/testsuite: Compile with -Wno-deprecated-declarations on windows-msvc Pedro Alves
2026-07-23 13:00 ` [PATCH 05/27] gdb/testsuite: Recognize windows-msvc across lib/gdb.exp procedures Pedro Alves
2026-07-23 13:00 ` [PATCH 06/27] gdb/testsuite: Don't pass -fPIC on PE/COFF targets Pedro Alves
2026-07-23 13:00 ` [PATCH 07/27] gdb/testsuite: Use /IMPLIB on windows-msvc to name import libraries Pedro Alves
2026-07-23 13:00 ` [PATCH 08/27] gdb/testsuite: Export all DLL symbols on windows-msvc via generated .def Pedro Alves
2026-07-23 13:01 ` [PATCH 09/27] gdb/testsuite: Restrict --no-as-needed to ELF targets Pedro Alves
2026-07-23 13:01 ` [PATCH 10/27] gdb.base/set-cwd.exp: Use is_windows_native_target Pedro Alves
2026-07-23 13:01 ` [PATCH 11/27] gdb.base/exitsignal.exp: " Pedro Alves
2026-07-23 13:01 ` [PATCH 12/27] gdb.base/exitsignal.exp: Relax SIGSEGV second-chance pattern Pedro Alves
2026-07-23 13:01 ` [PATCH 13/27] gdb/testsuite: Skip -Ttext-segment on PE Pedro Alves
2026-07-23 13:01 ` [PATCH 14/27] gdb/testsuite: Support text_segment on windows-msvc via /BASE Pedro Alves
2026-07-23 13:01 ` [PATCH 15/27] gdb.base/shreloc.exp: Use gdb_compile text_segment to set image base Pedro Alves
2026-07-23 13:01 ` [PATCH 16/27] gdb/coffread: Don't relocate absolute symbols Pedro Alves
2026-07-23 13:01 ` [PATCH 17/27] gdb.base/shreloc.exp: Test absolute symbols portably Pedro Alves
2026-07-23 13:01 ` [PATCH 18/27] gdb: %p => host_address_to_string, target-section owner token Pedro Alves
2026-07-23 13:01 ` [PATCH 19/27] gdb: %p => host_address_to_string, dump_for_expression Pedro Alves
2026-07-23 13:01 ` [PATCH 20/27] gdb: %p => host_address_to_string, find_symtab_matching_filename Pedro Alves
2026-07-23 13:01 ` [PATCH 21/27] gdb: %p => host_address_to_string, handle_output_debug_string Pedro Alves
2026-07-23 13:01 ` [PATCH 22/27] gdb.base/maint-info-sections.exp: Match exec file name with optional .exe Pedro Alves
2026-07-23 13:01 ` [PATCH 23/27] gdb.base/maint-info-sections.exp: Remove stale Windows DATA xfail Pedro Alves
2026-07-23 13:01 ` [PATCH 24/27] gdb.base/solib-weak.exp: Skip on all PE/COFF targets Pedro Alves
2026-07-23 13:01 ` [PATCH 25/27] gdb.server/wrapper.exp: Skip on all Windows targets Pedro Alves
2026-07-23 13:01 ` [PATCH 26/27] gdb/testsuite: Factor out dlopen/LoadLibrary shim into lib/gdb-dlfcn.h Pedro Alves
2026-07-23 13:01 ` [PATCH 27/27] gdb/testsuite/lib/gdb-dlfcn.h: __WIN32__ => _WIN32 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=20260723130118.206735-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