diff mbox

[google/gcc-4_6] Fix to use correct form for DW_AT_low_pc in compile_unit DIE. (issue6298055)

Message ID 20120607062322.53DE7E152C@ccoutant.mtv.corp.google.com
State New
Headers show

Commit Message

Cary Coutant June 7, 2012, 6:23 a.m. UTC
This patch is for the google/gcc-4_6 branch.

In porting the earlier patch to use constant forms for DW_AT_high_pc,
the code in dwarf2out_finish was inadvertently changed to use an
indirect form for DW_AT_low_pc in the main compile_unit DIE.  This
patch adds the force_direct parameter used in other cases to
distinguish between DIEs in the .o (which should use the normal direct
form) and DIEs in the .dwo (which need to use DW_FORM_addr_index).

Tested with make check-gcc and validate-failures.py.


2012-06-06   Cary Coutant  <ccoutant@google.com>

	* gcc/dwarf2out.c (add_AT_low_high_pc): Add force_direct parameter;
	add DW_FORM_addr_index reference when splitting debug info.
	(gen_subprogram_die): Pass FALSE when calling add_AT_low_high_pc.
	(add_high_low_attributes): Likewise.
	(dwarf2out_finish): Pass TRUE when calling add_AT_low_high_pc.



--
This patch is available for review at http://codereview.appspot.com/6298055

Comments

Sterling Augustine June 7, 2012, 2:59 p.m. UTC | #1
On Wed, Jun 6, 2012 at 11:23 PM, Cary Coutant <ccoutant@google.com> wrote:
> This patch is for the google/gcc-4_6 branch.
>
> In porting the earlier patch to use constant forms for DW_AT_high_pc,
> the code in dwarf2out_finish was inadvertently changed to use an
> indirect form for DW_AT_low_pc in the main compile_unit DIE.  This
> patch adds the force_direct parameter used in other cases to
> distinguish between DIEs in the .o (which should use the normal direct
> form) and DIEs in the .dwo (which need to use DW_FORM_addr_index).
>
> Tested with make check-gcc and validate-failures.py.
>
>
> 2012-06-06   Cary Coutant  <ccoutant@google.com>
>
>        * gcc/dwarf2out.c (add_AT_low_high_pc): Add force_direct parameter;
>        add DW_FORM_addr_index reference when splitting debug info.
>        (gen_subprogram_die): Pass FALSE when calling add_AT_low_high_pc.
>        (add_high_low_attributes): Likewise.
>        (dwarf2out_finish): Pass TRUE when calling add_AT_low_high_pc.
>
>
> Index: gcc/dwarf2out.c
> ===================================================================
> --- gcc/dwarf2out.c     (revision 188293)
> +++ gcc/dwarf2out.c     (working copy)
> @@ -7568,22 +7568,30 @@ add_AT_data8 (dw_die_ref die, enum dwarf
>
>  /* Add DW_AT_low_pc and DW_AT_high_pc to a DIE.  */
>  static inline void
> -add_AT_low_high_pc (dw_die_ref die, const char *lbl_low, const char *lbl_high)
> +add_AT_low_high_pc (dw_die_ref die, const char *lbl_low, const char *lbl_high,
> +                   bool force_direct)
>  {
>   dw_attr_node attr;
>
>   attr.dw_attr = DW_AT_low_pc;
>   attr.dw_attr_val.val_class = dw_val_class_lbl_id;
> +  attr.dw_attr_val.val_index = -1U;
>   attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_low);
>   add_dwarf_attr (die, &attr);
> +  if (dwarf_split_debug_info && !force_direct)
> +    set_AT_index (get_AT (die, DW_AT_low_pc), add_addr_table_entry (&attr));
>
>   attr.dw_attr = DW_AT_high_pc;
>   if (dwarf_version < 4)
>     attr.dw_attr_val.val_class = dw_val_class_lbl_id;
>   else
>     attr.dw_attr_val.val_class = dw_val_class_high_pc;
> +  attr.dw_attr_val.val_index = -1U;
>   attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_high);
>   add_dwarf_attr (die, &attr);
> +  if (attr.dw_attr_val.val_class == dw_val_class_lbl_id
> +      && dwarf_split_debug_info && !force_direct)
> +    set_AT_index (get_AT (die, DW_AT_high_pc), add_addr_table_entry (&attr));
>  }
>
>  /* Hash and equality functions for debug_str_hash.  */
> @@ -19968,7 +19976,8 @@ gen_subprogram_die (tree decl, dw_die_re
>          if (fde->dw_fde_begin)
>            {
>              /* We have already generated the labels.  */
> -             add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end);
> +             add_AT_low_high_pc (subr_die, fde->dw_fde_begin,
> +                                 fde->dw_fde_end, false);
>            }
>          else
>            {
> @@ -19979,7 +19988,8 @@ gen_subprogram_die (tree decl, dw_die_re
>                                           FUNC_LABEL_ID (cfun));
>              ASM_GENERATE_INTERNAL_LABEL (label_id_high, FUNC_END_LABEL,
>                                           FUNC_LABEL_ID (cfun));
> -             add_AT_low_high_pc (subr_die, label_id_low, label_id_high);
> +             add_AT_low_high_pc (subr_die, label_id_low, label_id_high,
> +                                 false);
>            }
>
>  #if VMS_DEBUGGING_INFO
> @@ -20045,7 +20055,7 @@ gen_subprogram_die (tree decl, dw_die_re
>
>                  /* Do the 'primary' section.   */
>                  add_AT_low_high_pc (subr_die, fde->dw_fde_begin,
> -                                     fde->dw_fde_end);
> +                                     fde->dw_fde_end, false);
>
>                  /* Build a minimal DIE for the secondary section.  */
>                  seg_die = new_die (DW_TAG_subprogram,
> @@ -20070,13 +20080,14 @@ gen_subprogram_die (tree decl, dw_die_re
>
>                  name = concat ("__second_sect_of_", name, NULL);
>                  add_AT_low_high_pc (seg_die, fde->dw_fde_second_begin,
> -                                     fde->dw_fde_second_end);
> +                                     fde->dw_fde_second_end, false);
>                  add_name_attribute (seg_die, name);
>                  add_pubname_string (name, seg_die);
>                }
>            }
>          else
> -           add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end);
> +           add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end,
> +                               false);
>        }
>
>  #ifdef MIPS_DEBUGGING_INFO
> @@ -20610,7 +20621,7 @@ add_high_low_attributes (tree stmt, dw_d
>                                   BLOCK_NUMBER (stmt));
>       ASM_GENERATE_INTERNAL_LABEL (label_high, BLOCK_END_LABEL,
>                                   BLOCK_NUMBER (stmt));
> -      add_AT_low_high_pc (die, label, label_high);
> +      add_AT_low_high_pc (die, label, label_high, false);
>     }
>  }
>
> @@ -24510,7 +24521,7 @@ dwarf2out_finish (const char *filename)
>   if (!have_multiple_function_sections
>       || (dwarf_version < 3 && dwarf_strict))
>     add_AT_low_high_pc (main_comp_unit_die, text_section_label,
> -                       text_end_label);
> +                       text_end_label, true);
>   else
>     {
>       unsigned fde_idx = 0;
>
> --
> This patch is available for review at http://codereview.appspot.com/6298055

This is OK for Google 4.6

Sterling
diff mbox

Patch

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 188293)
+++ gcc/dwarf2out.c	(working copy)
@@ -7568,22 +7568,30 @@  add_AT_data8 (dw_die_ref die, enum dwarf
 
 /* Add DW_AT_low_pc and DW_AT_high_pc to a DIE.  */
 static inline void
-add_AT_low_high_pc (dw_die_ref die, const char *lbl_low, const char *lbl_high)
+add_AT_low_high_pc (dw_die_ref die, const char *lbl_low, const char *lbl_high,
+		    bool force_direct)
 {
   dw_attr_node attr;
 
   attr.dw_attr = DW_AT_low_pc;
   attr.dw_attr_val.val_class = dw_val_class_lbl_id;
+  attr.dw_attr_val.val_index = -1U;
   attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_low);
   add_dwarf_attr (die, &attr);
+  if (dwarf_split_debug_info && !force_direct)
+    set_AT_index (get_AT (die, DW_AT_low_pc), add_addr_table_entry (&attr));
 
   attr.dw_attr = DW_AT_high_pc;
   if (dwarf_version < 4)
     attr.dw_attr_val.val_class = dw_val_class_lbl_id;
   else
     attr.dw_attr_val.val_class = dw_val_class_high_pc;
+  attr.dw_attr_val.val_index = -1U;
   attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_high);
   add_dwarf_attr (die, &attr);
+  if (attr.dw_attr_val.val_class == dw_val_class_lbl_id
+      && dwarf_split_debug_info && !force_direct)
+    set_AT_index (get_AT (die, DW_AT_high_pc), add_addr_table_entry (&attr));
 }
 
 /* Hash and equality functions for debug_str_hash.  */
@@ -19968,7 +19976,8 @@  gen_subprogram_die (tree decl, dw_die_re
 	  if (fde->dw_fde_begin)
 	    {
 	      /* We have already generated the labels.  */
-	      add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end);
+	      add_AT_low_high_pc (subr_die, fde->dw_fde_begin,
+				  fde->dw_fde_end, false);
 	    }
 	  else
 	    {
@@ -19979,7 +19988,8 @@  gen_subprogram_die (tree decl, dw_die_re
 					   FUNC_LABEL_ID (cfun));
 	      ASM_GENERATE_INTERNAL_LABEL (label_id_high, FUNC_END_LABEL,
 					   FUNC_LABEL_ID (cfun));
-	      add_AT_low_high_pc (subr_die, label_id_low, label_id_high);
+	      add_AT_low_high_pc (subr_die, label_id_low, label_id_high,
+				  false);
 	    }
 
 #if VMS_DEBUGGING_INFO
@@ -20045,7 +20055,7 @@  gen_subprogram_die (tree decl, dw_die_re
 
 		  /* Do the 'primary' section.   */
 		  add_AT_low_high_pc (subr_die, fde->dw_fde_begin,
-				      fde->dw_fde_end);
+				      fde->dw_fde_end, false);
 
 		  /* Build a minimal DIE for the secondary section.  */
 		  seg_die = new_die (DW_TAG_subprogram,
@@ -20070,13 +20080,14 @@  gen_subprogram_die (tree decl, dw_die_re
 
 		  name = concat ("__second_sect_of_", name, NULL); 
 		  add_AT_low_high_pc (seg_die, fde->dw_fde_second_begin,
-				      fde->dw_fde_second_end);
+				      fde->dw_fde_second_end, false);
 		  add_name_attribute (seg_die, name);
 		  add_pubname_string (name, seg_die);
 		}
 	    }
 	  else
-	    add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end);
+	    add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end,
+				false);
 	}
 
 #ifdef MIPS_DEBUGGING_INFO
@@ -20610,7 +20621,7 @@  add_high_low_attributes (tree stmt, dw_d
 				   BLOCK_NUMBER (stmt));
       ASM_GENERATE_INTERNAL_LABEL (label_high, BLOCK_END_LABEL,
 				   BLOCK_NUMBER (stmt));
-      add_AT_low_high_pc (die, label, label_high);
+      add_AT_low_high_pc (die, label, label_high, false);
     }
 }
 
@@ -24510,7 +24521,7 @@  dwarf2out_finish (const char *filename)
   if (!have_multiple_function_sections 
       || (dwarf_version < 3 && dwarf_strict))
     add_AT_low_high_pc (main_comp_unit_die, text_section_label,
-			text_end_label);
+			text_end_label, true);
   else
     {
       unsigned fde_idx = 0;