From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AK7set/htpt4ODjqwoOF3LpGqbX/gHme+vDVyGtdVHYXgEHA0tRCFE3i7sHkJjgFypIRpMeeCerBmA== 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) Sender: Rasmus Villemoes 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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]); } -- 2.37.2