From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MSLgGO5uemoi0RsAWB0awg (envelope-from ) for ; Mon, 10 Aug 2026 20:38:06 -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=vFnTbAx+; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 619C41E09B; Mon, 10 Aug 2026 20:38:06 -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 A62CE1E09B for ; Mon, 10 Aug 2026 20:38:05 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 18EBC4BB3BF2 for ; Tue, 11 Aug 2026 00:38:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18EBC4BB3BF2 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=vFnTbAx+ Received: from eastern.birch.relay.mailchannels.net (eastern.birch.relay.mailchannels.net [23.83.209.55]) by sourceware.org (Postfix) with ESMTPS id 9050C4BB3BE3 for ; Tue, 11 Aug 2026 00:37:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9050C4BB3BE3 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 9050C4BB3BE3 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=23.83.209.55 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786408659; cv=none; b=ZYuhvH7UhuiRhIQGzpP8C2dwddyRvo4OFNrH2CvBh5ZZ1zWe/t6kYyzMt07df6N4mG8j4fU+evithluSpUbN9G4xX3aE7IwYqfH5Tovq4/FIEK2QcnrHntFXNfOUjWhT9WVg86glPHM0u+dHVs7RI9n/myJzdKb2P1Y23xNUL+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786408659; c=relaxed/simple; bh=KSJZlHV17wMkVv2RuaxDPHzhICA0XGgzthhbXTZfnuk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Eig9r5yY20dFdHZvaVYFPFdHId9uhSGbtbBRqBaMagv4zksTAHzKUxDXyaAbLgpCq1SekdjiXTwzjV5jnQ5q5IK6jZ519QiJK/gTH0Mv8e0KvfP0n39pqSiIlZcWSrKUs0PcmjG0qwlV8R1794s/nRkdJcjw2ZvQUXekAQRfvPM= 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=vFnTbAx+ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9050C4BB3BE3 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 892A34C183F for ; Tue, 11 Aug 2026 00:37:38 +0000 (UTC) Received: from pdx1-sub0-mail-a258.dreamhost.com (trex-green-5.trex.outbound.svc.cluster.local [100.108.75.116]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 3C4B64C1C66 for ; Tue, 11 Aug 2026 00:37:34 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|pedro@palves.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|pedro@palves.net X-MailChannels-Auth-Id: dreamhost X-Tank-Chemical: 0cb65ca1029ddaa2_1786408658480_441380259 X-MC-Loop-Signature: 1786408658480:599976839 X-MC-Ingress-Time: 1786408658479 Received: from pdx1-sub0-mail-a258.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.108.75.116 (trex/8.0.2); Tue, 11 Aug 2026 00:37:38 +0000 Received: from localhost (bl21-204-140.dsl.telepac.pt [2.82.204.140]) (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-a258.dreamhost.com (Postfix) with ESMTPSA id 4hJt4Y586zzyrD for ; Mon, 10 Aug 2026 17:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=palves.net; s=dreamhost; t=1786408654; bh=Me588VYN1tSqwOv+MnQw9Cg1igiSd/Amb+/qWfPbdis=; h=From:To:Subject:Date:Content-Transfer-Encoding; b=vFnTbAx+qTZFb+aQVLNr2m2opzfQuIcnImZO1PyLgm8odD2oQCa+eqYuvDSxCUEzl AajgLCYTApCYmqIUhuRPdbOkXOjcFDTv24W4vsqsLfcdsJsi0oVz9TXpLMNKAMdQGv vDTnyJR6mzdKo/M7Yvk413uvjAtwBbnd4ZFDyMFB92pKBXi+1PGCxnzVyLLPKGdXqT MFVS5dy4YChBh0EZW4wsiI4DRbMHaMvp2u/6V/twSaN88oAGp3QFtCVbYPeeQpzApF XQpx5ZFjPLus7yfAKdsNoWo4JfdRd612zehrDtpDeQaQsqNQcEpZ9meRfDt5iYbcV0 nXSGLj/ZtKbmQ== From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/2] gdb/testsuite: Force DWARF debug info on windows-msvc Date: Tue, 11 Aug 2026 01:37:00 +0100 Message-ID: <20260811003700.3580470-3-pedro@palves.net> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260811003700.3580470-1-pedro@palves.net> References: <20260811003700.3580470-1-pedro@palves.net> 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 Clang's windows-msvc targets default to outputting PDB debug info for host code, which GDB does not understand. This commit makes the testsuite tell the compiler/linker to emit DWARF instead. There is a block in gdb_compile already doing this for AIX, so we extend it. Extra care is taken to make it possible to run the testsuite with another debug format, by passing the (pre-existing) debug_format flag, like this for example on the command line: $ make check RUNTESTFLAGS="--target_board unix/gdb:debug_flags=-gcodeview" or with a custom board that sets debug_flags. Change-Id: I5bcafa408696b349b829b4ffbd75037be25b3f3b --- gdb/testsuite/lib/gdb.exp | 85 ++++++++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 15 deletions(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 912ddf1cd54..0d3497fa3f2 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -6747,21 +6747,76 @@ proc gdb_compile {source dest type options} { } } - # On AIX systems, until GCC 12 (maybe later), stabs was the default - # debug option, but we'd like to have dwarf instead. - # If we're running on one of those systems and debug was requested, - # but no explicit -g option was given, use -gdwarf to force - # that as the debug info for the inferior. - # This list should be exhaustive: - set debug_format "btf|ctf|stabs|vms|coff|xcoff" - # Since additional_flags is a comma separated list, identify if there - # are other (optional) flags in the list. - set other_options "-\[a-zA-Z0-9\]*," - set full_regexp "^additional_flags=\($other_options\)*-g\($debug_format\)" - if { [istarget *-*-aix*] - && [lsearch -exact $options debug] != -1 - && [lsearch -regexp $options $full_regexp] == -1} { - lappend new_options "additional_flags=-gdwarf" + # Some systems default to debug formats other than DWARF, but we'd + # like to have DWARF instead: + # + # - On AIX systems, until GCC 12 (maybe later), stabs was the + # default debug option. + # + # - windows-msvc targets default to PDB/CodeView debug info, which + # we don't support. + # + # If we're running on one of those systems and debug was + # requested, but no explicit -g option was given, nor has + # a specific debug format been requested via debug_flags in the + # target board, use -gdwarf to force DWARF as the debug info for + # the inferior. + if {[lsearch -exact $options debug] != -1} { + # This list should be exhaustive: + set debug_format "btf|ctf|stabs|vms|coff|xcoff|dwarf|codeview" + # True if we're using DWARF. + set using_dwarf 0 + # Since additional_flags is a comma separated list, identify + # if there are other (optional) flags in the list. + set other_options "-\[a-zA-Z0-9\]*," + set full_regexp "^additional_flags=\($other_options\)*-g\($debug_format\)" + if { ([istarget *-*-aix*] || [istarget *-*-windows-msvc*]) + && ![board_info [target_info name] exists debug_flags] + && [lsearch -regexp $options $full_regexp] == -1} { + # Nothing is explicitly choosing a debug format. Emit + # DWARF. + lappend new_options "additional_flags=-gdwarf" + set using_dwarf 1 + } + + # On windows-msvc, if we're targeting DWARF, we need a couple + # extra linker (lld-link) options. This is a separate check + # from the above because we need to check whether the board + # file selects DWARF via debug_flags. + if { [istarget *-*-windows-msvc*] } { + set dwarf_regexp "^additional_flags=\($other_options\)*-gdwarf" + if { [board_info [target_info name] exists debug_flags] } { + # The board wants a specific debug format. Check + # whether it's DWARF. + set board_debug_flags "[board_info [target_info name] debug_flags]" + if { [lsearch -regexp $board_debug_flags "-gdwarf"] != -1 } { + set using_dwarf 1 + } + } elseif { [lsearch -regexp $options $dwarf_regexp] == -1 } { + # The testcase explicitly requested DWARF. + set using_dwarf 1 + } + + if {$using_dwarf} { + # Passing "-debug:dwarf" to lld-link suppresses: + # lld-link: warning: section name .debug_info is longer + # than 8 characters and will use a non-standard string table + # + # -Wl,/ignore:longsections would also work, but + # telling lld-link we're outputting DWARF does more + # than suppress the warning. + # + # Passing -debug:none before -debug:dwarf is necessary + # to disable PDB emission. This is because Clang + # passes -debug to lld-link if you specify _any_ -g + # option, including -gdwarf, and -debug makes lld-link + # emit a PDB file. IOW, even plain -gdwarf still + # emits a (mostly empty and useless) PDB file. + # -debug:dwarf does not disable PDB emission (by + # design), but "-debug:none" does disable it. + lappend new_options "ldflags=-Wl,-debug:none -Wl,-debug:dwarf" + } + } } set shlib_found 0 -- 2.54.0