From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kTsGFdUQYmr2WSkAWB0awg (envelope-from ) for ; Thu, 23 Jul 2026 09:02:13 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=palves.net header.i=@palves.net header.a=rsa-sha256 header.s=dreamhost header.b=svJnRZLx; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 524B21E09E; Thu, 23 Jul 2026 09:02:13 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4C8D91E099 for ; Thu, 23 Jul 2026 09:02:12 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8A9144BA23EE for ; Thu, 23 Jul 2026 13:02:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A9144BA23EE Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=palves.net header.i=@palves.net header.a=rsa-sha256 header.s=dreamhost header.b=svJnRZLx Received: from buffalo.larch.relay.mailchannels.net (buffalo.larch.relay.mailchannels.net [23.83.213.24]) by sourceware.org (Postfix) with ESMTPS id 960454BA23E6 for ; Thu, 23 Jul 2026 13:01:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 960454BA23E6 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=palves.net ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 960454BA23E6 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=23.83.213.24 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784811685; cv=none; b=p2EocAHRcuIdEoit9Bw9RwNHRfjqYc/9M33OXxPPfVtZjSwahcvB3kk/3HGJvVB5nvEAfWPe+xfhYCY8cbqV9Yx7ga376T35ZC4DLkw7GSkyJYUeutucPu26EOyiGZUkDogmSoCfR6BghuTzArqfW4qzmw4iFbSvSRVA8ljd2Fc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784811685; c=relaxed/simple; bh=zqQikPTe80a7IWnNvQhTFiWhsTAaaGOW+BzevrOD9/8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IyywtA1urP6khekAO3Z322OdnADStw65sj7OR+AZ5ypoQ9rOoPs8tTm12k5bcYoQvd4jzTtHQB9N87uwrXxjHNZ0odP90NGsYtMRJHZeM1++IOECW2ypp7krFeosevxdrygGnFJ/wnT/nj6SCTMFIU3q8/cYXbO0jqhwJikiQk4= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=palves.net header.i=@palves.net header.a=rsa-sha256 header.s=dreamhost header.b=svJnRZLx DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 960454BA23E6 X-Sender-Id: dreamhost|x-authsender|pedro@palves.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 0883C42475 for ; Thu, 23 Jul 2026 13:01:23 +0000 (UTC) Received: from pdx1-sub0-mail-a249.dreamhost.com (100-104-241-133.trex-nlb.outbound.svc.cluster.local [100.104.241.133]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 73F83425E6 for ; Thu, 23 Jul 2026 13:01:22 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|pedro@palves.net X-MC-Relay: Good X-MailChannels-SenderId: dreamhost|x-authsender|pedro@palves.net X-MailChannels-Auth-Id: dreamhost X-Shade-Bored: 3f14e8634dd22657_1784811682729_357686454 X-MC-Loop-Signature: 1784811682729:2735267184 X-MC-Ingress-Time: 1784811682729 Received: from pdx1-sub0-mail-a249.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.104.241.133 (trex/8.0.2); Thu, 23 Jul 2026 13:01:22 +0000 Received: from localhost (bl20-181-64.dsl.telepac.pt [2.81.181.64]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pedro@palves.net) by pdx1-sub0-mail-a249.dreamhost.com (Postfix) with ESMTPSA id 4h5WTY6cDtz1041 for ; Thu, 23 Jul 2026 06:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=palves.net; s=dreamhost; t=1784811682; bh=nat/0MFWHbBoUSqzApeiObCo909nV1Y5LjhXL5x29YQ=; h=From:To:Subject:Date:Content-Transfer-Encoding; b=svJnRZLx6BsylFGv6NE6KGZKye/3/+mPibfXRHBrZ0P3hvsn9HIZB9o4ZKDipSys1 uZXIbp5bV/sGEv9q3KTZ29SdH6oiAegysXgZTkAn0jLFo+N89A2YRds+pG61Dqg/+7 13p5r8VRuSZgC/xBYfrfMYNlR9/EDdcETG6SWZCHnE0I5zvo5OGpWl6s9StX+NfR7V 3KpLddZ/DWEm3i7C4LJTy9N2okcT40mz5l8CFd2kjsLADEd1KrOnPbIHLHZAhaDPi9 ZaJaaTV9mJoL3BTRYMX2ZAPK840tsuZBRQ+WfAiWldXQS7f0Avo4Jnd4sCkLQGKuuQ kNvn5Bn0UP6Sw== From: Pedro Alves 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 Message-ID: <20260723130118.206735-1-pedro@palves.net> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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