From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH 00/27] Teach the testsuite about the Windows/MSVC target
Date: Thu, 23 Jul 2026 14:00:51 +0100 [thread overview]
Message-ID: <20260723130118.206735-1-pedro@palves.net> (raw)
This series teaches the GDB testsuite about Windows targets whose
triplet uses the "windows" OS and the MSVC ABI, as produced by Clang
(e.g. x86_64-pc-windows-msvc), so that a MinGW-hosted GDB configured
with:
--host=x86_64-w64-mingw32 --target=x86_64-pc-windows-msvc
can be exercised against a matching Clang.
This is how a Windows AMDGPU GDB should be tested, as the gdb.rocm/
testcases compile with such a Clang.
This builds on part 1, which teaches GDB proper about such targets:
https://inbox.sourceware.org/gdb-patches/20260714004507.1323332-1-pedro@palves.net/T/
[PATCH 0/4] Support the Windows/MSVC target in GDB
The bulk of the work is in the testsuite, plus a couple of GDB fixes
that testcases surfaced.
The patches fall into a few groups:
- Native "make check" for a differing host/target.
A MinGW-hosted GDB targeting the MSVC ABI has host and target
triplets that differ, but it is still a native configuration. Two
patches make plain "make check" (with no board file) largely Just
Work there. I usually combine this with CC_FOR_TARGET, but no need
to point at objdump, objcopy, etc., etc...
- New istarget predicates.
The testsuite is littered with hand-rolled istarget checks like
"[istarget *-*-mingw*] || [istarget *-*-cygwin*]" that do not match
windows-msvc. This series introduces is_windows_native_target and
is_pecoff_target in lib/gdb.exp, routes the existing checks through
them, and then goes over individual testcases replacing the
open-coded checks.
- Compile and link fixes for the windows-msvc toolchain.
lld-link, the linker Clang drives on windows-msvc, is stricter than
GNU ld: it rejects -fPIC, -Wl,--no-as-needed, --out-implib, and
-Ttext-segment, exports no DLL symbols by default.
There is no separate math library (-lm).
A handful of patches make gdb_compile/gdb_compile_shlib do the right
thing for the target: drop -lm, drop -fPIC on PE/COFF, restrict
--no-as-needed to ELF, generate a .def to export all DLL symbols,
use /IMPLIB for import libraries, and support the text_segment
option via lld-link's /BASE.
- Along the way, a preexisting testsuite cygwin/mingw bug is fixed:
-Ttext-segment was silently ignored by PE ld, so the image base was
-never actually being set -- --image-base is the right flag there.
- MSVC C runtime differences.
The MSVC CRT renders %p without a "0x" prefix and defaults to a
statically-linked, single-threaded CRT. A few patches switch the
affected GDB printfs to host_address_to_string (so pointers always
print "0x"-prefixed), and relax a testcase pattern that assumed a
multi-threaded inferior at main.
- A GDB fix that a testcase surfaced - absolute symbols and relocations
gdb/coffread.c currently incorrectly relocates COFF absolute symbols
as if they belonged to the text section, so an absolute symbol in a
relocated DLL comes out shifted by the load bias.
gdb.base/shreloc.exp catches this on mingw/cygwin. Funny enough,
that part of the test can only run on those targets currently, so if
e.g., Linux got it absolute symbols wrong we wouldn't notice. The
series tweaks that test to be able to run it on all targets.
- The dlopen/LoadLibrary shim scattered across several testcases is
factored into a new lib/gdb-dlfcn.h, and its Windows guard switched
from the MinGW-ism __WIN32__ to _WIN32 so it works with Clang
targeting windows-msvc too.
Pedro Alves (27):
gdb/testsuite: Don't link with -lm on windows-msvc
gdb/testsuite: Use unprefixed runtest for a native Windows/MSVC build
gdb/testsuite: Find host binutils in a native Windows/MSVC config
gdb/testsuite: Compile with -Wno-deprecated-declarations on
windows-msvc
gdb/testsuite: Recognize windows-msvc across lib/gdb.exp procedures
gdb/testsuite: Don't pass -fPIC on PE/COFF targets
gdb/testsuite: Use /IMPLIB on windows-msvc to name import libraries
gdb/testsuite: Export all DLL symbols on windows-msvc via generated
.def
gdb/testsuite: Restrict --no-as-needed to ELF targets
gdb.base/set-cwd.exp: Use is_windows_native_target
gdb.base/exitsignal.exp: Use is_windows_native_target
gdb.base/exitsignal.exp: Relax SIGSEGV second-chance pattern
gdb/testsuite: Skip -Ttext-segment on PE
gdb/testsuite: Support text_segment on windows-msvc via /BASE
gdb.base/shreloc.exp: Use gdb_compile text_segment to set image base
gdb/coffread: Don't relocate absolute symbols
gdb.base/shreloc.exp: Test absolute symbols portably
gdb: %p => host_address_to_string, target-section owner token
gdb: %p => host_address_to_string, dump_for_expression
gdb: %p => host_address_to_string, find_symtab_matching_filename
gdb: %p => host_address_to_string, handle_output_debug_string
gdb.base/maint-info-sections.exp: Match exec file name with optional
.exe
gdb.base/maint-info-sections.exp: Remove stale Windows DATA xfail
gdb.base/solib-weak.exp: Skip on all PE/COFF targets
gdb.server/wrapper.exp: Skip on all Windows targets
gdb/testsuite: Factor out dlopen/LoadLibrary shim into lib/gdb-dlfcn.h
gdb/testsuite/lib/gdb-dlfcn.h: __WIN32__ => _WIN32
gdb/acinclude.m4 | 3 +
gdb/coffread.c | 23 +-
gdb/configure | 40 +--
gdb/configure.ac | 23 +-
gdb/expprint.c | 3 +-
gdb/gdb-native.m4 | 30 ++
gdb/maint.c | 4 +-
gdb/symfile-debug.c | 4 +-
gdb/testsuite/Makefile.in | 4 +-
gdb/testsuite/aclocal.m4 | 1 +
gdb/testsuite/configure | 19 ++
gdb/testsuite/configure.ac | 5 +
gdb/testsuite/gdb.base/bp-disabled-by-cond.c | 13 +-
gdb/testsuite/gdb.base/catch-load.c | 8 +-
.../gdb.base/corefile-buildid-shlib.c | 10 +-
gdb/testsuite/gdb.base/exitsignal.exp | 4 +-
gdb/testsuite/gdb.base/jit-unload.c | 9 +-
.../gdb.base/maint-info-sections.exp | 18 +-
gdb/testsuite/gdb.base/set-cwd.exp | 2 +-
gdb/testsuite/gdb.base/shlib-unload.c | 13 +-
gdb/testsuite/gdb.base/shreloc.exp | 31 +--
gdb/testsuite/gdb.base/shreloc.h | 33 +++
gdb/testsuite/gdb.base/shreloc1.c | 2 +
gdb/testsuite/gdb.base/shreloc2.c | 2 +
gdb/testsuite/gdb.base/solib-disc.c | 10 +-
gdb/testsuite/gdb.base/solib-weak.exp | 13 +-
gdb/testsuite/gdb.base/unload.c | 21 +-
gdb/testsuite/gdb.base/watchpoint-solib.c | 17 +-
gdb/testsuite/gdb.mi/mi-catch-load.c | 8 +-
gdb/testsuite/gdb.mi/mi-dprintf-modified.c | 13 +-
gdb/testsuite/gdb.perf/solib.c | 9 +-
gdb/testsuite/gdb.python/py-event-load.c | 8 +-
gdb/testsuite/gdb.server/wrapper.exp | 3 +-
gdb/testsuite/lib/future.exp | 91 +++++--
gdb/testsuite/lib/gdb-dlfcn.h | 51 ++++
gdb/testsuite/lib/gdb.exp | 257 +++++++++++++-----
gdb/windows-nat.c | 5 +-
37 files changed, 508 insertions(+), 302 deletions(-)
create mode 100644 gdb/gdb-native.m4
create mode 100644 gdb/testsuite/gdb.base/shreloc.h
create mode 100644 gdb/testsuite/lib/gdb-dlfcn.h
base-commit: 33f0797fff4dcac33092bfde19105c1eeb483526
prerequisite-patch-id: ed1cdd12fb2e8aff39333606bd7e09be908d38b2
prerequisite-patch-id: 2573abf27e64de02c68de290f396c180aab7f07c
prerequisite-patch-id: 4ad37c9dcc630915da81f129125a9db1ad21812d
prerequisite-patch-id: 77b8e6b2ee0b0d3b8db75cec33683b9e929dd241
prerequisite-patch-id: ba7de51d339a3bde1e3519679487861355826eef
--
2.54.0
next 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 Pedro Alves [this message]
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 ` [PATCH 02/27] gdb/testsuite: Use unprefixed runtest for a native Windows/MSVC build Pedro Alves
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-1-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