]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
debug/101473 - apply debug prefix maps before checksumming DIEs
authorRichard Biener <rguenther@suse.de>
Tue, 20 Jul 2021 09:00:33 +0000 (11:00 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 20 Jul 2021 10:49:59 +0000 (12:49 +0200)
The following makes sure to apply the debug prefix maps to filenames
before checksumming DIEs to create the global symbol for the CU DIE
used by LTO to link the late debug to the early debug.  This avoids
binary differences (in said symbol) when compiling with toolchains
installed under a different path and that compensated with appropriate
-fdebug-prefix-map options.

The easiest and most scalable way is to record both the unmapped
and the remapped filename in the dwarf_file_data so the remapping
process takes place at a single point and only once (otherwise it
creates GC garbage at each point doing that).

2021-07-20  Richard Biener  <rguenther@suse.de>

PR debug/101473
* dwarf2out.h (dwarf_file_data): Add key member.
* dwarf2out.c (dwarf_file_hasher::equal): Compare key.
(dwarf_file_hasher::hash): Hash key.
(lookup_filename): Remap the filename and store it in the
filename member of dwarf_file_data when creating a new
dwarf_file_data.
(file_name_acquire): Do not remap the filename again.
(maybe_emit_file): Likewise.

gcc/dwarf2out.c
gcc/dwarf2out.h

index 82783c4968b857ffadbab193b078e3f40a47ff39..884f1e191c6591a67acac580db8318e1afc09fe7 100644 (file)
@@ -12424,7 +12424,7 @@ file_name_acquire (dwarf_file_data **slot, file_name_acquire_data *fnad)
 
   fi = fnad->files + fnad->used_files++;
 
-  f = remap_debug_filename (d->filename);
+  f = d->filename;
 
   /* Skip all leading "./".  */
   while (f[0] == '.' && IS_DIR_SEPARATOR (f[1]))
@@ -27460,13 +27460,13 @@ dwarf2out_ignore_block (const_tree block)
 bool
 dwarf_file_hasher::equal (dwarf_file_data *p1, const char *p2)
 {
-  return filename_cmp (p1->filename, p2) == 0;
+  return filename_cmp (p1->key, p2) == 0;
 }
 
 hashval_t
 dwarf_file_hasher::hash (dwarf_file_data *p)
 {
-  return htab_hash_string (p->filename);
+  return htab_hash_string (p->key);
 }
 
 /* Lookup FILE_NAME (in the list of filenames that we know about here in
@@ -27496,7 +27496,8 @@ lookup_filename (const char *file_name)
     return *slot;
 
   created = ggc_alloc<dwarf_file_data> ();
-  created->filename = file_name;
+  created->key = file_name;
+  created->filename = remap_debug_filename (file_name);
   created->emitted_number = 0;
   *slot = created;
   return created;
@@ -27522,8 +27523,7 @@ maybe_emit_file (struct dwarf_file_data * fd)
       if (output_asm_line_debug_info ())
        {
          fprintf (asm_out_file, "\t.file %u ", fd->emitted_number);
-         output_quoted_string (asm_out_file,
-                               remap_debug_filename (fd->filename));
+         output_quoted_string (asm_out_file, fd->filename);
          fputc ('\n', asm_out_file);
        }
     }
index 057afdb53a0e3542e2137d47bfb529b45a6b54e0..b2152a53bf96f7d7c3f3b7688d97d9325fe0240e 100644 (file)
@@ -424,6 +424,7 @@ extern enum dwarf_tag dw_get_die_tag (dw_die_ref);
 
 /* Data about a single source file.  */
 struct GTY((for_user)) dwarf_file_data {
+  const char * key;
   const char * filename;
   int emitted_number;
 };