]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix debug info for ignored decls at start of assembly
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Sat, 24 Jul 2021 10:53:39 +0000 (12:53 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Wed, 4 Aug 2021 14:18:07 +0000 (16:18 +0200)
Ignored functions decls that are compiled at the start of
the assembly have bogus line numbers until the first .file
directive, as reported in PR101575.

The corresponding binutils bug report is
https://sourceware.org/bugzilla/show_bug.cgi?id=28149

The work around for this issue is to emit a dummy .file
directive before the first function is compiled, unless
another .file directive was already emitted previously.

2021-08-04  Bernd Edlinger  <bernd.edlinger@hotmail.de>

PR ada/101575
* dwarf2out.c (dwarf2out_assembly_start): Emit a dummy
.file statement when needed.

gcc/dwarf2out.c

index 884f1e191c6591a67acac580db8318e1afc09fe7..b91a9b5abaac7bb6fbfea82572c7c0a1cf08f5fd 100644 (file)
@@ -29389,7 +29389,18 @@ dwarf2out_assembly_start (void)
       output_quoted_string (asm_out_file, remap_debug_filename (filename0));
       fputc ('\n', asm_out_file);
     }
+  else
 #endif
+  /* Work around for PR101575: output a dummy .file directive.  */
+  if (!last_emitted_file && dwarf_debuginfo_p ()
+      && debug_info_level >= DINFO_LEVEL_TERSE)
+    {
+      const char *filename0 = get_AT_string (comp_unit_die (), DW_AT_name);
+
+      if (filename0 == NULL)
+       filename0 = "<dummy>";
+      maybe_emit_file (lookup_filename (filename0));
+    }
 }
 
 /* A helper function for dwarf2out_finish called through