Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: RFA: Don't use obsavestring in dwarf2read
@ 2004-02-10 10:08 Michael Elizabeth Chastain
  0 siblings, 0 replies; 14+ messages in thread
From: Michael Elizabeth Chastain @ 2004-02-10 10:08 UTC (permalink / raw)
  To: drow, ezannoni; +Cc: gdb-patches

Proofread, not tested.  Looks okay to me.

Michael C

===

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

	* dwarf2read.c: Add comment describing memory lifetimes.
	(dwarf2_add_field, dwarf2_add_member_fn, read_structure_scope)
	(read_enumeration, new_symbol): Don't use obsavestring.


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: RFA: Don't use obsavestring in dwarf2read
@ 2004-02-02 21:48 Michael Elizabeth Chastain
  0 siblings, 0 replies; 14+ messages in thread
From: Michael Elizabeth Chastain @ 2004-02-02 21:48 UTC (permalink / raw)
  To: drow, gdb-patches

Lightly proof-read, looks okay from my vantage point.

Michael C

===

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

	* dwarf2read.c: Add comment describing memory lifetimes.
	(dwarf2_add_field, dwarf2_add_member_fn, read_structure_scope)
	(read_enumeration, new_symbol): Don't use obsavestring.


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: RFA: Don't use obsavestring in dwarf2read
@ 2004-01-15 14:23 Michael Elizabeth Chastain
  0 siblings, 0 replies; 14+ messages in thread
From: Michael Elizabeth Chastain @ 2004-01-15 14:23 UTC (permalink / raw)
  To: drow, gdb-patches

I proofread this.  I didn't think it worthwhile to run the test suite,
because almost all tests are simple "load file / run / exit" that would
not catch memory lifetime bugs.

I have one concern.  read_string and read_indirect_string return NULL to
indicate a zero-length string.  obstack_savestring understands this and
copies an empty string "" into the obstack.  In most of your changes,
the string pointer is protected against being NULL, but in other
changes, it is possible for the string pointer to be NULL.  If the
string is NULL, then your code will produce slightly different results
than previously, which is a bit scary in the symtab reader.

So could you do this in two places:

  SET_FIELD_PHYSNAME (*fp, physname ? physname : "");

  fnp->physname = physname ? physname : "";

Other than that, it looks okay to me.  I stared at it for a while to
check that everything is coming from psymbol_obstack and symbol_obstack,
not dwarf2_tmp_obstack or alloca'd memory.

Michael C


^ permalink raw reply	[flat|nested] 14+ messages in thread
* RFA: Don't use obsavestring in dwarf2read
@ 2004-01-12  1:57 Daniel Jacobowitz
  2004-02-02 18:22 ` Daniel Jacobowitz
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2004-01-12  1:57 UTC (permalink / raw)
  To: gdb-patches

This patch is pretty self-explanatory, and pretty effective: With -readnow
to force immediate loading of full symbols, this is good for 3% startup time
and 30% memory savings (that's 100MB out of 330MB!) for a gdb session
against "monotone".  We already rely on the lifetimes of this data, so
there's no point in duplicating it onto another obstack with the exact same
lifetime.

OK?

[My current C++ work may have significant memory and startup time impact. 
I'm trying to clean house at the same time, so that I don't introduce a net
loss.  This is low-hanging fruit; higher-hanging fruit will take somewhat
longer.]

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2004-01-11  Daniel Jacobowitz  <drow@mvista.com>

	* dwarf2read.c: Add comment describing memory lifetimes.
	(dwarf2_add_field, dwarf2_add_member_fn, read_structure_scope)
	(read_enumeration, new_symbol): Don't use obsavestring.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.117
diff -u -p -r1.117 dwarf2read.c
--- dwarf2read.c	13 Dec 2003 22:29:06 -0000	1.117
+++ dwarf2read.c	12 Jan 2004 01:52:13 -0000
@@ -1,5 +1,5 @@
 /* DWARF 2 debugging format support for GDB.
-   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
 
    Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
@@ -54,6 +54,16 @@
 #define DWARF2_REG_TO_REGNUM(REG) (REG)
 #endif
 
+/* A note on memory usage: at the present time, this code reads the debug
+   info sections into the objfile's psymbol_obstack.  A definite improvement
+   for startup time, on platforms which do not emit relocations for debug
+   sections, would be to use mmap instead.
+   
+   In either case, the sections should remain loaded until the objfile is
+   released, and pointers into the section data can be used for any other
+   data associated to the objfile (symbol names, type names, location expressions
+   to name a few).  */
+
 #if 0
 /* .debug_info header for a compilation unit
    Because of alignment constraints, this structure has padding and cannot
@@ -2436,8 +2446,7 @@ dwarf2_add_field (struct field_info *fip
       attr = dwarf_attr (die, DW_AT_name);
       if (attr && DW_STRING (attr))
 	fieldname = DW_STRING (attr);
-      fp->name = obsavestring (fieldname, strlen (fieldname),
-			       &objfile->type_obstack);
+      fp->name = fieldname;
 
       /* Change accessibility for artificial fields (e.g. virtual table
          pointer or virtual base class pointer) to private.  */
@@ -2468,11 +2477,9 @@ dwarf2_add_field (struct field_info *fip
       /* Get physical name.  */
       physname = dwarf2_linkage_name (die);
 
-      SET_FIELD_PHYSNAME (*fp, obsavestring (physname, strlen (physname),
-					     &objfile->type_obstack));
+      SET_FIELD_PHYSNAME (*fp, physname);
       FIELD_TYPE (*fp) = die_type (die, cu);
-      FIELD_NAME (*fp) = obsavestring (fieldname, strlen (fieldname),
-				       &objfile->type_obstack);
+      FIELD_NAME (*fp) = fieldname;
     }
   else if (die->tag == DW_TAG_inheritance)
     {
@@ -2640,8 +2647,7 @@ dwarf2_add_member_fn (struct field_info 
 
   /* Fill in the member function field info.  */
   fnp = &new_fnfield->fnfield;
-  fnp->physname = obsavestring (physname, strlen (physname),
-				&objfile->type_obstack);
+  fnp->physname = physname;
   fnp->type = alloc_type (objfile);
   if (die->type && TYPE_CODE (die->type) == TYPE_CODE_FUNC)
     {
@@ -2778,11 +2784,7 @@ read_structure_scope (struct die_info *d
   INIT_CPLUS_SPECIFIC (type);
   attr = dwarf_attr (die, DW_AT_name);
   if (attr && DW_STRING (attr))
-    {
-      TYPE_TAG_NAME (type) = obsavestring (DW_STRING (attr),
-					   strlen (DW_STRING (attr)),
-					   &objfile->type_obstack);
-    }
+    TYPE_TAG_NAME (type) = DW_STRING (attr);
 
   if (die->tag == DW_TAG_structure_type)
     {
@@ -2944,11 +2946,7 @@ read_enumeration (struct die_info *die, 
   TYPE_CODE (type) = TYPE_CODE_ENUM;
   attr = dwarf_attr (die, DW_AT_name);
   if (attr && DW_STRING (attr))
-    {
-      TYPE_TAG_NAME (type) = obsavestring (DW_STRING (attr),
-					   strlen (DW_STRING (attr)),
-					   &objfile->type_obstack);
-    }
+    TYPE_TAG_NAME (type) = DW_STRING (attr);
 
   attr = dwarf_attr (die, DW_AT_byte_size);
   if (attr)
@@ -5325,10 +5323,7 @@ new_symbol (struct die_info *die, struct
 	      *typedef_sym = *sym;
 	      SYMBOL_DOMAIN (typedef_sym) = VAR_DOMAIN;
 	      if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
-		TYPE_NAME (SYMBOL_TYPE (sym)) =
-		  obsavestring (DEPRECATED_SYMBOL_NAME (sym),
-				strlen (DEPRECATED_SYMBOL_NAME (sym)),
-				&objfile->type_obstack);
+		TYPE_NAME (SYMBOL_TYPE (sym)) = DEPRECATED_SYMBOL_NAME (sym);
 	      add_symbol_to_list (typedef_sym, list_in_scope);
 	    }
 	  break;


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

end of thread, other threads:[~2004-03-05  3:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-10 10:08 RFA: Don't use obsavestring in dwarf2read Michael Elizabeth Chastain
  -- strict thread matches above, loose matches on Subject: below --
2004-02-02 21:48 Michael Elizabeth Chastain
2004-01-15 14:23 Michael Elizabeth Chastain
2004-01-12  1:57 Daniel Jacobowitz
2004-02-02 18:22 ` Daniel Jacobowitz
2004-02-05 19:29   ` Elena Zannoni
2004-02-05 19:48     ` Daniel Jacobowitz
2004-02-05 20:37       ` Elena Zannoni
2004-02-05 20:47         ` Daniel Jacobowitz
2004-02-05 23:20           ` Elena Zannoni
2004-02-08  4:41             ` Daniel Jacobowitz
2004-02-16 15:05               ` Elena Zannoni
2004-03-19  0:09                 ` Daniel Jacobowitz
2004-03-05  3:31                   ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox