This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[intercu] Copy names from the psymbol


As I mentioned in my last message, this eliminates a duplication between
two obstacks: the objfile's psymbol obstack is longer-lived than the
temporary partial_die_obstack so we can just use the copy of the name from
the psymbol.  This will be important later.

Also fixes a problem I noticed in rtti.exp.  My previous logic for copying
actual_name was just wrong.

The downside is that I was wrong about the memory usage peak.  It came from
expanding struct partial_die_info.  I'll see what I can do about shrinking
it down again; I think "sibling" is unneeded.

Committed to the intercu branch.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2004-02-22  Daniel Jacobowitz  <drow@mvista.com>

	* dwarf2read.c (partial_die_full_name): Remove allocate argument,
	always use concat.
	(add_partial_symbol): Copy the name from the psymbol.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.135.2.16
diff -u -p -r1.135.2.16 dwarf2read.c
--- dwarf2read.c	22 Feb 2004 06:11:54 -0000	1.135.2.16
+++ dwarf2read.c	22 Feb 2004 06:50:35 -0000
@@ -1501,10 +1501,10 @@ scan_partial_symbols (struct partial_die
 }
 
 static char *
-partial_die_full_name (struct partial_die_info *pdi, int allocate,
+partial_die_full_name (struct partial_die_info *pdi,
 		       struct dwarf2_cu *cu)
 {
-  char *full_name, *parent_name;
+  char *parent_name;
   struct partial_die_info *real_parent;
 
   /* Note: this code could be micro-optimized.  We could avoid redoing
@@ -1524,13 +1524,7 @@ partial_die_full_name (struct partial_di
   if (parent_name == NULL)
     parent_name = real_parent->name;
 
-  if (allocate)
-    full_name = obconcat (&cu->partial_die_obstack,
-			  parent_name, "::", pdi->name);
-  else
-    full_name = concat (parent_name, "::", pdi->name, NULL);
-
-  return full_name;
+  return concat (parent_name, "::", pdi->name, NULL);
 }
 
 static void
@@ -1541,33 +1535,27 @@ add_partial_symbol (struct partial_die_i
   CORE_ADDR addr = 0;
   char *actual_name;
   const char *my_prefix;
-  const struct partial_symbol *psym = NULL;
+  const struct partial_symbol *psym = NULL, *psym2 = NULL;
   CORE_ADDR baseaddr;
-  int free_actual_name = 0;
+  int built_actual_name = 0;
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
+  actual_name = NULL;
   if (pdi_needs_namespace (pdi->tag) && pdi->full_name == NULL)
     {
-      if (pdi->tag == DW_TAG_namespace
-	  || pdi->tag == DW_TAG_class_type
-	  || pdi->tag == DW_TAG_structure_type
-	  || pdi->tag == DW_TAG_union_type)
-	{
-	  pdi->full_name = partial_die_full_name (pdi, 1, cu);
-	  actual_name = pdi->full_name;
-	}
+      actual_name = partial_die_full_name (pdi, cu);
+      if (actual_name)
+	built_actual_name = 1;
+    }
+
+  if (actual_name == NULL)
+    {
+      if (pdi->full_name != NULL)
+	actual_name = pdi->full_name;
       else
-	{
-	  actual_name = partial_die_full_name (pdi, 0, cu);
-	  if (actual_name)
-	    free_actual_name = 1;
-	}
-      if (actual_name == NULL)
 	actual_name = pdi->name;
     }
-  else
-    actual_name = pdi->name;
 
   switch (pdi->tag)
     {
@@ -1636,16 +1624,16 @@ add_partial_symbol (struct partial_die_i
     case DW_TAG_typedef:
     case DW_TAG_base_type:
     case DW_TAG_subrange_type:
-      add_psymbol_to_list (actual_name, strlen (actual_name),
-			   VAR_DOMAIN, LOC_TYPEDEF,
-			   &objfile->static_psymbols,
-			   0, (CORE_ADDR) 0, cu->language, objfile);
+      psym2 = add_psymbol_to_list (actual_name, strlen (actual_name),
+				   VAR_DOMAIN, LOC_TYPEDEF,
+				   &objfile->static_psymbols,
+				   0, (CORE_ADDR) 0, cu->language, objfile);
       break;
     case DW_TAG_namespace:
-      add_psymbol_to_list (actual_name, strlen (actual_name),
-			   VAR_DOMAIN, LOC_TYPEDEF,
-			   &objfile->global_psymbols,
-			   0, (CORE_ADDR) 0, cu->language, objfile);
+      psym2 = add_psymbol_to_list (actual_name, strlen (actual_name),
+				   VAR_DOMAIN, LOC_TYPEDEF,
+				   &objfile->global_psymbols,
+				   0, (CORE_ADDR) 0, cu->language, objfile);
       break;
     case DW_TAG_class_type:
     case DW_TAG_structure_type:
@@ -1657,12 +1645,12 @@ add_partial_symbol (struct partial_die_i
 	 static vs. global.  */
       if (pdi->has_children == 0)
 	return;
-      add_psymbol_to_list (actual_name, strlen (actual_name),
-			   STRUCT_DOMAIN, LOC_TYPEDEF,
-			   cu->language == language_cplus
-			   ? &objfile->global_psymbols
-			   : &objfile->static_psymbols,
-			   0, (CORE_ADDR) 0, cu->language, objfile);
+      psym2 = add_psymbol_to_list (actual_name, strlen (actual_name),
+				   STRUCT_DOMAIN, LOC_TYPEDEF,
+				   cu->language == language_cplus
+				   ? &objfile->global_psymbols
+				   : &objfile->static_psymbols,
+				   0, (CORE_ADDR) 0, cu->language, objfile);
 
       if (cu->language == language_cplus)
 	{
@@ -1674,12 +1662,12 @@ add_partial_symbol (struct partial_die_i
 	}
       break;
     case DW_TAG_enumerator:
-      add_psymbol_to_list (actual_name, strlen (actual_name),
-			   VAR_DOMAIN, LOC_CONST,
-			   cu->language == language_cplus
-			   ? &objfile->global_psymbols
-			   : &objfile->static_psymbols,
-			   0, (CORE_ADDR) 0, cu->language, objfile);
+      psym2 = add_psymbol_to_list (actual_name, strlen (actual_name),
+				   VAR_DOMAIN, LOC_CONST,
+				   cu->language == language_cplus
+				   ? &objfile->global_psymbols
+				   : &objfile->static_psymbols,
+				   0, (CORE_ADDR) 0, cu->language, objfile);
       break;
     default:
       break;
@@ -1691,6 +1679,8 @@ add_partial_symbol (struct partial_die_i
      (otherwise we'll have psym == NULL), and if we actually had a
      mangled name to begin with.  */
 
+  /* FIXME drow/2004-02-22: Why don't we do this for classes?  */
+
   if (cu->language == language_cplus
       && have_namespace_info == 0
       && psym != NULL
@@ -1698,8 +1688,14 @@ add_partial_symbol (struct partial_die_i
     cp_check_possible_namespace_symbols (SYMBOL_CPLUS_DEMANGLED_NAME (psym),
 					 objfile);
 
-  if (free_actual_name)
-    xfree (actual_name);
+  if (built_actual_name)
+    {
+      /* psym2 should always be set in the built_actual_name case,
+	 because the same set are used in pdi_needs_namespace.  See
+	 FIXME above.  */
+      pdi->full_name = SYMBOL_LINKAGE_NAME (psym2);
+      xfree (actual_name);
+    }
 }
 
 /* Determine whether a die of type TAG living in a C++ class or


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