public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-8650] Emit .file 0 directive earlier in DWARF 5
Date: Thu, 24 Jun 2021 13:28:33 +0000 (GMT)	[thread overview]
Message-ID: <20210624132833.627CD388801B@sourceware.org> (raw)

https://gcc.gnu.org/g:f19b20de1b24d6b53479c6815316a5201b22775d

commit r11-8650-gf19b20de1b24d6b53479c6815316a5201b22775d
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Thu Jun 24 12:55:27 2021 +0200

    Emit .file 0 directive earlier in DWARF 5
    
    When the assembler supports it, the compiler automatically passes --gdwarf-5
    to it, which has an interesting side effect: any assembly instruction prior
    to the first .file directive defines a new line associated with .file 0 in
    the .debug_line section and of course the numbering of these implicit lines
    has nothing to do with that of the source code.  This can be problematic in
    Ada when we do not generate .file/.loc directives for compiled-generated
    functions to avoid too jumpy a debugging experience.
    
    gcc/
            * dwarf2out.c (dwarf2out_assembly_start): Emit .file 0 marker here..
            (dwarf2out_finish): ...instead of here.

Diff:
---
 gcc/dwarf2out.c | 45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 7a15debcb48..079b617fd0c 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -29121,6 +29121,30 @@ dwarf2out_assembly_start (void)
       && dwarf2out_do_cfi_asm ()
       && !dwarf2out_do_eh_frame ())
     fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");
+
+#if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
+  if (output_asm_line_debug_info () && dwarf_version >= 5)
+    {
+      /* When gas outputs DWARF5 .debug_line[_str] then we have to
+	 tell it the comp_dir and main file name for the zero entry
+	 line table.  */
+      const char *comp_dir, *filename0;
+
+      comp_dir = comp_dir_string ();
+      if (comp_dir == NULL)
+	comp_dir = "";
+
+      filename0 = get_AT_string (comp_unit_die (), DW_AT_name);
+      if (filename0 == NULL)
+	filename0 = "";
+
+      fprintf (asm_out_file, "\t.file 0 ");
+      output_quoted_string (asm_out_file, remap_debug_filename (comp_dir));
+      fputc (' ', asm_out_file);
+      output_quoted_string (asm_out_file, remap_debug_filename (filename0));
+      fputc ('\n', asm_out_file);
+    }
+#endif
 }
 
 /* A helper function for dwarf2out_finish called through
@@ -32034,27 +32058,6 @@ dwarf2out_finish (const char *filename)
   ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
   if (! output_asm_line_debug_info ())
     output_line_info (false);
-  else if (asm_outputs_debug_line_str ())
-    {
-      /* When gas outputs DWARF5 .debug_line[_str] then we have to
-	 tell it the comp_dir and main file name for the zero entry
-	 line table.  */
-      const char *comp_dir, *filename0;
-
-      comp_dir = comp_dir_string ();
-      if (comp_dir == NULL)
-	comp_dir = "";
-
-      filename0 = get_AT_string (comp_unit_die (), DW_AT_name);
-      if (filename0 == NULL)
-	filename0 = "";
-
-      fprintf (asm_out_file, "\t.file 0 ");
-      output_quoted_string (asm_out_file, remap_debug_filename (comp_dir));
-      fputc (' ', asm_out_file);
-      output_quoted_string (asm_out_file, remap_debug_filename (filename0));
-      fputc ('\n', asm_out_file);
-    }
 
   if (dwarf_split_debug_info && info_section_emitted)
     {


                 reply	other threads:[~2021-06-24 13:28 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=20210624132833.627CD388801B@sourceware.org \
    --to=ebotcazou@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).