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] Memory management fixes for last patch


This fixes the segfault I mentioned.  As I expected, reading the compacted
debug info (40% smaller) takes comparable time to reading the uncompacted
debug info.  Next on my list will be caching, and then on to full symbols,
I hope.

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): Always return NULL or
	malloc'd memory.  Don't try to free real_parent->full_name.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.135.2.18
diff -u -p -r1.135.2.18 dwarf2read.c
--- dwarf2read.c	22 Feb 2004 19:11:56 -0000	1.135.2.18
+++ dwarf2read.c	22 Feb 2004 19:25:35 -0000
@@ -1688,13 +1688,13 @@ static char *
 partial_die_full_name (struct partial_die_info *pdi,
 		       struct dwarf2_cu *cu)
 {
-  char *parent_name, *full_name;
+  char *parent_name = NULL, *full_name;
   struct partial_die_info *real_pdi, *real_parent;
   struct dwarf2_cu *spec_cu;
   int free_parent_name = 0;
 
-  if (pdi->full_name_set)
-    return pdi->full_name;
+  /* We shouldn't even have been called in this case.  */
+  gdb_assert (!pdi->full_name_set);
 
   /* Note: this code could probably be micro-optimized.  We may be
      able to avoid redoing the hash table lookup, and we might be able
@@ -1710,7 +1710,7 @@ partial_die_full_name (struct partial_di
      CU or later in this CU.  It's correct, but somewhat inefficient.  */
 
   if (real_pdi->full_name_set)
-    return real_pdi->full_name;
+    return xstrdup (real_pdi->full_name);
 
   real_parent = real_pdi->die_parent;
   if (real_parent == NULL)
@@ -1724,12 +1724,14 @@ partial_die_full_name (struct partial_di
       fixup_partial_die (real_parent, spec_cu);
       parent_name = partial_die_full_name (real_parent, spec_cu);
       /* Could cache the full name, too.  */
-      free_parent_name = 1;
+      if (parent_name != NULL)
+	free_parent_name = 1;
     }
 
   /* End hack zone.  */
 
-  parent_name = real_parent->full_name;
+  if (parent_name == NULL)
+    parent_name = real_parent->full_name;
   if (parent_name == NULL)
     parent_name = real_parent->name;
 


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