From patchwork Mon Feb 13 19:27:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 56489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2530246wrn; Mon, 13 Feb 2023 11:27:32 -0800 (PST) X-Google-Smtp-Source: AK7set+1CYh8fDwmB3WjBMZNViY/eNjgQl+0Wjfvdd7vtvIrXszhG0x9BkTQX5gSmLlzO//D0tet X-Received: by 2002:a17:906:558f:b0:8b1:28a0:e7ea with SMTP id y15-20020a170906558f00b008b128a0e7eamr7837ejp.71.1676316452459; Mon, 13 Feb 2023 11:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676316452; cv=none; d=google.com; s=arc-20160816; b=Ns8WJUuTm5+p0jbIDFM3KMf0w3W14EhD4/Z2bSLkyFXfo+inI1NCrJmh60pMdgNdm7 B6djj8W9K5XGpvSa1VeeEXe2CMhqhTOOuCoQts0trG5fHflSK3bRHQpia6IZP7SBL8bk t2XJd5o0fN+Fm6o7XjTNUrDUIvWh8VbLsIG4N4kCQb7nfnlyW2UKuvbXFdxQzektiZbh DJbRDYzUYfJuFXh/oZCPcWYgw6a/mP4kMr/jOgdvknVxw0fgcp9Ye3jnbCyu+SLKWToY d6U4zaNEfLmUDHrZntgKi+NR+dehQ1UkprGn3DlSlWPMsyxVrgo9yLu9q3vdX00d0DTD mV6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=94BSErlQxf/+TBu02dQ8ozU9D86JNXiPrLR5prCrFNE=; b=AaDAALXRcrblljVn/PIHkv2RN5lJmjt+nkIsNiLyqG9286kzqev7XdkYsbuAv2Rv0I aiV9I8JzxVA7x6nfR5j9jndWV5DxQZd6ljDNfY3WN+NcnU1//5ErLHTNTqDcJ0NNLu7G NI+9vnHJJItXM1UTvutqQpnJiJrjh/nVSfF9U2RtGPkMfysJ4T2YndTEyAHWAsAlhP6/ R0fJdo9ct5PnhVLuw9vaBw+ysXlw2thehAeAfd/TUl/R2Tz0f6BkdsSvlqaAeF30onu2 0nvyhW6BlL248lLux2A0t/kY6U1/26FI9w14eu8DUxiH+t4nGHnb5/2qcC5+X/Oza6qh VKjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@rasmusvillemoes.dk header.s=google header.b=F+JOY3gk; 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 gk14-20020a17090790ce00b008875432b6aasi12764931ejb.237.2023.02.13.11.27.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 11:27:32 -0800 (PST) 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=@rasmusvillemoes.dk header.s=google header.b=F+JOY3gk; 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 495FE3881D38 for ; Mon, 13 Feb 2023 19:27:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id F404338493E8 for ; Mon, 13 Feb 2023 19:27:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F404338493E8 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rasmusvillemoes.dk Received: by mail-ej1-x62c.google.com with SMTP id qb15so32401716ejc.1 for ; Mon, 13 Feb 2023 11:27:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=94BSErlQxf/+TBu02dQ8ozU9D86JNXiPrLR5prCrFNE=; b=F+JOY3gke09uZxkWq0MnPrnxzzft1mtFqDZbUT7Hlkjs4i3i9pMujOhKJmp3mK4oAk 6yZV+H7dEckwhQ3hgvzenxaa50GTr8QMkrG6KWBRQnNw58r00lKlA0liNMr35yGh3kCX CWyCvJQ0xUne8ErIN1xsyqCvtTN5Z9sA/rwCY= 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=94BSErlQxf/+TBu02dQ8ozU9D86JNXiPrLR5prCrFNE=; b=qL2H9PHxbxrp+P3UAhbNX2lJf+vvvidNlYgFGjdQd/z2NCBNx3GpsjE43lADbv1HLl x8rZ85qIKgKP3YLoURTTW35UmvsPb4e/a1gXDpo9UG4CAbt6Af8Eqyg/b6WSs+N2oZ34 mwuwIAt6zWbWimD5AZPr0s/4E7b25DApxPbo1ovoDKmeEHu+ic66FPPHUUV7KoEpfMKK ENsUP+lMcJXl0NJ432BXR2LTWyCsR2lMTjo+TF+L35qw+bIDLMNcRCaATv/vYTyXEdUl X+khbnUcGBmXkeeCWB+QVtzq8k+TTNJub3iZI0iE5Q/caKgUEWRdpolK20O/kfC6BGfo R7aw== X-Gm-Message-State: AO0yUKUQUiF5fm25j2ic93lJVEx0EcNKqq7jnd0eWND+o/4tqvmdg64m smzMMhpRvBMQ0ElFcLM1UUAx6EN2rh2CPUC8eWs= X-Received: by 2002:a17:906:edd7:b0:88d:d304:3432 with SMTP id sb23-20020a170906edd700b0088dd3043432mr19979ejb.60.1676316423294; Mon, 13 Feb 2023 11:27:03 -0800 (PST) Received: from localhost.localdomain ([80.208.70.109]) by smtp.gmail.com with ESMTPSA id n8-20020a1709067b4800b008af574fbfc2sm5311217ejo.33.2023.02.13.11.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 11:27:02 -0800 (PST) From: Rasmus Villemoes X-Google-Original-From: Rasmus Villemoes To: gcc-patches@gcc.gnu.org Cc: Jeff Law , Rasmus Villemoes Subject: [PATCH] apply debug-remap to file names in .su files Date: Mon, 13 Feb 2023 20:27:00 +0100 Message-Id: <20230213192700.2013187-1-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: , 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?1757745200782734453?= X-GMAIL-MSGID: =?utf-8?q?1757745200782734453?= The .su files generated with -fstack-usage are arguably debug info. In order to make builds more reproducible, apply the same remapping logic to the recorded file names as for when producing the debug info embedded in the object files. To this end, teach print_decl_identifier() a new PRINT_DECL_REMAP_DEBUG flag and use that from output_stack_usage_1(). gcc/ChangeLog: * print-tree.h (PRINT_DECL_REMAP_DEBUG): New flag. * print-tree.cc (print_decl_identifier): Implement it. * toplev.cc (output_stack_usage_1): Use it. --- gcc/print-tree.cc | 6 +++++- gcc/print-tree.h | 1 + gcc/toplev.cc | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/print-tree.cc b/gcc/print-tree.cc index 1f3afcbbc86..ccecd3dc6a7 100644 --- a/gcc/print-tree.cc +++ b/gcc/print-tree.cc @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-cfg.h" #include "dumpfile.h" #include "print-tree.h" +#include "file-prefix-map.h" /* Define the hash table of nodes already seen. Such nodes are not repeated; brief cross-references are used. */ @@ -1065,7 +1066,10 @@ print_decl_identifier (FILE *file, tree decl, int flags) { expanded_location loc = expand_location (DECL_SOURCE_LOCATION (decl)); - fprintf (file, "%s:%d:%d", loc.file, loc.line, loc.column); + const char *f = flags & PRINT_DECL_REMAP_DEBUG + ? remap_debug_filename (loc.file) + : loc.file; + fprintf (file, "%s:%d:%d", f, loc.line, loc.column); } needs_colon = true; } diff --git a/gcc/print-tree.h b/gcc/print-tree.h index 7683730484f..dc5a69b7a30 100644 --- a/gcc/print-tree.h +++ b/gcc/print-tree.h @@ -45,6 +45,7 @@ extern void indent_to (FILE *, int); #define PRINT_DECL_ORIGIN 0x1 #define PRINT_DECL_NAME 0x2 #define PRINT_DECL_UNIQUE_NAME 0x4 +#define PRINT_DECL_REMAP_DEBUG 0x8 extern void print_decl_identifier (FILE *, tree, int flags); #endif // GCC_PRINT_TREE_H diff --git a/gcc/toplev.cc b/gcc/toplev.cc index 4c15d4f542e..d76571f60e8 100644 --- a/gcc/toplev.cc +++ b/gcc/toplev.cc @@ -829,7 +829,8 @@ output_stack_usage_1 (FILE *cf) if (stack_usage_file) { print_decl_identifier (stack_usage_file, current_function_decl, - PRINT_DECL_ORIGIN | PRINT_DECL_NAME); + PRINT_DECL_ORIGIN | PRINT_DECL_NAME + | PRINT_DECL_REMAP_DEBUG); fprintf (stack_usage_file, "\t" HOST_WIDE_INT_PRINT_DEC"\t%s\n", stack_usage, stack_usage_kind_str[stack_usage_kind]); }