[PATCH 00/27] Teach the testsuite about the Windows/MSVC target
Pedro Alves <[email protected]> Thu, 23 Jul 2026 14:00:51 +0100
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
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/[email protected]/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