public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Bernd Edlinger <edlinger@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-2735] Fix debug info for ignored decls at start of assembly
Date: Wed,  4 Aug 2021 14:19:15 +0000 (GMT)	[thread overview]
Message-ID: <20210804141915.AE256385E019@sourceware.org> (raw)

https://gcc.gnu.org/g:96c82a16b2076891a9974d0f0e96a0b85fbc2df4

commit r12-2735-g96c82a16b2076891a9974d0f0e96a0b85fbc2df4
Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
Date:   Sat Jul 24 12:53:39 2021 +0200

    Fix debug info for ignored decls at start of assembly
    
    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.

Diff:
---
 gcc/dwarf2out.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 884f1e191c6..b91a9b5abaa 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -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


                 reply	other threads:[~2021-08-04 14:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210804141915.AE256385E019@sourceware.org \
    --to=edlinger@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).