This is the mail archive of the gdb-patches@sourceware.org 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]

[commit/dwarf2] Do not allocate padding DIEs


The DWARF representation ends every list of child DIEs with a null
entry (abbrev 0).  We currently allocate a DIE for this NULL entry; a
substantial portion of all DIEs we allocate are these trivial entries.
Nothing that walks the list of children is ever looking for them, so
we can win a bit by not allocating them.

This is part of a series of performance improvements for full symbol
reading.  I've tested the patches together, and benchmarked them
in sequence.  This is the second-biggest improvement; it's good for
about 10% of -readnow time on my tests of a number of C++ libraries.

Tested on x86_64-linux, committed.

-- 
Daniel Jacobowitz
CodeSourcery

2008-08-20  Daniel Jacobowitz  <dan@codesourcery.com>

	* dwarf2read.c (read_die_and_children): Ignore NULL DIEs.
	(read_die_and_siblings): Likewise.  Do not add padding DIEs to the
	sibling list.
	(read_full_die): Do not allocate DIEs for abbrev 0.
	(follow_die_ref): Correct error message.

---
 gdb/dwarf2read.c |   32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

Index: src/gdb/dwarf2read.c
===================================================================
--- src.orig/gdb/dwarf2read.c	2008-08-09 22:57:49.000000000 -0400
+++ src/gdb/dwarf2read.c	2008-08-09 23:31:29.000000000 -0400
@@ -5141,6 +5141,11 @@ read_die_and_children (gdb_byte *info_pt
   int has_children;
 
   cur_ptr = read_full_die (&die, abfd, info_ptr, cu, &has_children);
+  if (die == NULL)
+    {
+      *new_info_ptr = cur_ptr;
+      return NULL;
+    }
   store_in_ref_table (die->offset, die, cu);
 
   if (has_children)
@@ -5180,24 +5185,18 @@ read_die_and_siblings (gdb_byte *info_pt
       struct die_info *die
 	= read_die_and_children (cur_ptr, abfd, cu, &cur_ptr, parent);
 
-      if (!first_die)
-	{
-	  first_die = die;
-	}
-      else
-	{
-	  last_sibling->sibling = die;
-	}
-
-      if (die->tag == 0)
+      if (die == NULL)
 	{
 	  *new_info_ptr = cur_ptr;
 	  return first_die;
 	}
+
+      if (!first_die)
+	first_die = die;
       else
-	{
-	  last_sibling = die;
-	}
+	last_sibling->sibling = die;
+
+      last_sibling = die;
     }
 }
 
@@ -6048,10 +6047,7 @@ read_full_die (struct die_info **diep, b
   info_ptr += bytes_read;
   if (!abbrev_number)
     {
-      die = dwarf_alloc_die ();
-      die->tag = 0;
-      die->abbrev = abbrev_number;
-      *diep = die;
+      *diep = NULL;
       *has_children = 0;
       return info_ptr;
     }
@@ -9240,7 +9236,7 @@ follow_die_ref (struct die_info *src_die
 
   error (_("Dwarf Error: Cannot find DIE at 0x%lx referenced from DIE "
 	 "at 0x%lx [in module %s]"),
-	 (long) src_die->offset, (long) offset, cu->objfile->name);
+	 (long) offset, (long) src_die->offset, cu->objfile->name);
 
   return NULL;
 }


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