https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85339

            Bug ID: 85339
           Summary: [8 Regression] With early LTO debug the early DWARF
                    misses line-info
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Keywords: lto, wrong-debug
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org, marxin at gcc dot gnu.org
  Target Milestone: ---

dwz rightfully complains about bogus DW_AT_decl_file (and also _line/_column?)
beause the early debug doesn't contain .debug_line.  split-dwarf adds a
DW_AT_stmt_list pointing to the main files line tables but obviously
the early debug dwarf needs to stand on its own.

I'm not sure how to access line-info from gdb say for

 <1><19>: Abbrev Number: 2 (DW_TAG_structure_type)
    <1a>   DW_AT_name        : X
    <1c>   DW_AT_byte_size   : 8
    <1d>   DW_AT_decl_file   : 1
    <1e>   DW_AT_decl_line   : 1
    <1f>   DW_AT_decl_column : 8
    <20>   DW_AT_sibling     : <0x3b>
 <2><24>: Abbrev Number: 3 (DW_TAG_member)
    <25>   DW_AT_name        : a
    <27>   DW_AT_decl_file   : 1
    <28>   DW_AT_decl_line   : 1
    <29>   DW_AT_decl_column : 16
    <2a>   DW_AT_type        : <0x3b>
    <2e>   DW_AT_data_member_location: 0

maybe gdb just ignores that info (why do we output it then?).  Breakpoints
seem to work just fine beause the LTRANS unit will have a proper .debug_line.
So I'm really not sure what consumer uses the symbolic location attributes
on decls and types?

Note we already output .debug_line into the early debug at -g3 so the fix
might be as simple as enabling that also for -g.

Thus testing the following:

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c     (revision 259308)
+++ gcc/dwarf2out.c     (working copy)
@@ -31681,6 +31682,7 @@ static void
 dwarf2out_early_finish (const char *filename)
 {
   set_early_dwarf s;
+  char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES];

   /* PCH might result in DW_AT_producer string being restored from the
      header compilation, so always fill it with empty string initially
@@ -31829,6 +31835,16 @@ dwarf2out_early_finish (const char *file
        ctnode != NULL; ctnode = ctnode->next)
     add_sibling_attributes (ctnode->root_die);

+  /* AIX Assembler inserts the length, so adjust the reference to match the
+     offset expected by debuggers.  */
+  strcpy (dl_section_ref, debug_skeleton_line_section_label);
+  if (XCOFF_DEBUGGING_INFO)
+    strcat (dl_section_ref, DWARF_INITIAL_LENGTH_SIZE_STR);
+
+  if (debug_info_level >= DINFO_LEVEL_TERSE)
+    add_AT_lineptr (comp_unit_die (), DW_AT_stmt_list,
+                   dl_section_ref);
+
   if (have_macinfo)
     add_AT_macptr (comp_unit_die (), DEBUG_MACRO_ATTRIBUTE,
                   macinfo_section_label);
@@ -31898,11 +31914,6 @@ dwarf2out_early_finish (const char *file
       output_macinfo (debug_skeleton_line_section_label, true);
       dw2_asm_output_data (1, 0, "End compilation unit");

-      /* Emit a skeleton debug_line section.  */
-      switch_to_section (debug_skeleton_line_section);
-      ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_line_section_label);
-      output_line_info (true);
-
       if (flag_fat_lto_objects)
        {
          vec_free (macinfo_table);
@@ -31910,6 +31921,10 @@ dwarf2out_early_finish (const char *file
        }
     }

+  /* Emit a skeleton debug_line section.  */
+  switch_to_section (debug_skeleton_line_section);
+  ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_line_section_label);
+  output_line_info (true);

   /* If we emitted any indirect strings, output the string table too.  */
   if (debug_str_hash || skeleton_debug_str_hash)

Reply via email to