public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Variable tracking (location lists support) - part 2
@ 2004-02-02 20:37 Josef Zlomek
  2004-02-06  3:34 ` Roger Sayle
                   ` (2 more replies)
  0 siblings, 3 replies; 44+ messages in thread
From: Josef Zlomek @ 2004-02-02 20:37 UTC (permalink / raw)
  To: gcc-patches

Hello,

this patch adds location list support to dwarf2out.c.
This generates the location list debug info from the NOTE_INSN_VAR_LOCATION
notes produces by the first patch of variable tracking.

Bootstrapped/regtested x86-64 (standalone and together with the first part).

Josef

2004-02-02  Daniel Berlin <dberlin@dberlin.org>
            Josef Zlomek  <zlomekj@suse.cz>

        * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
        at the beginning of function, call dwarf2out_var_location for
        NOTE_INSN_VAR_LOCATION note.
	(struct var_loc_node, struct var_loc_list_def, loclabel_num,
	decl_loc_table, decl_loc_table_allocated, decl_loc_table_in_use,
	DECL_LOC_TABLE_INCREMENT): New.
	(lookup_decl_loc): New function.
	(add_var_loc_to_decl): New function.
	(based_loc_descr): Added parameter can_use_fbreg, DW_OP_fbreg is used
	only if can_use_fbreg.
	(mem_loc_descriptor): Added parameter can_use_fbreg, pass it to other
	functions.
	(loc_descriptor): Likewise. Process VAR_LOCATION.
	(concat_loc_descriptor): Call loc_descriptor with can_use_fbreg == true.
	(loc_descriptor_from_tree): Call mem_loc_descriptor with
	can_use_fbreg == true.
	(add_location_or_const_value_attribute): Added parameter enum
	dwarf_attribute attr, generate attribute ATTR.  Create the location list.
	(add_bound_info): Call loc_descriptor with can_use_fbreg == true.
	(gen_formal_parameter_die): Call add_location_or_const_value_attribute
	with attr == DW_AT_location.
	(gen_subprogram_die): Generate the location list for DW_AT_frame_base
	if frame_base_decl is defined and has a location list.
	(gen_variable_die): Call add_location_or_const_value_attribute with
	attr == DW_AT_location.
        (dwarf2out_var_location): New function.
        (dwarf2out_begin_function): New function.
	(dwarf2out_init): Create decl_loc_table and initialize
	decl_loc_table_allocated and decl_loc_table_in_use.

*** vt-main-part1/gcc/dwarf2out.c	2004-02-02 07:56:34.000000000 +0100
--- vt-main-part2/gcc/dwarf2out.c	2004-02-02 07:56:23.000000000 +0100
*************** static bool dwarf2out_ignore_block (tree
*** 3251,3256 ****
--- 3251,3258 ----
  static void dwarf2out_global_decl (tree);
  static void dwarf2out_imported_module_or_decl (tree, tree);
  static void dwarf2out_abstract_function (tree);
+ static void dwarf2out_var_location (rtx);
+ static void dwarf2out_begin_function (tree);
  
  /* The debug hooks structure.  */
  
*************** const struct gcc_debug_hooks dwarf2_debu
*** 3269,3275 ****
    dwarf2out_begin_prologue,
    debug_nothing_int_charstar,	/* end_prologue */
    dwarf2out_end_epilogue,
!   debug_nothing_tree,		/* begin_function */
    debug_nothing_int,		/* end_function */
    dwarf2out_decl,		/* function_decl */
    dwarf2out_global_decl,
--- 3271,3277 ----
    dwarf2out_begin_prologue,
    debug_nothing_int_charstar,	/* end_prologue */
    dwarf2out_end_epilogue,
!   dwarf2out_begin_function,
    debug_nothing_int,		/* end_function */
    dwarf2out_decl,		/* function_decl */
    dwarf2out_global_decl,
*************** const struct gcc_debug_hooks dwarf2_debu
*** 3281,3287 ****
    dwarf2out_abstract_function,	/* outlining_inline_function */
    debug_nothing_rtx,		/* label */
    debug_nothing_int,		/* handle_pch */
!   debug_nothing_rtx		/* var_location */
  };
  #endif
  \f
--- 3283,3289 ----
    dwarf2out_abstract_function,	/* outlining_inline_function */
    debug_nothing_rtx,		/* label */
    debug_nothing_int,		/* handle_pch */
!   dwarf2out_var_location
  };
  #endif
  \f
*************** static GTY(()) size_t file_table_last_lo
*** 3477,3482 ****
--- 3479,3512 ----
     The key is a DECL_UID() which is a unique number identifying each decl.  */
  static GTY ((param_is (struct die_struct))) htab_t decl_die_table;
  
+ /* Node of the variable location list.  */
+ struct var_loc_node GTY ((chain_next ("%h.next")))
+ {
+   rtx GTY (()) var_loc_note;
+   const char * GTY (()) label;
+   struct var_loc_node * GTY (()) next;
+ };
+ 
+ /* Variable location list.  */
+ struct var_loc_list_def GTY (())
+ {
+   struct var_loc_node * GTY (()) first;
+ 
+   /* Do not mark the last element of the chained list because
+      it is marked through the chain.  */
+   struct var_loc_node * GTY ((skip ("%h"))) last;
+ 
+   /* DECL_UID of the variable decl.  */
+   unsigned int decl_id;
+ };
+ typedef struct var_loc_list_def var_loc_list;
+ 
+ /* Unique label counter.  */
+ static unsigned int loclabel_num = 0;
+ 
+ /* Table of decl location linked lists.  */
+ static GTY ((param_is (var_loc_list))) htab_t decl_loc_table;
+ 
  /* A pointer to the base of a list of references to DIE's that
     are uniquely identified by their tag, presence/absence of
     children DIE's, and list of attribute/value pairs.  */
*************** static void equate_type_number_to_die (t
*** 3651,3657 ****
--- 3681,3691 ----
  static hashval_t decl_die_table_hash (const void *);
  static int decl_die_table_eq (const void *, const void *);
  static dw_die_ref lookup_decl_die (tree);
+ static hashval_t decl_loc_table_hash (const void *);
+ static int decl_loc_table_eq (const void *, const void *);
+ static var_loc_list *lookup_decl_loc (tree);
  static void equate_decl_number_to_die (tree, dw_die_ref);
+ static void add_var_loc_to_decl (tree, struct var_loc_node *);
  static void print_spaces (FILE *);
  static void print_die (dw_die_ref, FILE *);
  static void print_dwarf_line_table (FILE *);
*************** static dw_loc_descr_ref reg_loc_descript
*** 3717,3727 ****
  static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int);
  static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx);
  static dw_loc_descr_ref int_loc_descriptor (HOST_WIDE_INT);
! static dw_loc_descr_ref based_loc_descr (unsigned, HOST_WIDE_INT);
  static int is_based_loc (rtx);
! static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode);
  static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx);
! static dw_loc_descr_ref loc_descriptor (rtx);
  static dw_loc_descr_ref loc_descriptor_from_tree (tree, int);
  static HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
  static tree field_type (tree);
--- 3751,3761 ----
  static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int);
  static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx);
  static dw_loc_descr_ref int_loc_descriptor (HOST_WIDE_INT);
! static dw_loc_descr_ref based_loc_descr (unsigned, HOST_WIDE_INT, bool);
  static int is_based_loc (rtx);
! static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode, bool);
  static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx);
! static dw_loc_descr_ref loc_descriptor (rtx, bool);
  static dw_loc_descr_ref loc_descriptor_from_tree (tree, int);
  static HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
  static tree field_type (tree);
*************** static void add_AT_location_description	
*** 3734,3740 ****
  static void add_data_member_location_attribute (dw_die_ref, tree);
  static void add_const_value_attribute (dw_die_ref, rtx);
  static rtx rtl_for_decl_location (tree);
! static void add_location_or_const_value_attribute (dw_die_ref, tree);
  static void tree_add_const_value_attribute (dw_die_ref, tree);
  static void add_name_attribute (dw_die_ref, const char *);
  static void add_comp_dir_attribute (dw_die_ref);
--- 3768,3775 ----
  static void add_data_member_location_attribute (dw_die_ref, tree);
  static void add_const_value_attribute (dw_die_ref, rtx);
  static rtx rtl_for_decl_location (tree);
! static void add_location_or_const_value_attribute (dw_die_ref, tree,
! 						   enum dwarf_attribute);
  static void tree_add_const_value_attribute (dw_die_ref, tree);
  static void add_name_attribute (dw_die_ref, const char *);
  static void add_comp_dir_attribute (dw_die_ref);
*************** lookup_decl_die (tree decl)
*** 5229,5234 ****
--- 5264,5291 ----
    return htab_find_with_hash (decl_die_table, decl, DECL_UID (decl));
  }
  
+ /* Returns a hash value for X (which really is a var_loc_list).  */
+ 
+ static hashval_t
+ decl_loc_table_hash (const void *x)
+ {
+   return (hashval_t) ((const var_loc_list *) x)->decl_id;
+ }
+ 
+ static int
+ decl_loc_table_eq (const void *x, const void *y)
+ {
+   return (((const var_loc_list *) x)->decl_id == DECL_UID ((const tree) y));
+ }
+ 
+ /* Return the var_loc list associated with a given declaration.  */
+ 
+ static inline var_loc_list *
+ lookup_decl_loc (tree decl)
+ {
+   return htab_find_with_hash (decl_loc_table, decl, DECL_UID (decl));
+ }
+ 
  /* Equate a DIE to a particular declaration.  */
  
  static void
*************** equate_decl_number_to_die (tree decl, dw
*** 5241,5246 ****
--- 5298,5342 ----
    *slot = decl_die;
    decl_die->decl_id = decl_id;
  }
+ 
+ /* Add a variable location node to the linked list for DECL.  */
+ 
+ static void
+ add_var_loc_to_decl (tree decl, struct var_loc_node *loc)
+ {
+   unsigned int decl_id = DECL_UID (decl);
+   var_loc_list *temp;
+   void **slot;
+ 
+   slot = htab_find_slot_with_hash (decl_loc_table, decl, decl_id, INSERT);
+   if (*slot == NULL)
+     {
+       temp = ggc_alloc_cleared (sizeof (var_loc_list));
+       temp->decl_id = decl_id;
+       *slot = temp;
+     }
+   else
+     temp = *slot;
+ 
+   if (temp->last)
+     {
+       /* If the current location is the same as the end of the list,
+ 	 we have nothing to do.  */
+       if (!rtx_equal_p (NOTE_VAR_LOCATION_LOC (temp->last->var_loc_note),
+ 			NOTE_VAR_LOCATION_LOC (loc->var_loc_note)))
+ 	{
+ 	  /* Add LOC to the end of list and update LAST.  */
+ 	  temp->last->next = loc;
+ 	  temp->last = loc;
+ 	}
+     }
+   /* Do not add empty location to the beginning of the list.  */
+   else if (NOTE_VAR_LOCATION_LOC (loc->var_loc_note) != NULL_RTX)
+     {
+       temp->first = loc;
+       temp->last = loc;
+     }
+ }
  \f
  /* Keep track of the number of spaces used to indent the
     output of the debugging routines that print the structure of
*************** int_loc_descriptor (HOST_WIDE_INT i)
*** 8193,8199 ****
  /* Return a location descriptor that designates a base+offset location.  */
  
  static dw_loc_descr_ref
! based_loc_descr (unsigned int reg, HOST_WIDE_INT offset)
  {
    dw_loc_descr_ref loc_result;
    /* For the "frame base", we use the frame pointer or stack pointer
--- 8300,8306 ----
  /* Return a location descriptor that designates a base+offset location.  */
  
  static dw_loc_descr_ref
! based_loc_descr (unsigned int reg, HOST_WIDE_INT offset, bool can_use_fbreg)
  {
    dw_loc_descr_ref loc_result;
    /* For the "frame base", we use the frame pointer or stack pointer
*************** based_loc_descr (unsigned int reg, HOST_
*** 8203,8209 ****
  					 ? HARD_FRAME_POINTER_REGNUM
  					 : STACK_POINTER_REGNUM);
  
!   if (reg == fp_reg)
      loc_result = new_loc_descr (DW_OP_fbreg, offset, 0);
    else if (reg <= 31)
      loc_result = new_loc_descr (DW_OP_breg0 + reg, offset, 0);
--- 8310,8316 ----
  					 ? HARD_FRAME_POINTER_REGNUM
  					 : STACK_POINTER_REGNUM);
  
!   if (reg == fp_reg && can_use_fbreg)
      loc_result = new_loc_descr (DW_OP_fbreg, offset, 0);
    else if (reg <= 31)
      loc_result = new_loc_descr (DW_OP_breg0 + reg, offset, 0);
*************** is_based_loc (rtx rtl)
*** 8237,8246 ****
     MODE is the mode of the memory reference, needed to handle some
     autoincrement addressing modes.
  
     Return 0 if we can't represent the location.  */
  
  static dw_loc_descr_ref
! mem_loc_descriptor (rtx rtl, enum machine_mode mode)
  {
    dw_loc_descr_ref mem_loc_result = NULL;
  
--- 8344,8358 ----
     MODE is the mode of the memory reference, needed to handle some
     autoincrement addressing modes.
  
+    CAN_USE_FBREG is a flag whether we can use DW_AT_frame_base in the location
+    list for RTL. We can't use it when we are emitting location list for
+    virtual variable frame_base_decl (i.e. a location list for DW_AT_frame_base)
+    which describes how frame base changes when !frame_pointer_needed.
+ 
     Return 0 if we can't represent the location.  */
  
  static dw_loc_descr_ref
! mem_loc_descriptor (rtx rtl, enum machine_mode mode, bool can_use_fbreg)
  {
    dw_loc_descr_ref mem_loc_result = NULL;
  
*************** mem_loc_descriptor (rtx rtl, enum machin
*** 8286,8296 ****
  	 memory) so DWARF consumers need to be aware of the subtle
  	 distinction between OP_REG and OP_BASEREG.  */
        if (REGNO (rtl) < FIRST_PSEUDO_REGISTER)
! 	mem_loc_result = based_loc_descr (reg_number (rtl), 0);
        break;
  
      case MEM:
!       mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
        if (mem_loc_result != 0)
  	add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
        break;
--- 8398,8409 ----
  	 memory) so DWARF consumers need to be aware of the subtle
  	 distinction between OP_REG and OP_BASEREG.  */
        if (REGNO (rtl) < FIRST_PSEUDO_REGISTER)
! 	mem_loc_result = based_loc_descr (reg_number (rtl), 0, can_use_fbreg);
        break;
  
      case MEM:
!       mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl),
! 					   can_use_fbreg);
        if (mem_loc_result != 0)
  	add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
        break;
*************** mem_loc_descriptor (rtx rtl, enum machin
*** 8357,8366 ****
      plus:
        if (is_based_loc (rtl))
  	mem_loc_result = based_loc_descr (reg_number (XEXP (rtl, 0)),
! 					  INTVAL (XEXP (rtl, 1)));
        else
  	{
! 	  mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode);
  	  if (mem_loc_result == 0)
  	    break;
  
--- 8470,8481 ----
      plus:
        if (is_based_loc (rtl))
  	mem_loc_result = based_loc_descr (reg_number (XEXP (rtl, 0)),
! 					  INTVAL (XEXP (rtl, 1)),
! 					  can_use_fbreg);
        else
  	{
! 	  mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode,
! 					       can_use_fbreg);
  	  if (mem_loc_result == 0)
  	    break;
  
*************** mem_loc_descriptor (rtx rtl, enum machin
*** 8372,8378 ****
  	  else
  	    {
  	      add_loc_descr (&mem_loc_result,
! 			     mem_loc_descriptor (XEXP (rtl, 1), mode));
  	      add_loc_descr (&mem_loc_result,
  			     new_loc_descr (DW_OP_plus, 0, 0));
  	    }
--- 8487,8494 ----
  	  else
  	    {
  	      add_loc_descr (&mem_loc_result,
! 			     mem_loc_descriptor (XEXP (rtl, 1), mode,
! 						 can_use_fbreg));
  	      add_loc_descr (&mem_loc_result,
  			     new_loc_descr (DW_OP_plus, 0, 0));
  	    }
*************** mem_loc_descriptor (rtx rtl, enum machin
*** 8383,8390 ****
        {
  	/* If a pseudo-reg is optimized away, it is possible for it to
  	   be replaced with a MEM containing a multiply.  */
! 	dw_loc_descr_ref op0 = mem_loc_descriptor (XEXP (rtl, 0), mode);
! 	dw_loc_descr_ref op1 = mem_loc_descriptor (XEXP (rtl, 1), mode);
  
  	if (op0 == 0 || op1 == 0)
  	  break;
--- 8499,8508 ----
        {
  	/* If a pseudo-reg is optimized away, it is possible for it to
  	   be replaced with a MEM containing a multiply.  */
! 	dw_loc_descr_ref op0 = mem_loc_descriptor (XEXP (rtl, 0), mode,
! 						   can_use_fbreg);
! 	dw_loc_descr_ref op1 = mem_loc_descriptor (XEXP (rtl, 1), mode,
! 						   can_use_fbreg);
  
  	if (op0 == 0 || op1 == 0)
  	  break;
*************** mem_loc_descriptor (rtx rtl, enum machin
*** 8403,8413 ****
        /* If this is a MEM, return its address.  Otherwise, we can't
  	 represent this.  */
        if (GET_CODE (XEXP (rtl, 0)) == MEM)
! 	return mem_loc_descriptor (XEXP (XEXP (rtl, 0), 0), mode);
        else
  	return 0;
  
      default:
        abort ();
      }
  
--- 8521,8534 ----
        /* If this is a MEM, return its address.  Otherwise, we can't
  	 represent this.  */
        if (GET_CODE (XEXP (rtl, 0)) == MEM)
! 	return mem_loc_descriptor (XEXP (XEXP (rtl, 0), 0), mode,
! 				   can_use_fbreg);
        else
  	return 0;
  
      default:
+       fprintf (stderr, "\nInvalid mem_loc_descriptor RTL:\n");
+       print_rtl (stderr, rtl);
        abort ();
      }
  
*************** static dw_loc_descr_ref
*** 8421,8428 ****
  concat_loc_descriptor (rtx x0, rtx x1)
  {
    dw_loc_descr_ref cc_loc_result = NULL;
!   dw_loc_descr_ref x0_ref = loc_descriptor (x0);
!   dw_loc_descr_ref x1_ref = loc_descriptor (x1);
  
    if (x0_ref == 0 || x1_ref == 0)
      return 0;
--- 8542,8549 ----
  concat_loc_descriptor (rtx x0, rtx x1)
  {
    dw_loc_descr_ref cc_loc_result = NULL;
!   dw_loc_descr_ref x0_ref = loc_descriptor (x0, true);
!   dw_loc_descr_ref x1_ref = loc_descriptor (x1, true);
  
    if (x0_ref == 0 || x1_ref == 0)
      return 0;
*************** concat_loc_descriptor (rtx x0, rtx x1)
*** 8449,8455 ****
     If we don't know how to describe it, return 0.  */
  
  static dw_loc_descr_ref
! loc_descriptor (rtx rtl)
  {
    dw_loc_descr_ref loc_result = NULL;
  
--- 8570,8576 ----
     If we don't know how to describe it, return 0.  */
  
  static dw_loc_descr_ref
! loc_descriptor (rtx rtl, bool can_use_fbreg)
  {
    dw_loc_descr_ref loc_result = NULL;
  
*************** loc_descriptor (rtx rtl)
*** 8470,8482 ****
        break;
  
      case MEM:
!       loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
        break;
  
      case CONCAT:
        loc_result = concat_loc_descriptor (XEXP (rtl, 0), XEXP (rtl, 1));
        break;
  
      default:
        abort ();
      }
--- 8591,8639 ----
        break;
  
      case MEM:
!       loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl),
! 				       can_use_fbreg);
        break;
  
      case CONCAT:
        loc_result = concat_loc_descriptor (XEXP (rtl, 0), XEXP (rtl, 1));
        break;
  
+     case VAR_LOCATION:
+       /* Single part.  */
+       if (GET_CODE (XEXP (rtl, 1)) != PARALLEL)
+ 	{
+ 	  loc_result = loc_descriptor (XEXP (XEXP (rtl, 1), 0), can_use_fbreg);
+ 	}
+       /* Multiple parts.  */
+       else
+ 	{
+ 	  rtvec par_elems = XVEC (XEXP (rtl, 1), 0);
+ 	  int num_elem = GET_NUM_ELEM (par_elems);
+ 	  enum machine_mode mode;
+ 	  int i;
+ 
+ 	  /* Create the first one, so we have something to add to.  */
+ 	  loc_result = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0),
+ 				       can_use_fbreg);
+ 	  mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0));
+ 	  add_loc_descr (&loc_result,
+ 			 new_loc_descr (DW_OP_piece, GET_MODE_SIZE (mode), 0));
+ 	  for (i = 1; i < num_elem; i++)
+ 	    {
+ 	      dw_loc_descr_ref temp;
+ 
+ 	      temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0),
+ 				     can_use_fbreg);
+ 	      add_loc_descr (&loc_result, temp);
+ 	      mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0));
+ 	      add_loc_descr (&loc_result,
+ 			     new_loc_descr (DW_OP_piece,
+ 					    GET_MODE_SIZE (mode), 0));
+ 	    }
+ 	}
+       break;
+ 
      default:
        abort ();
      }
*************** loc_descriptor_from_tree (tree loc, int 
*** 8592,8598 ****
  		rtl = XEXP (rtl, 0);
  	      }
  
! 	    ret = mem_loc_descriptor (rtl, mode);
  	  }
        }
        break;
--- 8749,8755 ----
  		rtl = XEXP (rtl, 0);
  	      }
  
! 	    ret = mem_loc_descriptor (rtl, mode, true);
  	  }
        }
        break;
*************** loc_descriptor_from_tree (tree loc, int 
*** 8676,8682 ****
  	rtl = (*targetm.delegitimize_address) (rtl);
  
  	indirect_p = 1;
! 	ret = mem_loc_descriptor (rtl, mode);
  	break;
        }
  
--- 8833,8839 ----
  	rtl = (*targetm.delegitimize_address) (rtl);
  
  	indirect_p = 1;
! 	ret = mem_loc_descriptor (rtl, mode, true);
  	break;
        }
  
*************** rtl_for_decl_location (tree decl)
*** 9471,9486 ****
     function call evaluates to a compile-time constant address.  */
  
  static void
! add_location_or_const_value_attribute (dw_die_ref die, tree decl)
  {
    rtx rtl;
    dw_loc_descr_ref descr;
  
    if (TREE_CODE (decl) == ERROR_MARK)
      return;
    else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
      abort ();
  
    rtl = rtl_for_decl_location (decl);
    if (rtl == NULL_RTX)
      return;
--- 9628,9737 ----
     function call evaluates to a compile-time constant address.  */
  
  static void
! add_location_or_const_value_attribute (dw_die_ref die, tree decl,
! 				       enum dwarf_attribute attr)
  {
    rtx rtl;
    dw_loc_descr_ref descr;
+   var_loc_list *loc_list;
  
    if (TREE_CODE (decl) == ERROR_MARK)
      return;
    else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
      abort ();
  
+   /* See if we possibly have multiple locations for this variable.  */
+   loc_list = lookup_decl_loc (decl);
+ 
+   /* If it truly has multiple locations, the first and last node will
+      differ.  */
+   if (loc_list && loc_list->first != loc_list->last)
+     {
+       const char *secname;
+       const char *endname;
+       dw_loc_list_ref list;
+       rtx varloc;
+       struct var_loc_node *node;
+ 
+       /* We need to figure out what section we should use as the base
+ 	 for the address ranges where a given location is valid.
+ 	 1. If this particular DECL has a section associated with it,
+ 	 use that.
+ 	 2. If this function has a section associated with it, use
+ 	 that.
+ 	 3. Otherwise, use the text section.
+ 	 XXX: If you split a variable across multiple sections, this
+ 	 won't notice.  */
+ 
+       if (DECL_SECTION_NAME (decl))
+ 	{
+ 	  tree sectree = DECL_SECTION_NAME (decl);
+ 	  secname = TREE_STRING_POINTER (sectree);
+ 	}
+       else if (current_function_decl
+ 	       && DECL_SECTION_NAME (current_function_decl))
+ 	{
+ 	  tree sectree = DECL_SECTION_NAME (current_function_decl);
+ 	  secname = TREE_STRING_POINTER (sectree);
+ 	}
+       else
+ 	secname = TEXT_SECTION_NAME;
+ 
+       /* Now that we know what section we are using for a base,
+          actually construct the list of locations.
+ 	 The first location information is what is passed to the
+ 	 function that creates the location list, and the remaining
+ 	 locations just get added on to that list.
+ 	 Note that we only know the start address for a location
+ 	 (IE location changes), so to build the range, we use
+ 	 the range [current location start, next location start].
+ 	 This means we have to special case the last node, and generate
+ 	 a range of [last location start, end of function label].  */
+ 
+       node = loc_list->first;
+       varloc = NOTE_VAR_LOCATION (node->var_loc_note);
+       list = new_loc_list (loc_descriptor (varloc, attr != DW_AT_frame_base),
+ 			   node->label, node->next->label, secname, 1);
+       node = node->next;
+ 
+       for (; node->next; node = node->next)
+ 	if (NOTE_VAR_LOCATION_LOC (node->var_loc_note) != NULL_RTX)
+ 	  {
+ 	    /* The variable has a location between NODE->LABEL and
+ 	       NODE->NEXT->LABEL.  */
+ 	    varloc = NOTE_VAR_LOCATION (node->var_loc_note);
+ 	    add_loc_descr_to_loc_list (&list,
+ 				       loc_descriptor (varloc,
+ 						       attr != DW_AT_frame_base),
+ 				       node->label, node->next->label, secname);
+ 	  }
+ 
+       /* If the variable has a location at the last label
+ 	 it keeps its location until the end of function.  */
+       if (NOTE_VAR_LOCATION_LOC (node->var_loc_note) != NULL_RTX)
+ 	{
+ 	  char label_id[MAX_ARTIFICIAL_LABEL_BYTES];
+ 
+ 	  varloc = NOTE_VAR_LOCATION (node->var_loc_note);
+ 	  if (!current_function_decl)
+ 	    endname = text_end_label;
+ 	  else
+ 	    {
+ 	      ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL,
+ 					   current_function_funcdef_no);
+ 	      endname = ggc_strdup (label_id);
+ 	    }
+ 	  add_loc_descr_to_loc_list (&list,
+ 				     loc_descriptor (varloc,
+ 						     attr != DW_AT_frame_base),
+ 				     node->label, endname, secname);
+ 	}
+ 
+       /* Finally, add the location list to the DIE, and we are done.  */
+       add_AT_loc_list (die, attr, list);
+       return;
+     }
+ 
    rtl = rtl_for_decl_location (decl);
    if (rtl == NULL_RTX)
      return;
*************** add_location_or_const_value_attribute (d
*** 9517,9525 ****
  	case REG:
  	case SUBREG:
  	case CONCAT:
! 	  descr = loc_descriptor (rtl);
  	}
!       add_AT_location_description (die, DW_AT_location, descr);
        break;
  
      case PARALLEL:
--- 9768,9776 ----
  	case REG:
  	case SUBREG:
  	case CONCAT:
! 	  descr = loc_descriptor (rtl, true);
  	}
!       add_AT_location_description (die, attr, descr);
        break;
  
      case PARALLEL:
*************** add_location_or_const_value_attribute (d
*** 9530,9536 ****
  	int i;
  
  	/* Create the first one, so we have something to add to.  */
! 	descr = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0));
  	mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0));
  	add_loc_descr (&descr,
  		       new_loc_descr (DW_OP_piece, GET_MODE_SIZE (mode), 0));
--- 9781,9787 ----
  	int i;
  
  	/* Create the first one, so we have something to add to.  */
! 	descr = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0), true);
  	mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0));
  	add_loc_descr (&descr,
  		       new_loc_descr (DW_OP_piece, GET_MODE_SIZE (mode), 0));
*************** add_location_or_const_value_attribute (d
*** 9538,9544 ****
  	  {
  	    dw_loc_descr_ref temp;
  
! 	    temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0));
  	    add_loc_descr (&descr, temp);
  	    mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0));
  	    add_loc_descr (&descr,
--- 9789,9795 ----
  	  {
  	    dw_loc_descr_ref temp;
  
! 	    temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0), true);
  	    add_loc_descr (&descr, temp);
  	    mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0));
  	    add_loc_descr (&descr,
*************** add_bound_info (dw_die_ref subrange_die,
*** 9684,9690 ****
  	  add_AT_flag (decl_die, DW_AT_artificial, 1);
  	  add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
  	  add_AT_location_description (decl_die, DW_AT_location,
! 				       loc_descriptor (loc));
  	  add_AT_die_ref (subrange_die, bound_attr, decl_die);
  	}
  
--- 9935,9941 ----
  	  add_AT_flag (decl_die, DW_AT_artificial, 1);
  	  add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
  	  add_AT_location_description (decl_die, DW_AT_location,
! 				       loc_descriptor (loc, true));
  	  add_AT_die_ref (subrange_die, bound_attr, decl_die);
  	}
  
*************** gen_formal_parameter_die (tree node, dw_
*** 10507,10513 ****
  
        equate_decl_number_to_die (node, parm_die);
        if (! DECL_ABSTRACT (node))
! 	add_location_or_const_value_attribute (parm_die, node);
  
        break;
  
--- 10758,10764 ----
  
        equate_decl_number_to_die (node, parm_die);
        if (! DECL_ABSTRACT (node))
! 	add_location_or_const_value_attribute (parm_die, node, DW_AT_location);
  
        break;
  
*************** gen_subprogram_die (tree decl, dw_die_re
*** 10841,10849 ****
        /* Define the "frame base" location for this routine.  We use the
  	 frame pointer or stack pointer registers, since the RTL for local
  	 variables is relative to one of them.  */
!       fp_reg
! 	= frame_pointer_needed ? hard_frame_pointer_rtx : stack_pointer_rtx;
!       add_AT_loc (subr_die, DW_AT_frame_base, reg_loc_descriptor (fp_reg));
  
  #if 0
        /* ??? This fails for nested inline functions, because context_display
--- 11092,11108 ----
        /* Define the "frame base" location for this routine.  We use the
  	 frame pointer or stack pointer registers, since the RTL for local
  	 variables is relative to one of them.  */
!       if (frame_base_decl && lookup_decl_loc (frame_base_decl) != NULL)
! 	{
! 	  add_location_or_const_value_attribute (subr_die, frame_base_decl,
! 						 DW_AT_frame_base);
! 	}
!       else
! 	{
! 	  fp_reg
! 	    = frame_pointer_needed ? hard_frame_pointer_rtx : stack_pointer_rtx;
! 	  add_AT_loc (subr_die, DW_AT_frame_base, reg_loc_descriptor (fp_reg));
! 	}
  
  #if 0
        /* ??? This fails for nested inline functions, because context_display
*************** gen_variable_die (tree decl, dw_die_ref 
*** 11012,11018 ****
  
    if (! declaration && ! DECL_ABSTRACT (decl))
      {
!       add_location_or_const_value_attribute (var_die, decl);
        add_pubname (decl, var_die);
      }
    else
--- 11271,11277 ----
  
    if (! declaration && ! DECL_ABSTRACT (decl))
      {
!       add_location_or_const_value_attribute (var_die, decl, DW_AT_location);
        add_pubname (decl, var_die);
      }
    else
*************** init_file_table (void)
*** 12531,12536 ****
--- 12790,12850 ----
    file_table_last_lookup_index = 0;
  }
  
+ /* Called by the final INSN scan whenever we see a var location.  We
+    use it to drop labels in the right places, and throw the location in
+    our lookup table.  */
+ 
+ static void
+ dwarf2out_var_location (rtx loc_note)
+ {
+   char loclabel[MAX_ARTIFICIAL_LABEL_BYTES];
+   struct var_loc_node *newloc;
+   rtx prev_insn;
+   static rtx last_insn;
+   static const char *last_label;
+ 
+   if (!DECL_P (NOTE_VAR_LOCATION_DECL (loc_note)))
+     return;
+   prev_insn = PREV_INSN (loc_note);
+ 
+   newloc = ggc_alloc_cleared (sizeof (struct var_loc_node));
+   /* If the insn we processed last time is the previous insn
+      and it is also a var location note, use the label we emitted
+      last time.  */
+   if (last_insn != NULL_RTX
+       && last_insn == prev_insn
+       && GET_CODE (prev_insn) == NOTE
+       && NOTE_LINE_NUMBER (prev_insn) == NOTE_INSN_VAR_LOCATION)
+     {
+       newloc->label = last_label;
+     }
+   else
+     {
+       ASM_GENERATE_INTERNAL_LABEL (loclabel, "LVL", loclabel_num);
+       ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LVL", loclabel_num);
+       loclabel_num++;
+       newloc->label = ggc_strdup (loclabel);
+     }
+   newloc->var_loc_note = loc_note;
+   newloc->next = NULL;
+ 
+   last_insn = loc_note;
+   last_label = newloc->label;
+ 
+   add_var_loc_to_decl (NOTE_VAR_LOCATION_DECL (loc_note), newloc);
+ }
+ 
+ /* We need to reset the locations at the beginning of each
+    function. We can't do this in the end_function hook, because the
+    declarations that use the locations won't have been outputted when
+    that hook is called.  */
+ 
+ static void
+ dwarf2out_begin_function (tree unused ATTRIBUTE_UNUSED)
+ {
+   htab_empty (decl_loc_table);
+ }
+ 
  /* Output a label to mark the beginning of a source code line entry
     and record information relating to this source line, in
     'line_info_table' for later output of the .debug_line section.  */
*************** dwarf2out_init (const char *filename ATT
*** 12707,12712 ****
--- 13021,13030 ----
    decl_die_table = htab_create_ggc (10, decl_die_table_hash,
  				    decl_die_table_eq, NULL);
  
+   /* Allocate the initial hunk of the decl_loc_table.  */
+   decl_loc_table = htab_create_ggc (10, decl_loc_table_hash,
+ 				    decl_loc_table_eq, NULL);
+ 
    /* Allocate the initial hunk of the decl_scope_table.  */
    VARRAY_TREE_INIT (decl_scope_table, 256, "decl_scope_table");
  

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-02 20:37 Variable tracking (location lists support) - part 2 Josef Zlomek
@ 2004-02-06  3:34 ` Roger Sayle
  2004-02-06 12:31   ` Josef Zlomek
  2004-02-21 13:45   ` Roger Sayle
  2004-02-11 14:55 ` Kazu Hirata
  2004-02-21 13:45 ` Josef Zlomek
  2 siblings, 2 replies; 44+ messages in thread
From: Roger Sayle @ 2004-02-06  3:34 UTC (permalink / raw)
  To: Josef Zlomek; +Cc: Daniel Berlin, gcc-patches


On Mon, 2 Feb 2004, Josef Zlomek wrote:
> 2004-02-02  Daniel Berlin <dberlin@dberlin.org>
>             Josef Zlomek  <zlomekj@suse.cz>
>
>         * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
>         at the beginning of function, call dwarf2out_var_location for
>         NOTE_INSN_VAR_LOCATION note.
> 	(struct var_loc_node, struct var_loc_list_def, loclabel_num,
> 	decl_loc_table, decl_loc_table_allocated, decl_loc_table_in_use,
> 	DECL_LOC_TABLE_INCREMENT): New.
> 	(lookup_decl_loc): New function.
> 	(add_var_loc_to_decl): New function.
> 	(based_loc_descr): Added parameter can_use_fbreg, DW_OP_fbreg is used
> 	only if can_use_fbreg.
> 	(mem_loc_descriptor): Added parameter can_use_fbreg, pass it to other
> 	functions.
> 	(loc_descriptor): Likewise. Process VAR_LOCATION.
> 	(concat_loc_descriptor): Call loc_descriptor with can_use_fbreg == true.
> 	(loc_descriptor_from_tree): Call mem_loc_descriptor with
> 	can_use_fbreg == true.
> 	(add_location_or_const_value_attribute): Added parameter enum
> 	dwarf_attribute attr, generate attribute ATTR.  Create the location list.
> 	(add_bound_info): Call loc_descriptor with can_use_fbreg == true.
> 	(gen_formal_parameter_die): Call add_location_or_const_value_attribute
> 	with attr == DW_AT_location.
> 	(gen_subprogram_die): Generate the location list for DW_AT_frame_base
> 	if frame_base_decl is defined and has a location list.
> 	(gen_variable_die): Call add_location_or_const_value_attribute with
> 	attr == DW_AT_location.
>         (dwarf2out_var_location): New function.
>         (dwarf2out_begin_function): New function.
> 	(dwarf2out_init): Create decl_loc_table and initialize
> 	decl_loc_table_allocated and decl_loc_table_in_use.


Ok for mainline.  Given the importance of these patches, I'm surprised
that they haven't already been reviewed.  However, I'm happy to approve
any patches that move us towards omitting the frame pointer by default
on more platforms for 3.5, with the associated improvements in
compile-time, debugging and generated code performance.

Many thanks.

Roger
--

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-06  3:34 ` Roger Sayle
@ 2004-02-06 12:31   ` Josef Zlomek
  2004-02-06 12:32     ` Josef Zlomek
                       ` (2 more replies)
  2004-02-21 13:45   ` Roger Sayle
  1 sibling, 3 replies; 44+ messages in thread
From: Josef Zlomek @ 2004-02-06 12:31 UTC (permalink / raw)
  To: Roger Sayle; +Cc: Daniel Berlin, gcc-patches

> > 2004-02-02  Daniel Berlin <dberlin@dberlin.org>
> >             Josef Zlomek  <zlomekj@suse.cz>
> >
> >         * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
> >         at the beginning of function, call dwarf2out_var_location for
> >         NOTE_INSN_VAR_LOCATION note.
> > 	(struct var_loc_node, struct var_loc_list_def, loclabel_num,
> > 	decl_loc_table, decl_loc_table_allocated, decl_loc_table_in_use,
> > 	DECL_LOC_TABLE_INCREMENT): New.
> > 	(lookup_decl_loc): New function.
> > 	(add_var_loc_to_decl): New function.
> > 	(based_loc_descr): Added parameter can_use_fbreg, DW_OP_fbreg is used
> > 	only if can_use_fbreg.
> > 	(mem_loc_descriptor): Added parameter can_use_fbreg, pass it to other
> > 	functions.
> > 	(loc_descriptor): Likewise. Process VAR_LOCATION.
> > 	(concat_loc_descriptor): Call loc_descriptor with can_use_fbreg == true.
> > 	(loc_descriptor_from_tree): Call mem_loc_descriptor with
> > 	can_use_fbreg == true.
> > 	(add_location_or_const_value_attribute): Added parameter enum
> > 	dwarf_attribute attr, generate attribute ATTR.  Create the location list.
> > 	(add_bound_info): Call loc_descriptor with can_use_fbreg == true.
> > 	(gen_formal_parameter_die): Call add_location_or_const_value_attribute
> > 	with attr == DW_AT_location.
> > 	(gen_subprogram_die): Generate the location list for DW_AT_frame_base
> > 	if frame_base_decl is defined and has a location list.
> > 	(gen_variable_die): Call add_location_or_const_value_attribute with
> > 	attr == DW_AT_location.
> >         (dwarf2out_var_location): New function.
> >         (dwarf2out_begin_function): New function.
> > 	(dwarf2out_init): Create decl_loc_table and initialize
> > 	decl_loc_table_allocated and decl_loc_table_in_use.
> 
> 
> Ok for mainline.

Thanks :-)
What about the other related patches ?

Variable tracking (location lists support) - part 1
http://gcc.gnu.org/ml/gcc-patches/2004-01/msg03266.html

Fixes to dwarf2out.c WRT location lists
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00110.html

Josef

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-06 12:31   ` Josef Zlomek
@ 2004-02-06 12:32     ` Josef Zlomek
  2004-02-09 14:55       ` debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2) Joern Rennecke
  2004-02-21 13:45       ` Variable tracking (location lists support) - part 2 Josef Zlomek
  2004-02-06 13:41     ` Roger Sayle
  2004-02-21 13:45     ` Josef Zlomek
  2 siblings, 2 replies; 44+ messages in thread
From: Josef Zlomek @ 2004-02-06 12:32 UTC (permalink / raw)
  To: Roger Sayle; +Cc: Daniel Berlin, gcc-patches

> > > 2004-02-02  Daniel Berlin <dberlin@dberlin.org>
> > >             Josef Zlomek  <zlomekj@suse.cz>
> > >
> > >         * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
> > >         at the beginning of function, call dwarf2out_var_location for
> > >         NOTE_INSN_VAR_LOCATION note.
> > > 	(struct var_loc_node, struct var_loc_list_def, loclabel_num,
> > > 	decl_loc_table, decl_loc_table_allocated, decl_loc_table_in_use,
> > > 	DECL_LOC_TABLE_INCREMENT): New.
> > > 	(lookup_decl_loc): New function.
> > > 	(add_var_loc_to_decl): New function.
> > > 	(based_loc_descr): Added parameter can_use_fbreg, DW_OP_fbreg is used
> > > 	only if can_use_fbreg.
> > > 	(mem_loc_descriptor): Added parameter can_use_fbreg, pass it to other
> > > 	functions.
> > > 	(loc_descriptor): Likewise. Process VAR_LOCATION.
> > > 	(concat_loc_descriptor): Call loc_descriptor with can_use_fbreg == true.
> > > 	(loc_descriptor_from_tree): Call mem_loc_descriptor with
> > > 	can_use_fbreg == true.
> > > 	(add_location_or_const_value_attribute): Added parameter enum
> > > 	dwarf_attribute attr, generate attribute ATTR.  Create the location list.
> > > 	(add_bound_info): Call loc_descriptor with can_use_fbreg == true.
> > > 	(gen_formal_parameter_die): Call add_location_or_const_value_attribute
> > > 	with attr == DW_AT_location.
> > > 	(gen_subprogram_die): Generate the location list for DW_AT_frame_base
> > > 	if frame_base_decl is defined and has a location list.
> > > 	(gen_variable_die): Call add_location_or_const_value_attribute with
> > > 	attr == DW_AT_location.
> > >         (dwarf2out_var_location): New function.
> > >         (dwarf2out_begin_function): New function.
> > > 	(dwarf2out_init): Create decl_loc_table and initialize
> > > 	decl_loc_table_allocated and decl_loc_table_in_use.
> > 
> > 
> > Ok for mainline.
> 
> Thanks :-)
> What about the other related patches ?
> 
> Variable tracking (location lists support) - part 1
> http://gcc.gnu.org/ml/gcc-patches/2004-01/msg03266.html
> 
> Fixes to dwarf2out.c WRT location lists
> http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00110.html

I'm asking just to be sure I do not commit unreviewed patch...

Josef

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-06 12:31   ` Josef Zlomek
  2004-02-06 12:32     ` Josef Zlomek
@ 2004-02-06 13:41     ` Roger Sayle
  2004-02-08 22:24       ` Roger Sayle
  2004-02-21 13:45       ` Roger Sayle
  2004-02-21 13:45     ` Josef Zlomek
  2 siblings, 2 replies; 44+ messages in thread
From: Roger Sayle @ 2004-02-06 13:41 UTC (permalink / raw)
  To: Josef Zlomek; +Cc: Daniel Berlin, gcc-patches


Hi Josef,
> What about the other related patches ?
>
> Variable tracking (location lists support) - part 1
> http://gcc.gnu.org/ml/gcc-patches/2004-01/msg03266.html

This is OK too.  We'll recover the 2% slowdown, when we gain the much
larger speed-up from -fomit-frame-pointer.


> Fixes to dwarf2out.c WRT location lists
> http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00110.html

I've approved Dan's posting of this patch :>

Roger
--

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-06 13:41     ` Roger Sayle
@ 2004-02-08 22:24       ` Roger Sayle
  2004-02-08 23:01         ` Josef Zlomek
  2004-02-21 13:45         ` Roger Sayle
  2004-02-21 13:45       ` Roger Sayle
  1 sibling, 2 replies; 44+ messages in thread
From: Roger Sayle @ 2004-02-08 22:24 UTC (permalink / raw)
  To: Josef Zlomek; +Cc: Daniel Berlin, gcc-patches


Hi Josef and Dan,

I've just discovered that typing "gdb cc1" on i686-pc-linux-gnu with
a recently built mainline GCC, causes both gdb 6.0 and gdb 5.2.1 to
segmentation fault.  Given that 6.0 is the most recent release of GDB,
I suspect that either there's a bug in gcc's location list generation
or that GDB's dwarf-2 location list code isn't as backwardly "safe"
as we'd hoped.

The segfault in gdb 6.0 is in decode_locdesc of dwarf2read.c line 6771,
where the value of the "blk" pointer looks invalid.

I'm looking into the issue as best I can (without a debugger :<), but
I wonder if I could also ask you to investigate?  As a worst case
scenario, we might consider a patch to disable location lists by
default, until this failure is resolved?

Many thanks in advance,

Roger
--

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-08 22:24       ` Roger Sayle
@ 2004-02-08 23:01         ` Josef Zlomek
  2004-02-21 13:45           ` Josef Zlomek
  2004-02-21 13:45         ` Roger Sayle
  1 sibling, 1 reply; 44+ messages in thread
From: Josef Zlomek @ 2004-02-08 23:01 UTC (permalink / raw)
  To: Roger Sayle; +Cc: Daniel Berlin, gcc-patches

> Hi Josef and Dan,
> 
> I've just discovered that typing "gdb cc1" on i686-pc-linux-gnu with
> a recently built mainline GCC, causes both gdb 6.0 and gdb 5.2.1 to
> segmentation fault.

I noticed, that GDB 5.x segfault too :-(
CVS version of GDB (mainline and 6.0 branch) works.
The attached patch makes GDB 6.0 to support location lists fully.

> Given that 6.0 is the most recent release of GDB, I suspect that either
> there's a bug in gcc's location list generation or that GDB's dwarf-2 location
> list code isn't as backwardly "safe" as we'd hoped.

The were some bugs in GDB.

> The segfault in gdb 6.0 is in decode_locdesc of dwarf2read.c line 6771,
> where the value of the "blk" pointer looks invalid.
> 
> I'm looking into the issue as best I can (without a debugger :<), but
> I wonder if I could also ask you to investigate?  As a worst case
> scenario, we might consider a patch to disable location lists by
> default, until this failure is resolved?

It is easy to disable it by default in toplev.c:process_options().

Josef


2003-10-09  Daniel Jacobowitz  <drow@mvista.com>

	Merge from mainline:
	2003-07-31  Daniel Jacobowitz  <drow@mvista.com>

	* dwarf2read.c (new_symbol): Use var_decode_location for parameters.

2003-10-09  Daniel Jacobowitz  <drow@mvista.com>

	* dwarf2expr.c (execute_stack_op): Don't treat the frame base as
	a memory pointer.

Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.96.4.2
retrieving revision 1.96.4.3
diff -u -p -r1.96.4.2 -r1.96.4.3
--- gdb/dwarf2read.c	22 Jul 2003 15:44:10 -0000	1.96.4.2
+++ gdb/dwarf2read.c	9 Oct 2003 14:26:14 -0000	1.96.4.3
@@ -5207,32 +5207,10 @@ new_symbol (struct die_info *die, struct
 	  attr = dwarf_attr (die, DW_AT_location);
 	  if (attr)
 	    {
-	      SYMBOL_VALUE (sym) =
-		decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
-	      if (isreg)
-		{
-		  SYMBOL_CLASS (sym) = LOC_REGPARM;
-		  SYMBOL_VALUE (sym) = 
-		    DWARF2_REG_TO_REGNUM (SYMBOL_VALUE (sym));
-		}
-	      else if (offreg)
-		{
-		  if (isderef)
-		    {
-		      if (basereg != frame_base_reg)
-			dwarf2_complex_location_expr_complaint ();
-		      SYMBOL_CLASS (sym) = LOC_REF_ARG;
-		    }
-		  else
-		    {
-		      SYMBOL_CLASS (sym) = LOC_BASEREG_ARG;
-		      SYMBOL_BASEREG (sym) = DWARF2_REG_TO_REGNUM (basereg);
-		    }
-		}
-	      else
-		{
-		  SYMBOL_CLASS (sym) = LOC_ARG;
-		}
+	      var_decode_location (attr, sym, objfile, cu_header);
+	      /* FIXME drow/2003-07-31: Is LOC_COMPUTED_ARG necessary?  */
+	      if (SYMBOL_CLASS (sym) == LOC_COMPUTED)
+		SYMBOL_CLASS (sym) = LOC_COMPUTED_ARG;
 	    }
 	  attr = dwarf_attr (die, DW_AT_const_value);
 	  if (attr)
Index: gdb/dwarf2expr.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2expr.c,v
retrieving revision 1.8.8.1
retrieving revision 1.8.8.2
diff -u -p -r1.8.8.1 -r1.8.8.2
--- gdb/dwarf2expr.c	22 Jul 2003 15:44:10 -0000	1.8.8.1
+++ gdb/dwarf2expr.c	9 Oct 2003 14:16:21 -0000	1.8.8.2
@@ -441,18 +441,6 @@ execute_stack_op (struct dwarf_expr_cont
 	    result = dwarf_expr_fetch (ctx, 0);
 	    if (ctx->in_reg)
 	      result = (ctx->read_reg) (ctx->baton, result);
-	    else
-	      {
-		char *buf = alloca (TARGET_ADDR_BIT / TARGET_CHAR_BIT);
-		int bytes_read;
-
-		(ctx->read_mem) (ctx->baton, buf, result,
-				 TARGET_ADDR_BIT / TARGET_CHAR_BIT);
-		result = dwarf2_read_address (buf,
-					      buf + (TARGET_ADDR_BIT
-						     / TARGET_CHAR_BIT),
-					      &bytes_read);
-	      }
 	    result = result + offset;
 	    ctx->stack_len = before_stack_len;
 	    ctx->in_reg = 0;

^ permalink raw reply	[flat|nested] 44+ messages in thread

* debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-06 12:32     ` Josef Zlomek
@ 2004-02-09 14:55       ` Joern Rennecke
  2004-02-09 15:45         ` Daniel Berlin
  2004-02-21 13:45         ` Joern Rennecke
  2004-02-21 13:45       ` Variable tracking (location lists support) - part 2 Josef Zlomek
  1 sibling, 2 replies; 44+ messages in thread
From: Joern Rennecke @ 2004-02-09 14:55 UTC (permalink / raw)
  To: Josef Zlomek, Daniel Berlin; +Cc: Roger Sayle, gcc-patches

The addition of location list support broke sh-elf and sh64-elf builds.
Presumably all targets with a non-empty USTER_LABEL_PREFIX and dwarf2
debugging information are affected.

The new .debug_loc section contains invalid differences:

.Letext0:
        .section        .debug_loc,"",@progbits
.Ldebug_loc0:
.LLST0:
        .ualong 0xffffffff
        .ualong _.text
        .ualong .LVL0-_.text
        .ualong .LVL2-_.text

This is from the assembly file generated for muldi3 for sh-elf.

Here is a backtrace from the generation of the first invalid difference:

#0  dw2_assemble_integer (size=4, x=0x402aa3c0)
    at ../../srcw/gcc/dwarf2asm.c:50
#1  0x080e4c3f in dw2_asm_output_delta (size=4, lab1=0x83f7418 "*.LVL0", 
    lab2=0x830c42d ".text", 
    comment=0x830c4c0 "Location list begin address (%s)")
    at ../../srcw/gcc/dwarf2asm.c:107
#2  0x080ef71f in output_loc_list (list_head=0x4028be10)
    at ../../srcw/gcc/dwarf2out.c:6661
#3  0x080ee8cf in output_location_lists (die=0x40298b00)
    at ../../srcw/gcc/dwarf2out.c:6168
#4  0x080ee8ff in output_location_lists (die=0x40298ac0)
    at ../../srcw/gcc/dwarf2out.c:6171
#5  0x080ee8ff in output_location_lists (die=0x402097c0)
    at ../../srcw/gcc/dwarf2out.c:6171
#6  0x080ff38d in dwarf2out_finish (
    filename=0x83ee7b0 "../../srcw/gcc/libgcc2.c")
    at ../../srcw/gcc/dwarf2out.c:13439
#7  0x0824f52e in compile_file () at ../../srcw/gcc/toplev.c:1858
#8  0x08254bcc in do_compile () at ../../srcw/gcc/toplev.c:4678
#9  0x08254c62 in toplev_main (argc=19, argv=0xbfffe324)
    at ../../srcw/gcc/toplev.c:4718
#10 0x4004f507 in __libc_start_main (main=0x809e594 <main>, argc=19, 
    ubp_av=0xbfffe324, init=0x80494a0 <_init>, fini=0x82f7180 <_fini>, 
    rtld_fini=0x4000dc14 <_dl_fini>, stack_end=0xbfffe31c)
    at ../sysdeps/generic/libc-start.c:129

AFAIKS the basic problem is that curr->section is used like a label in
output_loc_list, which has been introduced in Daniel Berlin's patch from
2001-05-18 (dwarf2out.c version 1.270), but this code has not been used
during sh-elf or sh64-elf builds before.

The current form of this code is:

  if (strcmp (curr->section, ".text") == 0)
    {
      /* dw2_asm_output_data will mask off any extra bits in the ~0.  */
      dw2_asm_output_data (DWARF2_ADDR_SIZE, ~(unsigned HOST_WIDE_INT) 0,
                           "Location list base address specifier fake entry");
      dw2_asm_output_offset (DWARF2_ADDR_SIZE, curr->section,
                             "Location list base address specifier base");
    }

  /* Walk the location list, and output each range + expression.  */
  for (curr = list_head; curr != NULL; curr = curr->dw_loc_next)
    {
      unsigned long size;
      if (separate_line_info_table_in_use == 0)
        {
          dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->begin, curr->section,
                                "Location list begin address (%s)",
                                list_head->ll_symbol);
          dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->end, curr->section,
                                "Location list end address (%s)",
                                list_head->ll_symbol);
        }

curr->section is ".text"  Since there is no leading '*', LOCAL_LABEL_PREFIX
gets applied, so that we end up with _.text .

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-09 14:55       ` debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2) Joern Rennecke
@ 2004-02-09 15:45         ` Daniel Berlin
  2004-02-09 16:34           ` Joern Rennecke
  2004-02-21 13:45           ` Daniel Berlin
  2004-02-21 13:45         ` Joern Rennecke
  1 sibling, 2 replies; 44+ messages in thread
From: Daniel Berlin @ 2004-02-09 15:45 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: Josef Zlomek, Roger Sayle, gcc-patches


On Feb 9, 2004, at 8:42 AM, Joern Rennecke wrote:

> The addition of location list support broke sh-elf and sh64-elf builds.
> Presumably all targets with a non-empty USTER_LABEL_PREFIX and dwarf2
> debugging information are affected.
>
>
> The current form of this code is:
>
>   if (strcmp (curr->section, ".text") == 0)
>     {
>       /* dw2_asm_output_data will mask off any extra bits in the ~0.  
> */
>       dw2_asm_output_data (DWARF2_ADDR_SIZE, ~(unsigned HOST_WIDE_INT) 
> 0,
>                            "Location list base address specifier fake 
> entry");
>       dw2_asm_output_offset (DWARF2_ADDR_SIZE, curr->section,
>                              "Location list base address specifier 
> base");
>     }
>



There should be no need for this hunk of code anymore.

Does deleting it help?

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-09 15:45         ` Daniel Berlin
@ 2004-02-09 16:34           ` Joern Rennecke
  2004-02-09 17:26             ` Daniel Berlin
  2004-02-21 13:45             ` Joern Rennecke
  2004-02-21 13:45           ` Daniel Berlin
  1 sibling, 2 replies; 44+ messages in thread
From: Joern Rennecke @ 2004-02-09 16:34 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: Josef Zlomek, Roger Sayle, gcc-patches, Joern Rennecke

> There should be no need for this hunk of code anymore.
> 
> Does deleting it help?

Only marginally; it removes nine plain references to _.text,
but all the differences, which are generated by the code in the loop,
still refer to it.

Thus I still get 26 errors like this for _muldi3.o :

libgcc2.s: Assembler messages:
libgcc2.s:278: Error: can't resolve `.text' {.text section} - `_.text' {*UND* section}

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-09 16:34           ` Joern Rennecke
@ 2004-02-09 17:26             ` Daniel Berlin
  2004-02-09 21:48               ` Richard Henderson
  2004-02-21 13:45               ` Daniel Berlin
  2004-02-21 13:45             ` Joern Rennecke
  1 sibling, 2 replies; 44+ messages in thread
From: Daniel Berlin @ 2004-02-09 17:26 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: Josef Zlomek, Roger Sayle, gcc-patches


On Feb 9, 2004, at 10:37 AM, Joern Rennecke wrote:

>> There should be no need for this hunk of code anymore.
>>
>> Does deleting it help?
>
> Only marginally; it removes nine plain references to _.text,
> but all the differences, which are generated by the code in the loop,
> still refer to it.
>
> Thus I still get 26 errors like this for _muldi3.o :
>
> libgcc2.s: Assembler messages:
> libgcc2.s:278: Error: can't resolve `.text' {.text section} - `_.text' 
> {*UND* section}

I'm looking at how to do this "portably". Any suggestions would be 
appreciated.
I assumed we could difference section names without trouble, but this 
was 3 years ago, when i was young and naive :).

We have to difference against the absolute beginning of the section.
Or waste a *TON* of space and emit base address change entries with 
every location list.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-09 17:26             ` Daniel Berlin
@ 2004-02-09 21:48               ` Richard Henderson
  2004-02-10 18:05                 ` Josef Zlomek
  2004-02-21 13:45                 ` Richard Henderson
  2004-02-21 13:45               ` Daniel Berlin
  1 sibling, 2 replies; 44+ messages in thread
From: Richard Henderson @ 2004-02-09 21:48 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: Joern Rennecke, Josef Zlomek, Roger Sayle, gcc-patches

On Mon, Feb 09, 2004 at 10:45:54AM -0500, Daniel Berlin wrote:
> I'm looking at how to do this "portably". Any suggestions would be 
> appreciated.

The only way is to generate a label at the beginning of the section.
I believe we already do this, in order to built the aranges table,
so you should be able to reuse those.


r~

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-09 21:48               ` Richard Henderson
@ 2004-02-10 18:05                 ` Josef Zlomek
  2004-02-10 18:12                   ` Daniel Berlin
  2004-02-21 13:45                   ` Josef Zlomek
  2004-02-21 13:45                 ` Richard Henderson
  1 sibling, 2 replies; 44+ messages in thread
From: Josef Zlomek @ 2004-02-10 18:05 UTC (permalink / raw)
  To: Richard Henderson, Daniel Berlin, Joern Rennecke, Roger Sayle,
	gcc-patches

> > I'm looking at how to do this "portably". Any suggestions would be 
> > appreciated.
> 
> The only way is to generate a label at the beginning of the section.
> I believe we already do this, in order to built the aranges table,
> so you should be able to reuse those.

Yes, we generate it, it is a variable text_section_label.
Thanks!

Josef

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-10 18:05                 ` Josef Zlomek
@ 2004-02-10 18:12                   ` Daniel Berlin
  2004-02-21 13:45                     ` Daniel Berlin
  2004-02-21 13:45                   ` Josef Zlomek
  1 sibling, 1 reply; 44+ messages in thread
From: Daniel Berlin @ 2004-02-10 18:12 UTC (permalink / raw)
  To: Josef Zlomek; +Cc: Joern Rennecke, gcc-patches, Richard Henderson, Roger Sayle


On Feb 10, 2004, at 12:19 PM, Josef Zlomek wrote:

>>> I'm looking at how to do this "portably". Any suggestions would be
>>> appreciated.
>>
>> The only way is to generate a label at the beginning of the section.
>> I believe we already do this, in order to built the aranges table,
>> so you should be able to reuse those.
>
> Yes, we generate it, it is a variable text_section_label.
>
Hence the patch i submitted, which is reported to fix the problem.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-02 20:37 Variable tracking (location lists support) - part 2 Josef Zlomek
  2004-02-06  3:34 ` Roger Sayle
@ 2004-02-11 14:55 ` Kazu Hirata
  2004-02-11 16:06   ` Josef Zlomek
                     ` (3 more replies)
  2004-02-21 13:45 ` Josef Zlomek
  2 siblings, 4 replies; 44+ messages in thread
From: Kazu Hirata @ 2004-02-11 14:55 UTC (permalink / raw)
  To: zlomj9am; +Cc: gcc-patches

Hi Josef,

> this patch adds location list support to dwarf2out.c.
> This generates the location list debug info from the NOTE_INSN_VAR_LOCATION
> notes produces by the first patch of variable tracking.
> 
> Bootstrapped/regtested x86-64 (standalone and together with the first part).
> 
> Josef
> 
> 2004-02-02  Daniel Berlin <dberlin@dberlin.org>
>             Josef Zlomek  <zlomekj@suse.cz>
> 
>         * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
>         :
>         :

This patch unfortunately breaks the build of h8300-elf.  Specifically,
I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
minimized testcase and the errors I get.

int
foo (int a)
{
  return a;
}

/tmp/cchHQ5CR.s: Assembler messages:
/tmp/cchHQ5CR.s:75: Error: can't resolve `.LVL0' {.text section} - `_.text' {*UND* section}
/tmp/cchHQ5CR.s:76: Error: can't resolve `.LVL1' {.text section} - `_.text' {*UND* section}
/tmp/cchHQ5CR.s:75: Error: Difference of symbols in different sections is not supported
/tmp/cchHQ5CR.s:76: Error: Difference of symbols in different sections is not supported

Compiling the above testcase, GCC with your patch outputs several new
lines compared to what GCC outputs without your patch, some of which
are

       .2byte  .LVL0-_.text
       .2byte  .LVL1-_.text

gas for H8 does not support a difference of two labels.  I am not
familiar with debugging formats.  Does dwarf2 require a difference of
two labels?  Is there a way around it?

Thanks,

Kazu Hirata

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 14:55 ` Kazu Hirata
@ 2004-02-11 16:06   ` Josef Zlomek
  2004-02-21 13:45     ` Josef Zlomek
  2004-02-11 16:11   ` Rainer Orth
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 44+ messages in thread
From: Josef Zlomek @ 2004-02-11 16:06 UTC (permalink / raw)
  To: Kazu Hirata; +Cc: gcc-patches

> > this patch adds location list support to dwarf2out.c.
> > This generates the location list debug info from the NOTE_INSN_VAR_LOCATION
> > notes produces by the first patch of variable tracking.
> > 
> > Bootstrapped/regtested x86-64 (standalone and together with the first part).
> > 
> > Josef
> > 
> > 2004-02-02  Daniel Berlin <dberlin@dberlin.org>
> >             Josef Zlomek  <zlomekj@suse.cz>
> > 
> >         * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
> >         :
> >         :
> 
> This patch unfortunately breaks the build of h8300-elf.  Specifically,
> I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
> minimized testcase and the errors I get.
> 
> int
> foo (int a)
> {
>   return a;
> }
> 
> /tmp/cchHQ5CR.s: Assembler messages:
> /tmp/cchHQ5CR.s:75: Error: can't resolve `.LVL0' {.text section} - `_.text' {*UND* section}
> /tmp/cchHQ5CR.s:76: Error: can't resolve `.LVL1' {.text section} - `_.text' {*UND* section}
> /tmp/cchHQ5CR.s:75: Error: Difference of symbols in different sections is not supported
> /tmp/cchHQ5CR.s:76: Error: Difference of symbols in different sections is not supported

There is a patch (http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html)
from Daniel Berlin submited several days before which should fix this. 

Josef

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 14:55 ` Kazu Hirata
  2004-02-11 16:06   ` Josef Zlomek
@ 2004-02-11 16:11   ` Rainer Orth
  2004-02-11 17:15     ` Daniel Berlin
  2004-02-21 13:45     ` Rainer Orth
  2004-02-11 16:47   ` Daniel Berlin
  2004-02-21 13:45   ` Kazu Hirata
  3 siblings, 2 replies; 44+ messages in thread
From: Rainer Orth @ 2004-02-11 16:11 UTC (permalink / raw)
  To: Kazu Hirata; +Cc: zlomj9am, gcc-patches

Kazu Hirata <kazu@cs.umass.edu> writes:

> This patch unfortunately breaks the build of h8300-elf.  Specifically,
> I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
> minimized testcase and the errors I get.

I've the same problem on sparc-sun-solaris2.8 (native assembler) building
the sparcv9 libgcc (where, unlike sparcv7, DWARF-2 is used by default):

$ ./xgcc -B./ -B/vol/gcc/share/sparc-sun-solaris2.8/bin/ -isystem /vol/gcc/share/sparc-sun-solaris2.8/include -isystem /vol/gcc/share/sparc-sun-solaris2.8/sys-include -L/vol/gcc/obj/gcc-3.5.0-20040210/8-gcc/gcc/../ld -O2  -DIN_GCC    -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -I. -I -I/vol/gnu/src/gcc/gcc-dist/gcc -I/vol/gnu/src/gcc/gcc-dist/gcc/ -I/vol/gnu/src/gcc/gcc-dist/gcc/../include   -m64 -DL_muldi3 -c /vol/gnu/src/gcc/gcc-dist/gcc/libgcc2.c -o libgcc/sparcv9/_muldi3.o          
/usr/ccs/bin/as: "/var/tmp//cc71zJdd.s", line 275: error: can't compute value of an expression involving an external symbol
[...]

Line 275 is

        .uaxword        .LLVL0-.text

I suppose the problem is that there's no symbol .text, only

        .section        ".text"

so .text is assumed extern.

Please fix.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 14:55 ` Kazu Hirata
  2004-02-11 16:06   ` Josef Zlomek
  2004-02-11 16:11   ` Rainer Orth
@ 2004-02-11 16:47   ` Daniel Berlin
  2004-02-11 17:50     ` Kazu Hirata
  2004-02-21 13:45     ` Daniel Berlin
  2004-02-21 13:45   ` Kazu Hirata
  3 siblings, 2 replies; 44+ messages in thread
From: Daniel Berlin @ 2004-02-11 16:47 UTC (permalink / raw)
  To: Kazu Hirata; +Cc: zlomj9am, gcc-patches

>
> This patch unfortunately breaks the build of h8300-elf.  Specifically,
> I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
> minimized testcase and the errors I get.
>

Did you try the patch posted for this (still unreviewed as of yet):
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 16:11   ` Rainer Orth
@ 2004-02-11 17:15     ` Daniel Berlin
  2004-02-11 17:32       ` Rainer Orth
  2004-02-21 13:45       ` Daniel Berlin
  2004-02-21 13:45     ` Rainer Orth
  1 sibling, 2 replies; 44+ messages in thread
From: Daniel Berlin @ 2004-02-11 17:15 UTC (permalink / raw)
  To: Rainer Orth; +Cc: zlomj9am, gcc-patches, Kazu Hirata


On Feb 11, 2004, at 10:44 AM, Rainer Orth wrote:

> Kazu Hirata <kazu@cs.umass.edu> writes:
>
>> This patch unfortunately breaks the build of h8300-elf.  Specifically,
>> I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
>> minimized testcase and the errors I get.
>
> I've the same problem on sparc-sun-solaris2.8 (native assembler) 
> building
> the sparcv9 libgcc (where, unlike sparcv7, DWARF-2 is used by default):
>
> $ ./xgcc -B./ -B/vol/gcc/share/sparc-sun-solaris2.8/bin/ -isystem 
> /vol/gcc/share/sparc-sun-solaris2.8/include -isystem 
> /vol/gcc/share/sparc-sun-solaris2.8/sys-include 
> -L/vol/gcc/obj/gcc-3.5.0-20040210/8-gcc/gcc/../ld -O2  -DIN_GCC    -W 
> -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes 
> -Wold-style-definition  -isystem ./include  -fPIC -g 
> -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -I. -I 
> -I/vol/gnu/src/gcc/gcc-dist/gcc -I/vol/gnu/src/gcc/gcc-dist/gcc/ 
> -I/vol/gnu/src/gcc/gcc-dist/gcc/../include   -m64 -DL_muldi3 -c 
> /vol/gnu/src/gcc/gcc-dist/gcc/libgcc2.c -o libgcc/sparcv9/_muldi3.o
> /usr/ccs/bin/as: "/var/tmp//cc71zJdd.s", line 275: error: can't 
> compute value of an expression involving an external symbol
> [...]
>
> Line 275 is
>
>         .uaxword        .LLVL0-.text
>
> I suppose the problem is that there's no symbol .text, only
>
>         .section        ".text"
>
> so .text is assumed extern.
>
> Please fix.

Again, see
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html

I have confirmation it works on solaris 9. I expect it to work just as 
well in your case. :)

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 17:15     ` Daniel Berlin
@ 2004-02-11 17:32       ` Rainer Orth
  2004-02-21 13:45         ` Rainer Orth
  2004-02-21 13:45       ` Daniel Berlin
  1 sibling, 1 reply; 44+ messages in thread
From: Rainer Orth @ 2004-02-11 17:32 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: zlomj9am, gcc-patches, Kazu Hirata

Daniel Berlin writes:

> Again, see
> http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html
> 
> I have confirmation it works on solaris 9. I expect it to work just as 
> well in your case. :)

Indeed: bootstrap is into stage2 now.

Thanks.
	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 16:47   ` Daniel Berlin
@ 2004-02-11 17:50     ` Kazu Hirata
  2004-02-11 18:12       ` Zack Weinberg
  2004-02-21 13:45       ` Kazu Hirata
  2004-02-21 13:45     ` Daniel Berlin
  1 sibling, 2 replies; 44+ messages in thread
From: Kazu Hirata @ 2004-02-11 17:50 UTC (permalink / raw)
  To: dberlin; +Cc: zlomj9am, gcc-patches

Hi Daniel and Josef,

> > This patch unfortunately breaks the build of h8300-elf.  Specifically,
> > I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
> > minimized testcase and the errors I get.
> 
> Did you try the patch posted for this (still unreviewed as of yet):
> http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html

Your patch indeed solves the problem.  Thanks!

Kazu Hirata

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 17:50     ` Kazu Hirata
@ 2004-02-11 18:12       ` Zack Weinberg
  2004-02-21 13:45         ` Zack Weinberg
  2004-02-21 13:45       ` Kazu Hirata
  1 sibling, 1 reply; 44+ messages in thread
From: Zack Weinberg @ 2004-02-11 18:12 UTC (permalink / raw)
  To: Kazu Hirata; +Cc: dberlin, zlomj9am, gcc-patches

Kazu Hirata <kazu@cs.umass.edu> writes:

> Hi Daniel and Josef,
>
>> > This patch unfortunately breaks the build of h8300-elf.  Specifically,
>> > I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
>> > minimized testcase and the errors I get.
>> 
>> Did you try the patch posted for this (still unreviewed as of yet):
>> http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html
>
> Your patch indeed solves the problem.  Thanks!

This patch is approved.

zw

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 17:50     ` Kazu Hirata
  2004-02-11 18:12       ` Zack Weinberg
@ 2004-02-21 13:45       ` Kazu Hirata
  1 sibling, 0 replies; 44+ messages in thread
From: Kazu Hirata @ 2004-02-21 13:45 UTC (permalink / raw)
  To: dberlin; +Cc: zlomj9am, gcc-patches

Hi Daniel and Josef,

> > This patch unfortunately breaks the build of h8300-elf.  Specifically,
> > I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
> > minimized testcase and the errors I get.
> 
> Did you try the patch posted for this (still unreviewed as of yet):
> http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html

Your patch indeed solves the problem.  Thanks!

Kazu Hirata

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-09 15:45         ` Daniel Berlin
  2004-02-09 16:34           ` Joern Rennecke
@ 2004-02-21 13:45           ` Daniel Berlin
  1 sibling, 0 replies; 44+ messages in thread
From: Daniel Berlin @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: Josef Zlomek, Roger Sayle, gcc-patches


On Feb 9, 2004, at 8:42 AM, Joern Rennecke wrote:

> The addition of location list support broke sh-elf and sh64-elf builds.
> Presumably all targets with a non-empty USTER_LABEL_PREFIX and dwarf2
> debugging information are affected.
>
>
> The current form of this code is:
>
>   if (strcmp (curr->section, ".text") == 0)
>     {
>       /* dw2_asm_output_data will mask off any extra bits in the ~0.  
> */
>       dw2_asm_output_data (DWARF2_ADDR_SIZE, ~(unsigned HOST_WIDE_INT) 
> 0,
>                            "Location list base address specifier fake 
> entry");
>       dw2_asm_output_offset (DWARF2_ADDR_SIZE, curr->section,
>                              "Location list base address specifier 
> base");
>     }
>



There should be no need for this hunk of code anymore.

Does deleting it help?

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-06 12:32     ` Josef Zlomek
  2004-02-09 14:55       ` debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2) Joern Rennecke
@ 2004-02-21 13:45       ` Josef Zlomek
  1 sibling, 0 replies; 44+ messages in thread
From: Josef Zlomek @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Roger Sayle; +Cc: Daniel Berlin, gcc-patches

> > > 2004-02-02  Daniel Berlin <dberlin@dberlin.org>
> > >             Josef Zlomek  <zlomekj@suse.cz>
> > >
> > >         * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
> > >         at the beginning of function, call dwarf2out_var_location for
> > >         NOTE_INSN_VAR_LOCATION note.
> > > 	(struct var_loc_node, struct var_loc_list_def, loclabel_num,
> > > 	decl_loc_table, decl_loc_table_allocated, decl_loc_table_in_use,
> > > 	DECL_LOC_TABLE_INCREMENT): New.
> > > 	(lookup_decl_loc): New function.
> > > 	(add_var_loc_to_decl): New function.
> > > 	(based_loc_descr): Added parameter can_use_fbreg, DW_OP_fbreg is used
> > > 	only if can_use_fbreg.
> > > 	(mem_loc_descriptor): Added parameter can_use_fbreg, pass it to other
> > > 	functions.
> > > 	(loc_descriptor): Likewise. Process VAR_LOCATION.
> > > 	(concat_loc_descriptor): Call loc_descriptor with can_use_fbreg == true.
> > > 	(loc_descriptor_from_tree): Call mem_loc_descriptor with
> > > 	can_use_fbreg == true.
> > > 	(add_location_or_const_value_attribute): Added parameter enum
> > > 	dwarf_attribute attr, generate attribute ATTR.  Create the location list.
> > > 	(add_bound_info): Call loc_descriptor with can_use_fbreg == true.
> > > 	(gen_formal_parameter_die): Call add_location_or_const_value_attribute
> > > 	with attr == DW_AT_location.
> > > 	(gen_subprogram_die): Generate the location list for DW_AT_frame_base
> > > 	if frame_base_decl is defined and has a location list.
> > > 	(gen_variable_die): Call add_location_or_const_value_attribute with
> > > 	attr == DW_AT_location.
> > >         (dwarf2out_var_location): New function.
> > >         (dwarf2out_begin_function): New function.
> > > 	(dwarf2out_init): Create decl_loc_table and initialize
> > > 	decl_loc_table_allocated and decl_loc_table_in_use.
> > 
> > 
> > Ok for mainline.
> 
> Thanks :-)
> What about the other related patches ?
> 
> Variable tracking (location lists support) - part 1
> http://gcc.gnu.org/ml/gcc-patches/2004-01/msg03266.html
> 
> Fixes to dwarf2out.c WRT location lists
> http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00110.html

I'm asking just to be sure I do not commit unreviewed patch...

Josef

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-08 23:01         ` Josef Zlomek
@ 2004-02-21 13:45           ` Josef Zlomek
  0 siblings, 0 replies; 44+ messages in thread
From: Josef Zlomek @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Roger Sayle; +Cc: Daniel Berlin, gcc-patches

> Hi Josef and Dan,
> 
> I've just discovered that typing "gdb cc1" on i686-pc-linux-gnu with
> a recently built mainline GCC, causes both gdb 6.0 and gdb 5.2.1 to
> segmentation fault.

I noticed, that GDB 5.x segfault too :-(
CVS version of GDB (mainline and 6.0 branch) works.
The attached patch makes GDB 6.0 to support location lists fully.

> Given that 6.0 is the most recent release of GDB, I suspect that either
> there's a bug in gcc's location list generation or that GDB's dwarf-2 location
> list code isn't as backwardly "safe" as we'd hoped.

The were some bugs in GDB.

> The segfault in gdb 6.0 is in decode_locdesc of dwarf2read.c line 6771,
> where the value of the "blk" pointer looks invalid.
> 
> I'm looking into the issue as best I can (without a debugger :<), but
> I wonder if I could also ask you to investigate?  As a worst case
> scenario, we might consider a patch to disable location lists by
> default, until this failure is resolved?

It is easy to disable it by default in toplev.c:process_options().

Josef


2003-10-09  Daniel Jacobowitz  <drow@mvista.com>

	Merge from mainline:
	2003-07-31  Daniel Jacobowitz  <drow@mvista.com>

	* dwarf2read.c (new_symbol): Use var_decode_location for parameters.

2003-10-09  Daniel Jacobowitz  <drow@mvista.com>

	* dwarf2expr.c (execute_stack_op): Don't treat the frame base as
	a memory pointer.

Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.96.4.2
retrieving revision 1.96.4.3
diff -u -p -r1.96.4.2 -r1.96.4.3
--- gdb/dwarf2read.c	22 Jul 2003 15:44:10 -0000	1.96.4.2
+++ gdb/dwarf2read.c	9 Oct 2003 14:26:14 -0000	1.96.4.3
@@ -5207,32 +5207,10 @@ new_symbol (struct die_info *die, struct
 	  attr = dwarf_attr (die, DW_AT_location);
 	  if (attr)
 	    {
-	      SYMBOL_VALUE (sym) =
-		decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
-	      if (isreg)
-		{
-		  SYMBOL_CLASS (sym) = LOC_REGPARM;
-		  SYMBOL_VALUE (sym) = 
-		    DWARF2_REG_TO_REGNUM (SYMBOL_VALUE (sym));
-		}
-	      else if (offreg)
-		{
-		  if (isderef)
-		    {
-		      if (basereg != frame_base_reg)
-			dwarf2_complex_location_expr_complaint ();
-		      SYMBOL_CLASS (sym) = LOC_REF_ARG;
-		    }
-		  else
-		    {
-		      SYMBOL_CLASS (sym) = LOC_BASEREG_ARG;
-		      SYMBOL_BASEREG (sym) = DWARF2_REG_TO_REGNUM (basereg);
-		    }
-		}
-	      else
-		{
-		  SYMBOL_CLASS (sym) = LOC_ARG;
-		}
+	      var_decode_location (attr, sym, objfile, cu_header);
+	      /* FIXME drow/2003-07-31: Is LOC_COMPUTED_ARG necessary?  */
+	      if (SYMBOL_CLASS (sym) == LOC_COMPUTED)
+		SYMBOL_CLASS (sym) = LOC_COMPUTED_ARG;
 	    }
 	  attr = dwarf_attr (die, DW_AT_const_value);
 	  if (attr)
Index: gdb/dwarf2expr.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2expr.c,v
retrieving revision 1.8.8.1
retrieving revision 1.8.8.2
diff -u -p -r1.8.8.1 -r1.8.8.2
--- gdb/dwarf2expr.c	22 Jul 2003 15:44:10 -0000	1.8.8.1
+++ gdb/dwarf2expr.c	9 Oct 2003 14:16:21 -0000	1.8.8.2
@@ -441,18 +441,6 @@ execute_stack_op (struct dwarf_expr_cont
 	    result = dwarf_expr_fetch (ctx, 0);
 	    if (ctx->in_reg)
 	      result = (ctx->read_reg) (ctx->baton, result);
-	    else
-	      {
-		char *buf = alloca (TARGET_ADDR_BIT / TARGET_CHAR_BIT);
-		int bytes_read;
-
-		(ctx->read_mem) (ctx->baton, buf, result,
-				 TARGET_ADDR_BIT / TARGET_CHAR_BIT);
-		result = dwarf2_read_address (buf,
-					      buf + (TARGET_ADDR_BIT
-						     / TARGET_CHAR_BIT),
-					      &bytes_read);
-	      }
 	    result = result + offset;
 	    ctx->stack_len = before_stack_len;
 	    ctx->in_reg = 0;

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 17:32       ` Rainer Orth
@ 2004-02-21 13:45         ` Rainer Orth
  0 siblings, 0 replies; 44+ messages in thread
From: Rainer Orth @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: zlomj9am, gcc-patches, Kazu Hirata

Daniel Berlin writes:

> Again, see
> http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html
> 
> I have confirmation it works on solaris 9. I expect it to work just as 
> well in your case. :)

Indeed: bootstrap is into stage2 now.

Thanks.
	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 18:12       ` Zack Weinberg
@ 2004-02-21 13:45         ` Zack Weinberg
  0 siblings, 0 replies; 44+ messages in thread
From: Zack Weinberg @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Kazu Hirata; +Cc: dberlin, zlomj9am, gcc-patches

Kazu Hirata <kazu@cs.umass.edu> writes:

> Hi Daniel and Josef,
>
>> > This patch unfortunately breaks the build of h8300-elf.  Specifically,
>> > I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
>> > minimized testcase and the errors I get.
>> 
>> Did you try the patch posted for this (still unreviewed as of yet):
>> http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html
>
> Your patch indeed solves the problem.  Thanks!

This patch is approved.

zw

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-10 18:05                 ` Josef Zlomek
  2004-02-10 18:12                   ` Daniel Berlin
@ 2004-02-21 13:45                   ` Josef Zlomek
  1 sibling, 0 replies; 44+ messages in thread
From: Josef Zlomek @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Richard Henderson, Daniel Berlin, Joern Rennecke, Roger Sayle,
	gcc-patches

> > I'm looking at how to do this "portably". Any suggestions would be 
> > appreciated.
> 
> The only way is to generate a label at the beginning of the section.
> I believe we already do this, in order to built the aranges table,
> so you should be able to reuse those.

Yes, we generate it, it is a variable text_section_label.
Thanks!

Josef

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 16:06   ` Josef Zlomek
@ 2004-02-21 13:45     ` Josef Zlomek
  0 siblings, 0 replies; 44+ messages in thread
From: Josef Zlomek @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Kazu Hirata; +Cc: gcc-patches

> > this patch adds location list support to dwarf2out.c.
> > This generates the location list debug info from the NOTE_INSN_VAR_LOCATION
> > notes produces by the first patch of variable tracking.
> > 
> > Bootstrapped/regtested x86-64 (standalone and together with the first part).
> > 
> > Josef
> > 
> > 2004-02-02  Daniel Berlin <dberlin@dberlin.org>
> >             Josef Zlomek  <zlomekj@suse.cz>
> > 
> >         * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
> >         :
> >         :
> 
> This patch unfortunately breaks the build of h8300-elf.  Specifically,
> I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
> minimized testcase and the errors I get.
> 
> int
> foo (int a)
> {
>   return a;
> }
> 
> /tmp/cchHQ5CR.s: Assembler messages:
> /tmp/cchHQ5CR.s:75: Error: can't resolve `.LVL0' {.text section} - `_.text' {*UND* section}
> /tmp/cchHQ5CR.s:76: Error: can't resolve `.LVL1' {.text section} - `_.text' {*UND* section}
> /tmp/cchHQ5CR.s:75: Error: Difference of symbols in different sections is not supported
> /tmp/cchHQ5CR.s:76: Error: Difference of symbols in different sections is not supported

There is a patch (http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html)
from Daniel Berlin submited several days before which should fix this. 

Josef

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-09 17:26             ` Daniel Berlin
  2004-02-09 21:48               ` Richard Henderson
@ 2004-02-21 13:45               ` Daniel Berlin
  1 sibling, 0 replies; 44+ messages in thread
From: Daniel Berlin @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: Josef Zlomek, Roger Sayle, gcc-patches


On Feb 9, 2004, at 10:37 AM, Joern Rennecke wrote:

>> There should be no need for this hunk of code anymore.
>>
>> Does deleting it help?
>
> Only marginally; it removes nine plain references to _.text,
> but all the differences, which are generated by the code in the loop,
> still refer to it.
>
> Thus I still get 26 errors like this for _muldi3.o :
>
> libgcc2.s: Assembler messages:
> libgcc2.s:278: Error: can't resolve `.text' {.text section} - `_.text' 
> {*UND* section}

I'm looking at how to do this "portably". Any suggestions would be 
appreciated.
I assumed we could difference section names without trouble, but this 
was 3 years ago, when i was young and naive :).

We have to difference against the absolute beginning of the section.
Or waste a *TON* of space and emit base address change entries with 
every location list.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 16:11   ` Rainer Orth
  2004-02-11 17:15     ` Daniel Berlin
@ 2004-02-21 13:45     ` Rainer Orth
  1 sibling, 0 replies; 44+ messages in thread
From: Rainer Orth @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Kazu Hirata; +Cc: zlomj9am, gcc-patches

Kazu Hirata <kazu@cs.umass.edu> writes:

> This patch unfortunately breaks the build of h8300-elf.  Specifically,
> I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
> minimized testcase and the errors I get.

I've the same problem on sparc-sun-solaris2.8 (native assembler) building
the sparcv9 libgcc (where, unlike sparcv7, DWARF-2 is used by default):

$ ./xgcc -B./ -B/vol/gcc/share/sparc-sun-solaris2.8/bin/ -isystem /vol/gcc/share/sparc-sun-solaris2.8/include -isystem /vol/gcc/share/sparc-sun-solaris2.8/sys-include -L/vol/gcc/obj/gcc-3.5.0-20040210/8-gcc/gcc/../ld -O2  -DIN_GCC    -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -I. -I -I/vol/gnu/src/gcc/gcc-dist/gcc -I/vol/gnu/src/gcc/gcc-dist/gcc/ -I/vol/gnu/src/gcc/gcc-dist/gcc/../include   -m64 -DL_muldi3 -c /vol/gnu/src/gcc/gcc-dist/gcc/libgcc2.c -o libgcc/sparcv9/_muldi3.o          
/usr/ccs/bin/as: "/var/tmp//cc71zJdd.s", line 275: error: can't compute value of an expression involving an external symbol
[...]

Line 275 is

        .uaxword        .LLVL0-.text

I suppose the problem is that there's no symbol .text, only

        .section        ".text"

so .text is assumed extern.

Please fix.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University

^ permalink raw reply	[flat|nested] 44+ messages in thread

* debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-09 14:55       ` debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2) Joern Rennecke
  2004-02-09 15:45         ` Daniel Berlin
@ 2004-02-21 13:45         ` Joern Rennecke
  1 sibling, 0 replies; 44+ messages in thread
From: Joern Rennecke @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Josef Zlomek, Daniel Berlin; +Cc: Roger Sayle, gcc-patches

The addition of location list support broke sh-elf and sh64-elf builds.
Presumably all targets with a non-empty USTER_LABEL_PREFIX and dwarf2
debugging information are affected.

The new .debug_loc section contains invalid differences:

.Letext0:
        .section        .debug_loc,"",@progbits
.Ldebug_loc0:
.LLST0:
        .ualong 0xffffffff
        .ualong _.text
        .ualong .LVL0-_.text
        .ualong .LVL2-_.text

This is from the assembly file generated for muldi3 for sh-elf.

Here is a backtrace from the generation of the first invalid difference:

#0  dw2_assemble_integer (size=4, x=0x402aa3c0)
    at ../../srcw/gcc/dwarf2asm.c:50
#1  0x080e4c3f in dw2_asm_output_delta (size=4, lab1=0x83f7418 "*.LVL0", 
    lab2=0x830c42d ".text", 
    comment=0x830c4c0 "Location list begin address (%s)")
    at ../../srcw/gcc/dwarf2asm.c:107
#2  0x080ef71f in output_loc_list (list_head=0x4028be10)
    at ../../srcw/gcc/dwarf2out.c:6661
#3  0x080ee8cf in output_location_lists (die=0x40298b00)
    at ../../srcw/gcc/dwarf2out.c:6168
#4  0x080ee8ff in output_location_lists (die=0x40298ac0)
    at ../../srcw/gcc/dwarf2out.c:6171
#5  0x080ee8ff in output_location_lists (die=0x402097c0)
    at ../../srcw/gcc/dwarf2out.c:6171
#6  0x080ff38d in dwarf2out_finish (
    filename=0x83ee7b0 "../../srcw/gcc/libgcc2.c")
    at ../../srcw/gcc/dwarf2out.c:13439
#7  0x0824f52e in compile_file () at ../../srcw/gcc/toplev.c:1858
#8  0x08254bcc in do_compile () at ../../srcw/gcc/toplev.c:4678
#9  0x08254c62 in toplev_main (argc=19, argv=0xbfffe324)
    at ../../srcw/gcc/toplev.c:4718
#10 0x4004f507 in __libc_start_main (main=0x809e594 <main>, argc=19, 
    ubp_av=0xbfffe324, init=0x80494a0 <_init>, fini=0x82f7180 <_fini>, 
    rtld_fini=0x4000dc14 <_dl_fini>, stack_end=0xbfffe31c)
    at ../sysdeps/generic/libc-start.c:129

AFAIKS the basic problem is that curr->section is used like a label in
output_loc_list, which has been introduced in Daniel Berlin's patch from
2001-05-18 (dwarf2out.c version 1.270), but this code has not been used
during sh-elf or sh64-elf builds before.

The current form of this code is:

  if (strcmp (curr->section, ".text") == 0)
    {
      /* dw2_asm_output_data will mask off any extra bits in the ~0.  */
      dw2_asm_output_data (DWARF2_ADDR_SIZE, ~(unsigned HOST_WIDE_INT) 0,
                           "Location list base address specifier fake entry");
      dw2_asm_output_offset (DWARF2_ADDR_SIZE, curr->section,
                             "Location list base address specifier base");
    }

  /* Walk the location list, and output each range + expression.  */
  for (curr = list_head; curr != NULL; curr = curr->dw_loc_next)
    {
      unsigned long size;
      if (separate_line_info_table_in_use == 0)
        {
          dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->begin, curr->section,
                                "Location list begin address (%s)",
                                list_head->ll_symbol);
          dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->end, curr->section,
                                "Location list end address (%s)",
                                list_head->ll_symbol);
        }

curr->section is ".text"  Since there is no leading '*', LOCAL_LABEL_PREFIX
gets applied, so that we end up with _.text .

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 16:47   ` Daniel Berlin
  2004-02-11 17:50     ` Kazu Hirata
@ 2004-02-21 13:45     ` Daniel Berlin
  1 sibling, 0 replies; 44+ messages in thread
From: Daniel Berlin @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Kazu Hirata; +Cc: zlomj9am, gcc-patches

>
> This patch unfortunately breaks the build of h8300-elf.  Specifically,
> I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
> minimized testcase and the errors I get.
>

Did you try the patch posted for this (still unreviewed as of yet):
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-06  3:34 ` Roger Sayle
  2004-02-06 12:31   ` Josef Zlomek
@ 2004-02-21 13:45   ` Roger Sayle
  1 sibling, 0 replies; 44+ messages in thread
From: Roger Sayle @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Josef Zlomek; +Cc: Daniel Berlin, gcc-patches


On Mon, 2 Feb 2004, Josef Zlomek wrote:
> 2004-02-02  Daniel Berlin <dberlin@dberlin.org>
>             Josef Zlomek  <zlomekj@suse.cz>
>
>         * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
>         at the beginning of function, call dwarf2out_var_location for
>         NOTE_INSN_VAR_LOCATION note.
> 	(struct var_loc_node, struct var_loc_list_def, loclabel_num,
> 	decl_loc_table, decl_loc_table_allocated, decl_loc_table_in_use,
> 	DECL_LOC_TABLE_INCREMENT): New.
> 	(lookup_decl_loc): New function.
> 	(add_var_loc_to_decl): New function.
> 	(based_loc_descr): Added parameter can_use_fbreg, DW_OP_fbreg is used
> 	only if can_use_fbreg.
> 	(mem_loc_descriptor): Added parameter can_use_fbreg, pass it to other
> 	functions.
> 	(loc_descriptor): Likewise. Process VAR_LOCATION.
> 	(concat_loc_descriptor): Call loc_descriptor with can_use_fbreg == true.
> 	(loc_descriptor_from_tree): Call mem_loc_descriptor with
> 	can_use_fbreg == true.
> 	(add_location_or_const_value_attribute): Added parameter enum
> 	dwarf_attribute attr, generate attribute ATTR.  Create the location list.
> 	(add_bound_info): Call loc_descriptor with can_use_fbreg == true.
> 	(gen_formal_parameter_die): Call add_location_or_const_value_attribute
> 	with attr == DW_AT_location.
> 	(gen_subprogram_die): Generate the location list for DW_AT_frame_base
> 	if frame_base_decl is defined and has a location list.
> 	(gen_variable_die): Call add_location_or_const_value_attribute with
> 	attr == DW_AT_location.
>         (dwarf2out_var_location): New function.
>         (dwarf2out_begin_function): New function.
> 	(dwarf2out_init): Create decl_loc_table and initialize
> 	decl_loc_table_allocated and decl_loc_table_in_use.


Ok for mainline.  Given the importance of these patches, I'm surprised
that they haven't already been reviewed.  However, I'm happy to approve
any patches that move us towards omitting the frame pointer by default
on more platforms for 3.5, with the associated improvements in
compile-time, debugging and generated code performance.

Many thanks.

Roger
--

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Variable tracking (location lists support) - part 2
  2004-02-02 20:37 Variable tracking (location lists support) - part 2 Josef Zlomek
  2004-02-06  3:34 ` Roger Sayle
  2004-02-11 14:55 ` Kazu Hirata
@ 2004-02-21 13:45 ` Josef Zlomek
  2 siblings, 0 replies; 44+ messages in thread
From: Josef Zlomek @ 2004-02-21 13:45 UTC (permalink / raw)
  To: gcc-patches

Hello,

this patch adds location list support to dwarf2out.c.
This generates the location list debug info from the NOTE_INSN_VAR_LOCATION
notes produces by the first patch of variable tracking.

Bootstrapped/regtested x86-64 (standalone and together with the first part).

Josef

2004-02-02  Daniel Berlin <dberlin@dberlin.org>
            Josef Zlomek  <zlomekj@suse.cz>

        * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
        at the beginning of function, call dwarf2out_var_location for
        NOTE_INSN_VAR_LOCATION note.
	(struct var_loc_node, struct var_loc_list_def, loclabel_num,
	decl_loc_table, decl_loc_table_allocated, decl_loc_table_in_use,
	DECL_LOC_TABLE_INCREMENT): New.
	(lookup_decl_loc): New function.
	(add_var_loc_to_decl): New function.
	(based_loc_descr): Added parameter can_use_fbreg, DW_OP_fbreg is used
	only if can_use_fbreg.
	(mem_loc_descriptor): Added parameter can_use_fbreg, pass it to other
	functions.
	(loc_descriptor): Likewise. Process VAR_LOCATION.
	(concat_loc_descriptor): Call loc_descriptor with can_use_fbreg == true.
	(loc_descriptor_from_tree): Call mem_loc_descriptor with
	can_use_fbreg == true.
	(add_location_or_const_value_attribute): Added parameter enum
	dwarf_attribute attr, generate attribute ATTR.  Create the location list.
	(add_bound_info): Call loc_descriptor with can_use_fbreg == true.
	(gen_formal_parameter_die): Call add_location_or_const_value_attribute
	with attr == DW_AT_location.
	(gen_subprogram_die): Generate the location list for DW_AT_frame_base
	if frame_base_decl is defined and has a location list.
	(gen_variable_die): Call add_location_or_const_value_attribute with
	attr == DW_AT_location.
        (dwarf2out_var_location): New function.
        (dwarf2out_begin_function): New function.
	(dwarf2out_init): Create decl_loc_table and initialize
	decl_loc_table_allocated and decl_loc_table_in_use.

*** vt-main-part1/gcc/dwarf2out.c	2004-02-02 07:56:34.000000000 +0100
--- vt-main-part2/gcc/dwarf2out.c	2004-02-02 07:56:23.000000000 +0100
*************** static bool dwarf2out_ignore_block (tree
*** 3251,3256 ****
--- 3251,3258 ----
  static void dwarf2out_global_decl (tree);
  static void dwarf2out_imported_module_or_decl (tree, tree);
  static void dwarf2out_abstract_function (tree);
+ static void dwarf2out_var_location (rtx);
+ static void dwarf2out_begin_function (tree);
  
  /* The debug hooks structure.  */
  
*************** const struct gcc_debug_hooks dwarf2_debu
*** 3269,3275 ****
    dwarf2out_begin_prologue,
    debug_nothing_int_charstar,	/* end_prologue */
    dwarf2out_end_epilogue,
!   debug_nothing_tree,		/* begin_function */
    debug_nothing_int,		/* end_function */
    dwarf2out_decl,		/* function_decl */
    dwarf2out_global_decl,
--- 3271,3277 ----
    dwarf2out_begin_prologue,
    debug_nothing_int_charstar,	/* end_prologue */
    dwarf2out_end_epilogue,
!   dwarf2out_begin_function,
    debug_nothing_int,		/* end_function */
    dwarf2out_decl,		/* function_decl */
    dwarf2out_global_decl,
*************** const struct gcc_debug_hooks dwarf2_debu
*** 3281,3287 ****
    dwarf2out_abstract_function,	/* outlining_inline_function */
    debug_nothing_rtx,		/* label */
    debug_nothing_int,		/* handle_pch */
!   debug_nothing_rtx		/* var_location */
  };
  #endif
  \f
--- 3283,3289 ----
    dwarf2out_abstract_function,	/* outlining_inline_function */
    debug_nothing_rtx,		/* label */
    debug_nothing_int,		/* handle_pch */
!   dwarf2out_var_location
  };
  #endif
  \f
*************** static GTY(()) size_t file_table_last_lo
*** 3477,3482 ****
--- 3479,3512 ----
     The key is a DECL_UID() which is a unique number identifying each decl.  */
  static GTY ((param_is (struct die_struct))) htab_t decl_die_table;
  
+ /* Node of the variable location list.  */
+ struct var_loc_node GTY ((chain_next ("%h.next")))
+ {
+   rtx GTY (()) var_loc_note;
+   const char * GTY (()) label;
+   struct var_loc_node * GTY (()) next;
+ };
+ 
+ /* Variable location list.  */
+ struct var_loc_list_def GTY (())
+ {
+   struct var_loc_node * GTY (()) first;
+ 
+   /* Do not mark the last element of the chained list because
+      it is marked through the chain.  */
+   struct var_loc_node * GTY ((skip ("%h"))) last;
+ 
+   /* DECL_UID of the variable decl.  */
+   unsigned int decl_id;
+ };
+ typedef struct var_loc_list_def var_loc_list;
+ 
+ /* Unique label counter.  */
+ static unsigned int loclabel_num = 0;
+ 
+ /* Table of decl location linked lists.  */
+ static GTY ((param_is (var_loc_list))) htab_t decl_loc_table;
+ 
  /* A pointer to the base of a list of references to DIE's that
     are uniquely identified by their tag, presence/absence of
     children DIE's, and list of attribute/value pairs.  */
*************** static void equate_type_number_to_die (t
*** 3651,3657 ****
--- 3681,3691 ----
  static hashval_t decl_die_table_hash (const void *);
  static int decl_die_table_eq (const void *, const void *);
  static dw_die_ref lookup_decl_die (tree);
+ static hashval_t decl_loc_table_hash (const void *);
+ static int decl_loc_table_eq (const void *, const void *);
+ static var_loc_list *lookup_decl_loc (tree);
  static void equate_decl_number_to_die (tree, dw_die_ref);
+ static void add_var_loc_to_decl (tree, struct var_loc_node *);
  static void print_spaces (FILE *);
  static void print_die (dw_die_ref, FILE *);
  static void print_dwarf_line_table (FILE *);
*************** static dw_loc_descr_ref reg_loc_descript
*** 3717,3727 ****
  static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int);
  static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx);
  static dw_loc_descr_ref int_loc_descriptor (HOST_WIDE_INT);
! static dw_loc_descr_ref based_loc_descr (unsigned, HOST_WIDE_INT);
  static int is_based_loc (rtx);
! static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode);
  static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx);
! static dw_loc_descr_ref loc_descriptor (rtx);
  static dw_loc_descr_ref loc_descriptor_from_tree (tree, int);
  static HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
  static tree field_type (tree);
--- 3751,3761 ----
  static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int);
  static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx);
  static dw_loc_descr_ref int_loc_descriptor (HOST_WIDE_INT);
! static dw_loc_descr_ref based_loc_descr (unsigned, HOST_WIDE_INT, bool);
  static int is_based_loc (rtx);
! static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode, bool);
  static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx);
! static dw_loc_descr_ref loc_descriptor (rtx, bool);
  static dw_loc_descr_ref loc_descriptor_from_tree (tree, int);
  static HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
  static tree field_type (tree);
*************** static void add_AT_location_description	
*** 3734,3740 ****
  static void add_data_member_location_attribute (dw_die_ref, tree);
  static void add_const_value_attribute (dw_die_ref, rtx);
  static rtx rtl_for_decl_location (tree);
! static void add_location_or_const_value_attribute (dw_die_ref, tree);
  static void tree_add_const_value_attribute (dw_die_ref, tree);
  static void add_name_attribute (dw_die_ref, const char *);
  static void add_comp_dir_attribute (dw_die_ref);
--- 3768,3775 ----
  static void add_data_member_location_attribute (dw_die_ref, tree);
  static void add_const_value_attribute (dw_die_ref, rtx);
  static rtx rtl_for_decl_location (tree);
! static void add_location_or_const_value_attribute (dw_die_ref, tree,
! 						   enum dwarf_attribute);
  static void tree_add_const_value_attribute (dw_die_ref, tree);
  static void add_name_attribute (dw_die_ref, const char *);
  static void add_comp_dir_attribute (dw_die_ref);
*************** lookup_decl_die (tree decl)
*** 5229,5234 ****
--- 5264,5291 ----
    return htab_find_with_hash (decl_die_table, decl, DECL_UID (decl));
  }
  
+ /* Returns a hash value for X (which really is a var_loc_list).  */
+ 
+ static hashval_t
+ decl_loc_table_hash (const void *x)
+ {
+   return (hashval_t) ((const var_loc_list *) x)->decl_id;
+ }
+ 
+ static int
+ decl_loc_table_eq (const void *x, const void *y)
+ {
+   return (((const var_loc_list *) x)->decl_id == DECL_UID ((const tree) y));
+ }
+ 
+ /* Return the var_loc list associated with a given declaration.  */
+ 
+ static inline var_loc_list *
+ lookup_decl_loc (tree decl)
+ {
+   return htab_find_with_hash (decl_loc_table, decl, DECL_UID (decl));
+ }
+ 
  /* Equate a DIE to a particular declaration.  */
  
  static void
*************** equate_decl_number_to_die (tree decl, dw
*** 5241,5246 ****
--- 5298,5342 ----
    *slot = decl_die;
    decl_die->decl_id = decl_id;
  }
+ 
+ /* Add a variable location node to the linked list for DECL.  */
+ 
+ static void
+ add_var_loc_to_decl (tree decl, struct var_loc_node *loc)
+ {
+   unsigned int decl_id = DECL_UID (decl);
+   var_loc_list *temp;
+   void **slot;
+ 
+   slot = htab_find_slot_with_hash (decl_loc_table, decl, decl_id, INSERT);
+   if (*slot == NULL)
+     {
+       temp = ggc_alloc_cleared (sizeof (var_loc_list));
+       temp->decl_id = decl_id;
+       *slot = temp;
+     }
+   else
+     temp = *slot;
+ 
+   if (temp->last)
+     {
+       /* If the current location is the same as the end of the list,
+ 	 we have nothing to do.  */
+       if (!rtx_equal_p (NOTE_VAR_LOCATION_LOC (temp->last->var_loc_note),
+ 			NOTE_VAR_LOCATION_LOC (loc->var_loc_note)))
+ 	{
+ 	  /* Add LOC to the end of list and update LAST.  */
+ 	  temp->last->next = loc;
+ 	  temp->last = loc;
+ 	}
+     }
+   /* Do not add empty location to the beginning of the list.  */
+   else if (NOTE_VAR_LOCATION_LOC (loc->var_loc_note) != NULL_RTX)
+     {
+       temp->first = loc;
+       temp->last = loc;
+     }
+ }
  \f
  /* Keep track of the number of spaces used to indent the
     output of the debugging routines that print the structure of
*************** int_loc_descriptor (HOST_WIDE_INT i)
*** 8193,8199 ****
  /* Return a location descriptor that designates a base+offset location.  */
  
  static dw_loc_descr_ref
! based_loc_descr (unsigned int reg, HOST_WIDE_INT offset)
  {
    dw_loc_descr_ref loc_result;
    /* For the "frame base", we use the frame pointer or stack pointer
--- 8300,8306 ----
  /* Return a location descriptor that designates a base+offset location.  */
  
  static dw_loc_descr_ref
! based_loc_descr (unsigned int reg, HOST_WIDE_INT offset, bool can_use_fbreg)
  {
    dw_loc_descr_ref loc_result;
    /* For the "frame base", we use the frame pointer or stack pointer
*************** based_loc_descr (unsigned int reg, HOST_
*** 8203,8209 ****
  					 ? HARD_FRAME_POINTER_REGNUM
  					 : STACK_POINTER_REGNUM);
  
!   if (reg == fp_reg)
      loc_result = new_loc_descr (DW_OP_fbreg, offset, 0);
    else if (reg <= 31)
      loc_result = new_loc_descr (DW_OP_breg0 + reg, offset, 0);
--- 8310,8316 ----
  					 ? HARD_FRAME_POINTER_REGNUM
  					 : STACK_POINTER_REGNUM);
  
!   if (reg == fp_reg && can_use_fbreg)
      loc_result = new_loc_descr (DW_OP_fbreg, offset, 0);
    else if (reg <= 31)
      loc_result = new_loc_descr (DW_OP_breg0 + reg, offset, 0);
*************** is_based_loc (rtx rtl)
*** 8237,8246 ****
     MODE is the mode of the memory reference, needed to handle some
     autoincrement addressing modes.
  
     Return 0 if we can't represent the location.  */
  
  static dw_loc_descr_ref
! mem_loc_descriptor (rtx rtl, enum machine_mode mode)
  {
    dw_loc_descr_ref mem_loc_result = NULL;
  
--- 8344,8358 ----
     MODE is the mode of the memory reference, needed to handle some
     autoincrement addressing modes.
  
+    CAN_USE_FBREG is a flag whether we can use DW_AT_frame_base in the location
+    list for RTL. We can't use it when we are emitting location list for
+    virtual variable frame_base_decl (i.e. a location list for DW_AT_frame_base)
+    which describes how frame base changes when !frame_pointer_needed.
+ 
     Return 0 if we can't represent the location.  */
  
  static dw_loc_descr_ref
! mem_loc_descriptor (rtx rtl, enum machine_mode mode, bool can_use_fbreg)
  {
    dw_loc_descr_ref mem_loc_result = NULL;
  
*************** mem_loc_descriptor (rtx rtl, enum machin
*** 8286,8296 ****
  	 memory) so DWARF consumers need to be aware of the subtle
  	 distinction between OP_REG and OP_BASEREG.  */
        if (REGNO (rtl) < FIRST_PSEUDO_REGISTER)
! 	mem_loc_result = based_loc_descr (reg_number (rtl), 0);
        break;
  
      case MEM:
!       mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
        if (mem_loc_result != 0)
  	add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
        break;
--- 8398,8409 ----
  	 memory) so DWARF consumers need to be aware of the subtle
  	 distinction between OP_REG and OP_BASEREG.  */
        if (REGNO (rtl) < FIRST_PSEUDO_REGISTER)
! 	mem_loc_result = based_loc_descr (reg_number (rtl), 0, can_use_fbreg);
        break;
  
      case MEM:
!       mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl),
! 					   can_use_fbreg);
        if (mem_loc_result != 0)
  	add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
        break;
*************** mem_loc_descriptor (rtx rtl, enum machin
*** 8357,8366 ****
      plus:
        if (is_based_loc (rtl))
  	mem_loc_result = based_loc_descr (reg_number (XEXP (rtl, 0)),
! 					  INTVAL (XEXP (rtl, 1)));
        else
  	{
! 	  mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode);
  	  if (mem_loc_result == 0)
  	    break;
  
--- 8470,8481 ----
      plus:
        if (is_based_loc (rtl))
  	mem_loc_result = based_loc_descr (reg_number (XEXP (rtl, 0)),
! 					  INTVAL (XEXP (rtl, 1)),
! 					  can_use_fbreg);
        else
  	{
! 	  mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode,
! 					       can_use_fbreg);
  	  if (mem_loc_result == 0)
  	    break;
  
*************** mem_loc_descriptor (rtx rtl, enum machin
*** 8372,8378 ****
  	  else
  	    {
  	      add_loc_descr (&mem_loc_result,
! 			     mem_loc_descriptor (XEXP (rtl, 1), mode));
  	      add_loc_descr (&mem_loc_result,
  			     new_loc_descr (DW_OP_plus, 0, 0));
  	    }
--- 8487,8494 ----
  	  else
  	    {
  	      add_loc_descr (&mem_loc_result,
! 			     mem_loc_descriptor (XEXP (rtl, 1), mode,
! 						 can_use_fbreg));
  	      add_loc_descr (&mem_loc_result,
  			     new_loc_descr (DW_OP_plus, 0, 0));
  	    }
*************** mem_loc_descriptor (rtx rtl, enum machin
*** 8383,8390 ****
        {
  	/* If a pseudo-reg is optimized away, it is possible for it to
  	   be replaced with a MEM containing a multiply.  */
! 	dw_loc_descr_ref op0 = mem_loc_descriptor (XEXP (rtl, 0), mode);
! 	dw_loc_descr_ref op1 = mem_loc_descriptor (XEXP (rtl, 1), mode);
  
  	if (op0 == 0 || op1 == 0)
  	  break;
--- 8499,8508 ----
        {
  	/* If a pseudo-reg is optimized away, it is possible for it to
  	   be replaced with a MEM containing a multiply.  */
! 	dw_loc_descr_ref op0 = mem_loc_descriptor (XEXP (rtl, 0), mode,
! 						   can_use_fbreg);
! 	dw_loc_descr_ref op1 = mem_loc_descriptor (XEXP (rtl, 1), mode,
! 						   can_use_fbreg);
  
  	if (op0 == 0 || op1 == 0)
  	  break;
*************** mem_loc_descriptor (rtx rtl, enum machin
*** 8403,8413 ****
        /* If this is a MEM, return its address.  Otherwise, we can't
  	 represent this.  */
        if (GET_CODE (XEXP (rtl, 0)) == MEM)
! 	return mem_loc_descriptor (XEXP (XEXP (rtl, 0), 0), mode);
        else
  	return 0;
  
      default:
        abort ();
      }
  
--- 8521,8534 ----
        /* If this is a MEM, return its address.  Otherwise, we can't
  	 represent this.  */
        if (GET_CODE (XEXP (rtl, 0)) == MEM)
! 	return mem_loc_descriptor (XEXP (XEXP (rtl, 0), 0), mode,
! 				   can_use_fbreg);
        else
  	return 0;
  
      default:
+       fprintf (stderr, "\nInvalid mem_loc_descriptor RTL:\n");
+       print_rtl (stderr, rtl);
        abort ();
      }
  
*************** static dw_loc_descr_ref
*** 8421,8428 ****
  concat_loc_descriptor (rtx x0, rtx x1)
  {
    dw_loc_descr_ref cc_loc_result = NULL;
!   dw_loc_descr_ref x0_ref = loc_descriptor (x0);
!   dw_loc_descr_ref x1_ref = loc_descriptor (x1);
  
    if (x0_ref == 0 || x1_ref == 0)
      return 0;
--- 8542,8549 ----
  concat_loc_descriptor (rtx x0, rtx x1)
  {
    dw_loc_descr_ref cc_loc_result = NULL;
!   dw_loc_descr_ref x0_ref = loc_descriptor (x0, true);
!   dw_loc_descr_ref x1_ref = loc_descriptor (x1, true);
  
    if (x0_ref == 0 || x1_ref == 0)
      return 0;
*************** concat_loc_descriptor (rtx x0, rtx x1)
*** 8449,8455 ****
     If we don't know how to describe it, return 0.  */
  
  static dw_loc_descr_ref
! loc_descriptor (rtx rtl)
  {
    dw_loc_descr_ref loc_result = NULL;
  
--- 8570,8576 ----
     If we don't know how to describe it, return 0.  */
  
  static dw_loc_descr_ref
! loc_descriptor (rtx rtl, bool can_use_fbreg)
  {
    dw_loc_descr_ref loc_result = NULL;
  
*************** loc_descriptor (rtx rtl)
*** 8470,8482 ****
        break;
  
      case MEM:
!       loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
        break;
  
      case CONCAT:
        loc_result = concat_loc_descriptor (XEXP (rtl, 0), XEXP (rtl, 1));
        break;
  
      default:
        abort ();
      }
--- 8591,8639 ----
        break;
  
      case MEM:
!       loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl),
! 				       can_use_fbreg);
        break;
  
      case CONCAT:
        loc_result = concat_loc_descriptor (XEXP (rtl, 0), XEXP (rtl, 1));
        break;
  
+     case VAR_LOCATION:
+       /* Single part.  */
+       if (GET_CODE (XEXP (rtl, 1)) != PARALLEL)
+ 	{
+ 	  loc_result = loc_descriptor (XEXP (XEXP (rtl, 1), 0), can_use_fbreg);
+ 	}
+       /* Multiple parts.  */
+       else
+ 	{
+ 	  rtvec par_elems = XVEC (XEXP (rtl, 1), 0);
+ 	  int num_elem = GET_NUM_ELEM (par_elems);
+ 	  enum machine_mode mode;
+ 	  int i;
+ 
+ 	  /* Create the first one, so we have something to add to.  */
+ 	  loc_result = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0),
+ 				       can_use_fbreg);
+ 	  mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0));
+ 	  add_loc_descr (&loc_result,
+ 			 new_loc_descr (DW_OP_piece, GET_MODE_SIZE (mode), 0));
+ 	  for (i = 1; i < num_elem; i++)
+ 	    {
+ 	      dw_loc_descr_ref temp;
+ 
+ 	      temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0),
+ 				     can_use_fbreg);
+ 	      add_loc_descr (&loc_result, temp);
+ 	      mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0));
+ 	      add_loc_descr (&loc_result,
+ 			     new_loc_descr (DW_OP_piece,
+ 					    GET_MODE_SIZE (mode), 0));
+ 	    }
+ 	}
+       break;
+ 
      default:
        abort ();
      }
*************** loc_descriptor_from_tree (tree loc, int 
*** 8592,8598 ****
  		rtl = XEXP (rtl, 0);
  	      }
  
! 	    ret = mem_loc_descriptor (rtl, mode);
  	  }
        }
        break;
--- 8749,8755 ----
  		rtl = XEXP (rtl, 0);
  	      }
  
! 	    ret = mem_loc_descriptor (rtl, mode, true);
  	  }
        }
        break;
*************** loc_descriptor_from_tree (tree loc, int 
*** 8676,8682 ****
  	rtl = (*targetm.delegitimize_address) (rtl);
  
  	indirect_p = 1;
! 	ret = mem_loc_descriptor (rtl, mode);
  	break;
        }
  
--- 8833,8839 ----
  	rtl = (*targetm.delegitimize_address) (rtl);
  
  	indirect_p = 1;
! 	ret = mem_loc_descriptor (rtl, mode, true);
  	break;
        }
  
*************** rtl_for_decl_location (tree decl)
*** 9471,9486 ****
     function call evaluates to a compile-time constant address.  */
  
  static void
! add_location_or_const_value_attribute (dw_die_ref die, tree decl)
  {
    rtx rtl;
    dw_loc_descr_ref descr;
  
    if (TREE_CODE (decl) == ERROR_MARK)
      return;
    else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
      abort ();
  
    rtl = rtl_for_decl_location (decl);
    if (rtl == NULL_RTX)
      return;
--- 9628,9737 ----
     function call evaluates to a compile-time constant address.  */
  
  static void
! add_location_or_const_value_attribute (dw_die_ref die, tree decl,
! 				       enum dwarf_attribute attr)
  {
    rtx rtl;
    dw_loc_descr_ref descr;
+   var_loc_list *loc_list;
  
    if (TREE_CODE (decl) == ERROR_MARK)
      return;
    else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
      abort ();
  
+   /* See if we possibly have multiple locations for this variable.  */
+   loc_list = lookup_decl_loc (decl);
+ 
+   /* If it truly has multiple locations, the first and last node will
+      differ.  */
+   if (loc_list && loc_list->first != loc_list->last)
+     {
+       const char *secname;
+       const char *endname;
+       dw_loc_list_ref list;
+       rtx varloc;
+       struct var_loc_node *node;
+ 
+       /* We need to figure out what section we should use as the base
+ 	 for the address ranges where a given location is valid.
+ 	 1. If this particular DECL has a section associated with it,
+ 	 use that.
+ 	 2. If this function has a section associated with it, use
+ 	 that.
+ 	 3. Otherwise, use the text section.
+ 	 XXX: If you split a variable across multiple sections, this
+ 	 won't notice.  */
+ 
+       if (DECL_SECTION_NAME (decl))
+ 	{
+ 	  tree sectree = DECL_SECTION_NAME (decl);
+ 	  secname = TREE_STRING_POINTER (sectree);
+ 	}
+       else if (current_function_decl
+ 	       && DECL_SECTION_NAME (current_function_decl))
+ 	{
+ 	  tree sectree = DECL_SECTION_NAME (current_function_decl);
+ 	  secname = TREE_STRING_POINTER (sectree);
+ 	}
+       else
+ 	secname = TEXT_SECTION_NAME;
+ 
+       /* Now that we know what section we are using for a base,
+          actually construct the list of locations.
+ 	 The first location information is what is passed to the
+ 	 function that creates the location list, and the remaining
+ 	 locations just get added on to that list.
+ 	 Note that we only know the start address for a location
+ 	 (IE location changes), so to build the range, we use
+ 	 the range [current location start, next location start].
+ 	 This means we have to special case the last node, and generate
+ 	 a range of [last location start, end of function label].  */
+ 
+       node = loc_list->first;
+       varloc = NOTE_VAR_LOCATION (node->var_loc_note);
+       list = new_loc_list (loc_descriptor (varloc, attr != DW_AT_frame_base),
+ 			   node->label, node->next->label, secname, 1);
+       node = node->next;
+ 
+       for (; node->next; node = node->next)
+ 	if (NOTE_VAR_LOCATION_LOC (node->var_loc_note) != NULL_RTX)
+ 	  {
+ 	    /* The variable has a location between NODE->LABEL and
+ 	       NODE->NEXT->LABEL.  */
+ 	    varloc = NOTE_VAR_LOCATION (node->var_loc_note);
+ 	    add_loc_descr_to_loc_list (&list,
+ 				       loc_descriptor (varloc,
+ 						       attr != DW_AT_frame_base),
+ 				       node->label, node->next->label, secname);
+ 	  }
+ 
+       /* If the variable has a location at the last label
+ 	 it keeps its location until the end of function.  */
+       if (NOTE_VAR_LOCATION_LOC (node->var_loc_note) != NULL_RTX)
+ 	{
+ 	  char label_id[MAX_ARTIFICIAL_LABEL_BYTES];
+ 
+ 	  varloc = NOTE_VAR_LOCATION (node->var_loc_note);
+ 	  if (!current_function_decl)
+ 	    endname = text_end_label;
+ 	  else
+ 	    {
+ 	      ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL,
+ 					   current_function_funcdef_no);
+ 	      endname = ggc_strdup (label_id);
+ 	    }
+ 	  add_loc_descr_to_loc_list (&list,
+ 				     loc_descriptor (varloc,
+ 						     attr != DW_AT_frame_base),
+ 				     node->label, endname, secname);
+ 	}
+ 
+       /* Finally, add the location list to the DIE, and we are done.  */
+       add_AT_loc_list (die, attr, list);
+       return;
+     }
+ 
    rtl = rtl_for_decl_location (decl);
    if (rtl == NULL_RTX)
      return;
*************** add_location_or_const_value_attribute (d
*** 9517,9525 ****
  	case REG:
  	case SUBREG:
  	case CONCAT:
! 	  descr = loc_descriptor (rtl);
  	}
!       add_AT_location_description (die, DW_AT_location, descr);
        break;
  
      case PARALLEL:
--- 9768,9776 ----
  	case REG:
  	case SUBREG:
  	case CONCAT:
! 	  descr = loc_descriptor (rtl, true);
  	}
!       add_AT_location_description (die, attr, descr);
        break;
  
      case PARALLEL:
*************** add_location_or_const_value_attribute (d
*** 9530,9536 ****
  	int i;
  
  	/* Create the first one, so we have something to add to.  */
! 	descr = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0));
  	mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0));
  	add_loc_descr (&descr,
  		       new_loc_descr (DW_OP_piece, GET_MODE_SIZE (mode), 0));
--- 9781,9787 ----
  	int i;
  
  	/* Create the first one, so we have something to add to.  */
! 	descr = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0), true);
  	mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0));
  	add_loc_descr (&descr,
  		       new_loc_descr (DW_OP_piece, GET_MODE_SIZE (mode), 0));
*************** add_location_or_const_value_attribute (d
*** 9538,9544 ****
  	  {
  	    dw_loc_descr_ref temp;
  
! 	    temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0));
  	    add_loc_descr (&descr, temp);
  	    mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0));
  	    add_loc_descr (&descr,
--- 9789,9795 ----
  	  {
  	    dw_loc_descr_ref temp;
  
! 	    temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0), true);
  	    add_loc_descr (&descr, temp);
  	    mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0));
  	    add_loc_descr (&descr,
*************** add_bound_info (dw_die_ref subrange_die,
*** 9684,9690 ****
  	  add_AT_flag (decl_die, DW_AT_artificial, 1);
  	  add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
  	  add_AT_location_description (decl_die, DW_AT_location,
! 				       loc_descriptor (loc));
  	  add_AT_die_ref (subrange_die, bound_attr, decl_die);
  	}
  
--- 9935,9941 ----
  	  add_AT_flag (decl_die, DW_AT_artificial, 1);
  	  add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
  	  add_AT_location_description (decl_die, DW_AT_location,
! 				       loc_descriptor (loc, true));
  	  add_AT_die_ref (subrange_die, bound_attr, decl_die);
  	}
  
*************** gen_formal_parameter_die (tree node, dw_
*** 10507,10513 ****
  
        equate_decl_number_to_die (node, parm_die);
        if (! DECL_ABSTRACT (node))
! 	add_location_or_const_value_attribute (parm_die, node);
  
        break;
  
--- 10758,10764 ----
  
        equate_decl_number_to_die (node, parm_die);
        if (! DECL_ABSTRACT (node))
! 	add_location_or_const_value_attribute (parm_die, node, DW_AT_location);
  
        break;
  
*************** gen_subprogram_die (tree decl, dw_die_re
*** 10841,10849 ****
        /* Define the "frame base" location for this routine.  We use the
  	 frame pointer or stack pointer registers, since the RTL for local
  	 variables is relative to one of them.  */
!       fp_reg
! 	= frame_pointer_needed ? hard_frame_pointer_rtx : stack_pointer_rtx;
!       add_AT_loc (subr_die, DW_AT_frame_base, reg_loc_descriptor (fp_reg));
  
  #if 0
        /* ??? This fails for nested inline functions, because context_display
--- 11092,11108 ----
        /* Define the "frame base" location for this routine.  We use the
  	 frame pointer or stack pointer registers, since the RTL for local
  	 variables is relative to one of them.  */
!       if (frame_base_decl && lookup_decl_loc (frame_base_decl) != NULL)
! 	{
! 	  add_location_or_const_value_attribute (subr_die, frame_base_decl,
! 						 DW_AT_frame_base);
! 	}
!       else
! 	{
! 	  fp_reg
! 	    = frame_pointer_needed ? hard_frame_pointer_rtx : stack_pointer_rtx;
! 	  add_AT_loc (subr_die, DW_AT_frame_base, reg_loc_descriptor (fp_reg));
! 	}
  
  #if 0
        /* ??? This fails for nested inline functions, because context_display
*************** gen_variable_die (tree decl, dw_die_ref 
*** 11012,11018 ****
  
    if (! declaration && ! DECL_ABSTRACT (decl))
      {
!       add_location_or_const_value_attribute (var_die, decl);
        add_pubname (decl, var_die);
      }
    else
--- 11271,11277 ----
  
    if (! declaration && ! DECL_ABSTRACT (decl))
      {
!       add_location_or_const_value_attribute (var_die, decl, DW_AT_location);
        add_pubname (decl, var_die);
      }
    else
*************** init_file_table (void)
*** 12531,12536 ****
--- 12790,12850 ----
    file_table_last_lookup_index = 0;
  }
  
+ /* Called by the final INSN scan whenever we see a var location.  We
+    use it to drop labels in the right places, and throw the location in
+    our lookup table.  */
+ 
+ static void
+ dwarf2out_var_location (rtx loc_note)
+ {
+   char loclabel[MAX_ARTIFICIAL_LABEL_BYTES];
+   struct var_loc_node *newloc;
+   rtx prev_insn;
+   static rtx last_insn;
+   static const char *last_label;
+ 
+   if (!DECL_P (NOTE_VAR_LOCATION_DECL (loc_note)))
+     return;
+   prev_insn = PREV_INSN (loc_note);
+ 
+   newloc = ggc_alloc_cleared (sizeof (struct var_loc_node));
+   /* If the insn we processed last time is the previous insn
+      and it is also a var location note, use the label we emitted
+      last time.  */
+   if (last_insn != NULL_RTX
+       && last_insn == prev_insn
+       && GET_CODE (prev_insn) == NOTE
+       && NOTE_LINE_NUMBER (prev_insn) == NOTE_INSN_VAR_LOCATION)
+     {
+       newloc->label = last_label;
+     }
+   else
+     {
+       ASM_GENERATE_INTERNAL_LABEL (loclabel, "LVL", loclabel_num);
+       ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LVL", loclabel_num);
+       loclabel_num++;
+       newloc->label = ggc_strdup (loclabel);
+     }
+   newloc->var_loc_note = loc_note;
+   newloc->next = NULL;
+ 
+   last_insn = loc_note;
+   last_label = newloc->label;
+ 
+   add_var_loc_to_decl (NOTE_VAR_LOCATION_DECL (loc_note), newloc);
+ }
+ 
+ /* We need to reset the locations at the beginning of each
+    function. We can't do this in the end_function hook, because the
+    declarations that use the locations won't have been outputted when
+    that hook is called.  */
+ 
+ static void
+ dwarf2out_begin_function (tree unused ATTRIBUTE_UNUSED)
+ {
+   htab_empty (decl_loc_table);
+ }
+ 
  /* Output a label to mark the beginning of a source code line entry
     and record information relating to this source line, in
     'line_info_table' for later output of the .debug_line section.  */
*************** dwarf2out_init (const char *filename ATT
*** 12707,12712 ****
--- 13021,13030 ----
    decl_die_table = htab_create_ggc (10, decl_die_table_hash,
  				    decl_die_table_eq, NULL);
  
+   /* Allocate the initial hunk of the decl_loc_table.  */
+   decl_loc_table = htab_create_ggc (10, decl_loc_table_hash,
+ 				    decl_loc_table_eq, NULL);
+ 
    /* Allocate the initial hunk of the decl_scope_table.  */
    VARRAY_TREE_INIT (decl_scope_table, 256, "decl_scope_table");
  

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-09 16:34           ` Joern Rennecke
  2004-02-09 17:26             ` Daniel Berlin
@ 2004-02-21 13:45             ` Joern Rennecke
  1 sibling, 0 replies; 44+ messages in thread
From: Joern Rennecke @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: Josef Zlomek, Roger Sayle, gcc-patches, Joern Rennecke

> There should be no need for this hunk of code anymore.
> 
> Does deleting it help?

Only marginally; it removes nine plain references to _.text,
but all the differences, which are generated by the code in the loop,
still refer to it.

Thus I still get 26 errors like this for _muldi3.o :

libgcc2.s: Assembler messages:
libgcc2.s:278: Error: can't resolve `.text' {.text section} - `_.text' {*UND* section}

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-06 12:31   ` Josef Zlomek
  2004-02-06 12:32     ` Josef Zlomek
  2004-02-06 13:41     ` Roger Sayle
@ 2004-02-21 13:45     ` Josef Zlomek
  2 siblings, 0 replies; 44+ messages in thread
From: Josef Zlomek @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Roger Sayle; +Cc: Daniel Berlin, gcc-patches

> > 2004-02-02  Daniel Berlin <dberlin@dberlin.org>
> >             Josef Zlomek  <zlomekj@suse.cz>
> >
> >         * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
> >         at the beginning of function, call dwarf2out_var_location for
> >         NOTE_INSN_VAR_LOCATION note.
> > 	(struct var_loc_node, struct var_loc_list_def, loclabel_num,
> > 	decl_loc_table, decl_loc_table_allocated, decl_loc_table_in_use,
> > 	DECL_LOC_TABLE_INCREMENT): New.
> > 	(lookup_decl_loc): New function.
> > 	(add_var_loc_to_decl): New function.
> > 	(based_loc_descr): Added parameter can_use_fbreg, DW_OP_fbreg is used
> > 	only if can_use_fbreg.
> > 	(mem_loc_descriptor): Added parameter can_use_fbreg, pass it to other
> > 	functions.
> > 	(loc_descriptor): Likewise. Process VAR_LOCATION.
> > 	(concat_loc_descriptor): Call loc_descriptor with can_use_fbreg == true.
> > 	(loc_descriptor_from_tree): Call mem_loc_descriptor with
> > 	can_use_fbreg == true.
> > 	(add_location_or_const_value_attribute): Added parameter enum
> > 	dwarf_attribute attr, generate attribute ATTR.  Create the location list.
> > 	(add_bound_info): Call loc_descriptor with can_use_fbreg == true.
> > 	(gen_formal_parameter_die): Call add_location_or_const_value_attribute
> > 	with attr == DW_AT_location.
> > 	(gen_subprogram_die): Generate the location list for DW_AT_frame_base
> > 	if frame_base_decl is defined and has a location list.
> > 	(gen_variable_die): Call add_location_or_const_value_attribute with
> > 	attr == DW_AT_location.
> >         (dwarf2out_var_location): New function.
> >         (dwarf2out_begin_function): New function.
> > 	(dwarf2out_init): Create decl_loc_table and initialize
> > 	decl_loc_table_allocated and decl_loc_table_in_use.
> 
> 
> Ok for mainline.

Thanks :-)
What about the other related patches ?

Variable tracking (location lists support) - part 1
http://gcc.gnu.org/ml/gcc-patches/2004-01/msg03266.html

Fixes to dwarf2out.c WRT location lists
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00110.html

Josef

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 14:55 ` Kazu Hirata
                     ` (2 preceding siblings ...)
  2004-02-11 16:47   ` Daniel Berlin
@ 2004-02-21 13:45   ` Kazu Hirata
  3 siblings, 0 replies; 44+ messages in thread
From: Kazu Hirata @ 2004-02-21 13:45 UTC (permalink / raw)
  To: zlomj9am; +Cc: gcc-patches

Hi Josef,

> this patch adds location list support to dwarf2out.c.
> This generates the location list debug info from the NOTE_INSN_VAR_LOCATION
> notes produces by the first patch of variable tracking.
> 
> Bootstrapped/regtested x86-64 (standalone and together with the first part).
> 
> Josef
> 
> 2004-02-02  Daniel Berlin <dberlin@dberlin.org>
>             Josef Zlomek  <zlomekj@suse.cz>
> 
>         * dwarf2out.c (struct gcc_debug_hooks): Call dwarf2out_begin_function
>         :
>         :

This patch unfortunately breaks the build of h8300-elf.  Specifically,
I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
minimized testcase and the errors I get.

int
foo (int a)
{
  return a;
}

/tmp/cchHQ5CR.s: Assembler messages:
/tmp/cchHQ5CR.s:75: Error: can't resolve `.LVL0' {.text section} - `_.text' {*UND* section}
/tmp/cchHQ5CR.s:76: Error: can't resolve `.LVL1' {.text section} - `_.text' {*UND* section}
/tmp/cchHQ5CR.s:75: Error: Difference of symbols in different sections is not supported
/tmp/cchHQ5CR.s:76: Error: Difference of symbols in different sections is not supported

Compiling the above testcase, GCC with your patch outputs several new
lines compared to what GCC outputs without your patch, some of which
are

       .2byte  .LVL0-_.text
       .2byte  .LVL1-_.text

gas for H8 does not support a difference of two labels.  I am not
familiar with debugging formats.  Does dwarf2 require a difference of
two labels?  Is there a way around it?

Thanks,

Kazu Hirata

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-10 18:12                   ` Daniel Berlin
@ 2004-02-21 13:45                     ` Daniel Berlin
  0 siblings, 0 replies; 44+ messages in thread
From: Daniel Berlin @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Josef Zlomek; +Cc: Joern Rennecke, gcc-patches, Richard Henderson, Roger Sayle


On Feb 10, 2004, at 12:19 PM, Josef Zlomek wrote:

>>> I'm looking at how to do this "portably". Any suggestions would be
>>> appreciated.
>>
>> The only way is to generate a label at the beginning of the section.
>> I believe we already do this, in order to built the aranges table,
>> so you should be able to reuse those.
>
> Yes, we generate it, it is a variable text_section_label.
>
Hence the patch i submitted, which is reported to fix the problem.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2)
  2004-02-09 21:48               ` Richard Henderson
  2004-02-10 18:05                 ` Josef Zlomek
@ 2004-02-21 13:45                 ` Richard Henderson
  1 sibling, 0 replies; 44+ messages in thread
From: Richard Henderson @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: Joern Rennecke, Josef Zlomek, Roger Sayle, gcc-patches

On Mon, Feb 09, 2004 at 10:45:54AM -0500, Daniel Berlin wrote:
> I'm looking at how to do this "portably". Any suggestions would be 
> appreciated.

The only way is to generate a label at the beginning of the section.
I believe we already do this, in order to built the aranges table,
so you should be able to reuse those.


r~

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-08 22:24       ` Roger Sayle
  2004-02-08 23:01         ` Josef Zlomek
@ 2004-02-21 13:45         ` Roger Sayle
  1 sibling, 0 replies; 44+ messages in thread
From: Roger Sayle @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Josef Zlomek; +Cc: Daniel Berlin, gcc-patches


Hi Josef and Dan,

I've just discovered that typing "gdb cc1" on i686-pc-linux-gnu with
a recently built mainline GCC, causes both gdb 6.0 and gdb 5.2.1 to
segmentation fault.  Given that 6.0 is the most recent release of GDB,
I suspect that either there's a bug in gcc's location list generation
or that GDB's dwarf-2 location list code isn't as backwardly "safe"
as we'd hoped.

The segfault in gdb 6.0 is in decode_locdesc of dwarf2read.c line 6771,
where the value of the "blk" pointer looks invalid.

I'm looking into the issue as best I can (without a debugger :<), but
I wonder if I could also ask you to investigate?  As a worst case
scenario, we might consider a patch to disable location lists by
default, until this failure is resolved?

Many thanks in advance,

Roger
--

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-11 17:15     ` Daniel Berlin
  2004-02-11 17:32       ` Rainer Orth
@ 2004-02-21 13:45       ` Daniel Berlin
  1 sibling, 0 replies; 44+ messages in thread
From: Daniel Berlin @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Rainer Orth; +Cc: zlomj9am, gcc-patches, Kazu Hirata


On Feb 11, 2004, at 10:44 AM, Rainer Orth wrote:

> Kazu Hirata <kazu@cs.umass.edu> writes:
>
>> This patch unfortunately breaks the build of h8300-elf.  Specifically,
>> I get assembler errors while compiling muldi3 of libgcc2.c.  Here is a
>> minimized testcase and the errors I get.
>
> I've the same problem on sparc-sun-solaris2.8 (native assembler) 
> building
> the sparcv9 libgcc (where, unlike sparcv7, DWARF-2 is used by default):
>
> $ ./xgcc -B./ -B/vol/gcc/share/sparc-sun-solaris2.8/bin/ -isystem 
> /vol/gcc/share/sparc-sun-solaris2.8/include -isystem 
> /vol/gcc/share/sparc-sun-solaris2.8/sys-include 
> -L/vol/gcc/obj/gcc-3.5.0-20040210/8-gcc/gcc/../ld -O2  -DIN_GCC    -W 
> -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes 
> -Wold-style-definition  -isystem ./include  -fPIC -g 
> -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -I. -I 
> -I/vol/gnu/src/gcc/gcc-dist/gcc -I/vol/gnu/src/gcc/gcc-dist/gcc/ 
> -I/vol/gnu/src/gcc/gcc-dist/gcc/../include   -m64 -DL_muldi3 -c 
> /vol/gnu/src/gcc/gcc-dist/gcc/libgcc2.c -o libgcc/sparcv9/_muldi3.o
> /usr/ccs/bin/as: "/var/tmp//cc71zJdd.s", line 275: error: can't 
> compute value of an expression involving an external symbol
> [...]
>
> Line 275 is
>
>         .uaxword        .LLVL0-.text
>
> I suppose the problem is that there's no symbol .text, only
>
>         .section        ".text"
>
> so .text is assumed extern.
>
> Please fix.

Again, see
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00826.html

I have confirmation it works on solaris 9. I expect it to work just as 
well in your case. :)

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Variable tracking (location lists support) - part 2
  2004-02-06 13:41     ` Roger Sayle
  2004-02-08 22:24       ` Roger Sayle
@ 2004-02-21 13:45       ` Roger Sayle
  1 sibling, 0 replies; 44+ messages in thread
From: Roger Sayle @ 2004-02-21 13:45 UTC (permalink / raw)
  To: Josef Zlomek; +Cc: Daniel Berlin, gcc-patches


Hi Josef,
> What about the other related patches ?
>
> Variable tracking (location lists support) - part 1
> http://gcc.gnu.org/ml/gcc-patches/2004-01/msg03266.html

This is OK too.  We'll recover the 2% slowdown, when we gain the much
larger speed-up from -fomit-frame-pointer.


> Fixes to dwarf2out.c WRT location lists
> http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00110.html

I've approved Dan's posting of this patch :>

Roger
--

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2004-02-11 17:57 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-02 20:37 Variable tracking (location lists support) - part 2 Josef Zlomek
2004-02-06  3:34 ` Roger Sayle
2004-02-06 12:31   ` Josef Zlomek
2004-02-06 12:32     ` Josef Zlomek
2004-02-09 14:55       ` debug info breaks build (Was: Re: Variable tracking (location lists support) - part 2) Joern Rennecke
2004-02-09 15:45         ` Daniel Berlin
2004-02-09 16:34           ` Joern Rennecke
2004-02-09 17:26             ` Daniel Berlin
2004-02-09 21:48               ` Richard Henderson
2004-02-10 18:05                 ` Josef Zlomek
2004-02-10 18:12                   ` Daniel Berlin
2004-02-21 13:45                     ` Daniel Berlin
2004-02-21 13:45                   ` Josef Zlomek
2004-02-21 13:45                 ` Richard Henderson
2004-02-21 13:45               ` Daniel Berlin
2004-02-21 13:45             ` Joern Rennecke
2004-02-21 13:45           ` Daniel Berlin
2004-02-21 13:45         ` Joern Rennecke
2004-02-21 13:45       ` Variable tracking (location lists support) - part 2 Josef Zlomek
2004-02-06 13:41     ` Roger Sayle
2004-02-08 22:24       ` Roger Sayle
2004-02-08 23:01         ` Josef Zlomek
2004-02-21 13:45           ` Josef Zlomek
2004-02-21 13:45         ` Roger Sayle
2004-02-21 13:45       ` Roger Sayle
2004-02-21 13:45     ` Josef Zlomek
2004-02-21 13:45   ` Roger Sayle
2004-02-11 14:55 ` Kazu Hirata
2004-02-11 16:06   ` Josef Zlomek
2004-02-21 13:45     ` Josef Zlomek
2004-02-11 16:11   ` Rainer Orth
2004-02-11 17:15     ` Daniel Berlin
2004-02-11 17:32       ` Rainer Orth
2004-02-21 13:45         ` Rainer Orth
2004-02-21 13:45       ` Daniel Berlin
2004-02-21 13:45     ` Rainer Orth
2004-02-11 16:47   ` Daniel Berlin
2004-02-11 17:50     ` Kazu Hirata
2004-02-11 18:12       ` Zack Weinberg
2004-02-21 13:45         ` Zack Weinberg
2004-02-21 13:45       ` Kazu Hirata
2004-02-21 13:45     ` Daniel Berlin
2004-02-21 13:45   ` Kazu Hirata
2004-02-21 13:45 ` Josef Zlomek

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).