This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c/4259: dwarf2out.c ignores the garbage collector



>Number:         4259
>Category:       c
>Synopsis:       dwarf2out.c ignores the garbage collector
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 07 10:26:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     tim@fungible.com
>Release:        gcc 3.0.1; current CVS
>Organization:
>Environment:
Any time you generate dwarf2 format debug records.
>Description:
dwarf2out does not pay due attention to the garbage 
collector.  Specifically, decl_scope_table and 
incomplete_types need to become varray's and to 
be registered as roots.  Here's a patch against
gcc 3.0.1 that also seems to work against this morning's
CVS tree.  This fixes bugs 4212 and 4215.
>How-To-Repeat:
Same instructions as bug 4215.
>Fix:

*** dwarf2out.c.orig	Fri Sep  7 06:32:29 2001
--- dwarf2out.c	Fri Sep  7 09:52:26 2001
***************
*** 3210,3226 ****
     of declaration scopes at the current scope and containing
     scopes.  This table is used to find the proper place to
     define type declaration DIE's.  */
! static tree *decl_scope_table;
! 
! /* Number of elements currently allocated for the decl_scope_table.  */
! static int decl_scope_table_allocated;
! 
! /* Current level of nesting of declaration scopes.  */
! static int decl_scope_depth;
! 
! /* Size (in elements) of increments by which we may expand the
!    decl_scope_table.  */
! #define DECL_SCOPE_TABLE_INCREMENT 64
  
  /* A pointer to the base of a list of references to DIE's that
     are uniquely identified by their tag, presence/absence of
--- 3210,3216 ----
     of declaration scopes at the current scope and containing
     scopes.  This table is used to find the proper place to
     define type declaration DIE's.  */
! varray_type decl_scope_table;
  
  /* A pointer to the base of a list of references to DIE's that
     are uniquely identified by their tag, presence/absence of
***************
*** 3290,3309 ****
  #define ARANGE_TABLE_INCREMENT 64
  
  /* A pointer to the base of a list of incomplete types which might be
!    completed at some later time.  */
! 
! static tree *incomplete_types_list;
! 
! /* Number of elements currently allocated for the incomplete_types_list.  */
! static unsigned incomplete_types_allocated;
! 
! /* Number of elements of incomplete_types_list currently in use.  */
! static unsigned incomplete_types;
! 
! /* Size (in elements) of increments by which we may expand the incomplete
!    types list.  Actually, a single hunk of space of this size should
!    be enough for most typical programs.	 */
! #define INCOMPLETE_TYPES_INCREMENT 64
  
  /* Record whether the function being analyzed contains inlined functions.  */
  static int current_function_has_inlines;
--- 3280,3290 ----
  #define ARANGE_TABLE_INCREMENT 64
  
  /* A pointer to the base of a list of incomplete types which might be
!    completed at some later time.  incomplete_types_list needs to be a VARRAY
!    because we want to tell the garbage collector about it.  If we don't tell
!    the garbage collector about it, we can garbage collect live data.
!    Bug 4215.*/
! varray_type incomplete_types;
  
  /* Record whether the function being analyzed contains inlined functions.  */
  static int current_function_has_inlines;
***************
*** 8789,8814 ****
  push_decl_scope (scope)
       tree scope;
  {
!   /* Make room in the decl_scope_table, if necessary.  */
!   if (decl_scope_table_allocated == decl_scope_depth)
!     {
!       decl_scope_table_allocated += DECL_SCOPE_TABLE_INCREMENT;
!       decl_scope_table
! 	= (tree *) xrealloc (decl_scope_table,
! 			     decl_scope_table_allocated * sizeof (tree));
!     }
! 
!   decl_scope_table[decl_scope_depth] = scope;
!   decl_scope_depth++;
  }
  
  /* Pop a declaration scope.  */
  static inline void
  pop_decl_scope ()
  {
!   if (decl_scope_depth <= 0)
      abort ();
!   --decl_scope_depth;
  }
  
  /* Return the DIE for the scope that immediately contains this type.
--- 8770,8785 ----
  push_decl_scope (scope)
       tree scope;
  {
!   VARRAY_PUSH_TREE (decl_scope_table, scope);
  }
  
  /* Pop a declaration scope.  */
  static inline void
  pop_decl_scope ()
  {
!   if (VARRAY_ACTIVE_SIZE (decl_scope_table) <= 0)
      abort ();
!   VARRAY_POP (decl_scope_table);
  }
  
  /* Return the DIE for the scope that immediately contains this type.
***************
*** 8850,8857 ****
  	 first we check to see if we're in the middle of emitting it
  	 so we know where the new DIE should go.  */
  
!       for (i = decl_scope_depth - 1; i >= 0; --i)
! 	if (decl_scope_table[i] == containing_scope)
  	  break;
  
        if (i < 0)
--- 8821,8828 ----
  	 first we check to see if we're in the middle of emitting it
  	 so we know where the new DIE should go.  */
  
!       for (i = VARRAY_ACTIVE_SIZE (decl_scope_table) - 1; i >= 0; --i)
! 	if (VARRAY_TREE (decl_scope_table, i) == containing_scope)
  	  break;
  
        if (i < 0)
***************
*** 9105,9124 ****
  #endif
  
  /* Remember a type in the incomplete_types_list.  */
- 
  static void
  add_incomplete_type (type)
       tree type;
  {
!   if (incomplete_types == incomplete_types_allocated)
!     {
!       incomplete_types_allocated += INCOMPLETE_TYPES_INCREMENT;
!       incomplete_types_list
! 	= (tree *) xrealloc (incomplete_types_list,
! 			     sizeof (tree) * incomplete_types_allocated);
!     }
! 
!   incomplete_types_list[incomplete_types++] = type;
  }
  
  /* Walk through the list of incomplete types again, trying once more to
--- 9076,9086 ----
  #endif
  
  /* Remember a type in the incomplete_types_list.  */
  static void
  add_incomplete_type (type)
       tree type;
  {
!   VARRAY_PUSH_TREE (incomplete_types, type);
  }
  
  /* Walk through the list of incomplete types again, trying once more to
***************
*** 9127,9139 ****
  static void
  retry_incomplete_types ()
  {
!   register tree type;
! 
!   while (incomplete_types)
      {
!       --incomplete_types;
!       type = incomplete_types_list[incomplete_types];
!       gen_type_die (type, comp_unit_die);
      }
  }
  
--- 9089,9098 ----
  static void
  retry_incomplete_types ()
  {
!   int i;
!   for (i = VARRAY_ACTIVE_SIZE (incomplete_types) - 1; i >= 0; i--)
      {
!       gen_type_die (VARRAY_TREE (incomplete_types, i), comp_unit_die);
      }
  }
  
***************
*** 11195,11204 ****
    decl_die_table_in_use = 0;
  
    /* Allocate the initial hunk of the decl_scope_table.  */
!   decl_scope_table
!     = (tree *) xcalloc (DECL_SCOPE_TABLE_INCREMENT, sizeof (tree));
!   decl_scope_table_allocated = DECL_SCOPE_TABLE_INCREMENT;
!   decl_scope_depth = 0;
  
    /* Allocate the initial hunk of the abbrev_die_table.  */
    abbrev_die_table
--- 11154,11161 ----
    decl_die_table_in_use = 0;
  
    /* Allocate the initial hunk of the decl_scope_table.  */
!   VARRAY_TREE_INIT (decl_scope_table, 256, "decl_scope_table");
!   ggc_add_tree_varray_root (&decl_scope_table, 1);
  
    /* Allocate the initial hunk of the abbrev_die_table.  */
    abbrev_die_table
***************
*** 11222,11227 ****
--- 11179,11187 ----
       taken as being relative to the directory from which the compiler was
       invoked when the given (base) source file was compiled.  */
    comp_unit_die = gen_compile_unit_die (main_input_filename);
+ 
+   VARRAY_TREE_INIT (incomplete_types, 64, "incomplete_types");
+   ggc_add_tree_varray_root (&incomplete_types, 1);
  
    VARRAY_RTX_INIT (used_rtx_varray, 32, "used_rtx_varray");
    ggc_add_rtx_varray_root (&used_rtx_varray, 1);
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]