From patchwork Mon Oct 24 00:28:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Harmstone X-Patchwork-Id: 8102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp185167wru; Sun, 23 Oct 2022 17:29:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7WZzQoIO5DKCEhzERd91M+68ISwOqgma9+sD/0a5CdLO8laCC6qDE8Xb8Wz24dg7I6SfE9 X-Received: by 2002:a17:906:770d:b0:73c:a08f:593c with SMTP id q13-20020a170906770d00b0073ca08f593cmr26017038ejm.182.1666571381049; Sun, 23 Oct 2022 17:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666571381; cv=none; d=google.com; s=arc-20160816; b=LEiNJGAR6FTlXvuBrDFUQaM/ucixRsnqjuH2AqQd/dozDV5yDYNsnGHl/IQSHjNc1s yRp6q0P98Bj7i1Tsq47bfq8E4swkcdUuLtdLFwDagrse7VEB62hBMKGExWsH2UR/N3u7 +cxkB0QGjtQzxcUtZsXedk7WDX28l0Fc3vuGLRCfjPkKjejpDQWV6gHYSabyYLKma2Hn rSxHrf0z/TlIZmoh2K2h4x5swc/rCA80tD/iRv1JmVfQXrVmfkHixyjv1Uf7X4JOL8I6 lABJDYHlYWV2ypVZYZCG5R4ei5BcSBVP1WiRWShFt+yhzXZjec9brsbSbU9a6T/UjKlZ +MMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=0oXDdJMvy0Caq1Re9vzpFzAo79P9gmmPl5TTpRfK8qg=; b=rnjZtmsNHTRzqvHoT+ghsJ+m1RjMXxU/G6NraESCZpPNr9bdVR27++2LwJuIef8ftp aM4r0ede65wL0moDMAqoZDsYurvQrJ3Di6pRpCP0sAls0kBofuBCF9nucQN6jKvQZ3IK 00UfH7zyupstIh4nsHm9iSCl4+Wn36+qGPAIpnR5mzrQv3M81eBvXMSAqWzn0bJhU7tg 5fbLlnopjSMTKtQOTQ107aan/gllap1NscrGtWZCqvNXeicE7b25yPveLlbnz1OmB0Wh NmZ6OsJIZ5eJWjve/x/eygiuzd8AHf/4pTAsiU8HcpLtIje3B4jQkgLi4WyPZlYdutit ovGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=Ggma0TlI; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t14-20020a056402240e00b004588af9ea19si26511239eda.166.2022.10.23.17.29.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 17:29:41 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=Ggma0TlI; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A9BE13851A9C for ; Mon, 24 Oct 2022 00:29:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 4D0D63853802 for ; Mon, 24 Oct 2022 00:28:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4D0D63853802 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=harmstone.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x42e.google.com with SMTP id a14so10883598wru.5 for ; Sun, 23 Oct 2022 17:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=0oXDdJMvy0Caq1Re9vzpFzAo79P9gmmPl5TTpRfK8qg=; b=Ggma0TlI1qizBsA/EAEPENm+JOubS4IeWVVAP29HL8fkY7JYI3xRrk+ohcW2KW8UiE c0KOrqQ4Qw4JGgt+tv09hfvjS2WqBhiUZDIRBvTZp8FeE1i+AExDjBi4mN+IZQWxTHj+ O9ET/4y4P9Tgg1ZhWY4h0hv1/UCz9ru9MHOOGPzQxhsQXFTOnywRtTx3Jwr5bepV+4er Vob/lUqhteA1xOeDnS40ZgiSPZeSREDqp1YYkIjZJSz7Hdbtqt3rAlL8+4iTCbNLeFsl PIsE5yHhBzCfAVxyx8t0G6cVgUSTX21rNgZhilIwpoerFF5F0sKRItD3vQG/1t3FFwaz DW+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0oXDdJMvy0Caq1Re9vzpFzAo79P9gmmPl5TTpRfK8qg=; b=fTBkXBrFHH3ckoqE0s4e9+oLncQUeaB0GQ5mxd5Sj8Jm30hghakKy8Bvue0IoAXIFU s0XBZE7T8xuME9jcFFMPTmOW3IRcbvO565glUTNEaP9NJ7x3L9SV7BAaZXopTBYg0t9u FfZRnefkZR/OWc1JalIC+SpMl5K3HWUhBp3f/TYVQ9Tm1wwLWvJzTnSDHZVDWBeUP1uB 2IIOnhfZoCnPT7SyHPl1D2YPgRhw80E+AZ64dHrCLesYSDaFblCHF/4i0xBmStwfKfW0 K9QaHRCe0FlLrGCIq0spRLmLfOFeRoTNoAVPkr90PCkPbDKwWzsafvPed5o43qpLvVy8 WLdA== X-Gm-Message-State: ACrzQf0DlRH/P+S+U7ivTFT3C6qhpJxFo9kkVSZO+CEXjnVYeV3zBwRf 9BqBWvTJU6IBLkgoU3lcebqI92/Epic= X-Received: by 2002:a5d:43c5:0:b0:236:6ff9:9167 with SMTP id v5-20020a5d43c5000000b002366ff99167mr1681052wrr.160.1666571331630; Sun, 23 Oct 2022 17:28:51 -0700 (PDT) Received: from beren.harmstone.com ([2a02:8010:64ea:0:8eb8:7eff:fe53:9d5f]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b003b4a68645e9sm6735567wmg.34.2022.10.23.17.28.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 17:28:51 -0700 (PDT) From: Mark Harmstone To: gcc-patches@gcc.gnu.org, martin@martin.st Subject: [PATCH] Add -gcodeview option Date: Mon, 24 Oct 2022 01:28:28 +0100 Message-Id: <20221024002828.28861-1-mark@harmstone.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Harmstone Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747526752644591931?= X-GMAIL-MSGID: =?utf-8?q?1747526752644591931?= Both current lld and the next version of ld have an option -pdb, which creates a PDB file which Microsoft's debuggers can use. This patch adds a -gcodeview option, which passes this to the linker. I do intend to expand this so it also creates the .debug$S and .debug$T sections which would make this useful - I submitted patches for this a while back, but they need to be rewritten to parse the DWARF DIEs rather than using debug_hooks. Clang also has -gcodeview, but AFAICS only uses it for .debug$S and .debug$T, and doesn't use it for linker options (though IMO it probably should). --- gcc/common.opt | 4 ++++ gcc/doc/invoke.texi | 7 +++++++ gcc/gcc.cc | 4 ++++ gcc/opts.cc | 3 +++ 4 files changed, 18 insertions(+) diff --git a/gcc/common.opt b/gcc/common.opt index 8a0dafc522d..77103f961d8 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -3253,6 +3253,10 @@ gas-locview-support Common Driver Var(dwarf2out_as_locview_support) Assume assembler support for view in (DWARF2+) .loc directives. +gcodeview +Common Driver JoinedOrMissing +Generate debug information in CodeView format. + gcoff Common Driver WarnRemoved Does nothing. Preserved for backward compatibility. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index ff6c338bedb..2d29fd2611d 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -483,6 +483,7 @@ Objective-C and Objective-C++ Dialects}. -gstabs -gstabs+ -gstrict-dwarf -gno-strict-dwarf @gol -gas-loc-support -gno-as-loc-support @gol -gas-locview-support -gno-as-locview-support @gol +-gcodeview @gol -gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 @gol -gstatement-frontiers -gno-statement-frontiers @gol -gvariable-location-views -gno-variable-location-views @gol @@ -10358,6 +10359,12 @@ assembler (GAS) to fail with an error. Produce debugging information in Alpha/VMS debug format (if that is supported). This is the format used by DEBUG on Alpha/VMS systems. +@item -gcodeview +@opindex gcodeview +Produce debugging information in CodeView debug format (if that is +supported). This is the format used by Microsoft Visual C++ on +Windows. + @item -g@var{level} @itemx -ggdb@var{level} @itemx -gstabs@var{level} diff --git a/gcc/gcc.cc b/gcc/gcc.cc index bb07cc244e3..2820f325282 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -4608,6 +4608,10 @@ driver_handle_option (struct gcc_options *opts, do_save = false; break; + case OPT_gcodeview: + add_infile ("-pdb=", "*"); + break; + default: /* Various driver options need no special processing at this point, having been handled in a prescan above or being diff --git a/gcc/opts.cc b/gcc/opts.cc index 3a89da2dd03..e2633ee5439 100644 --- a/gcc/opts.cc +++ b/gcc/opts.cc @@ -3089,6 +3089,9 @@ common_handle_option (struct gcc_options *opts, set_debug_level (NO_DEBUG, 2, arg, opts, opts_set, loc); break; + case OPT_gcodeview: + break; + case OPT_gstabs: case OPT_gstabs_: set_debug_level (DBX_DEBUG, code == OPT_gstabs_, arg, opts, opts_set,