]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
apply debug-remap to file names in .su files
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Mon, 13 Feb 2023 15:07:47 +0000 (16:07 +0100)
committerRasmus Villemoes <rv@rasmusvillemoes.dk>
Mon, 1 May 2023 08:16:00 +0000 (10:16 +0200)
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
gcc/print-tree.h
gcc/toplev.cc

index 1f3afcbbc86eedda67a0f1c17e135634f6d72aaa..ccecd3dc6a7d7157a5df7eb58ff6f5994e18e02b 100644 (file)
@@ -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;
     }
index 7683730484f8b3f5e26afd9feba66621dd51d411..dc5a69b7a30507e266438eb2c9120e72ae702ad3 100644 (file)
@@ -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
index 109c9d58cbd1950b49c78a21166a916a919162da..d53b5e78ae34b3f1e0ef86edaca4054f60412e66 100644 (file)
@@ -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]);
     }