This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
RFA: Don't use obsavestring in dwarf2read
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 11 Jan 2004 20:57:26 -0500
- Subject: RFA: Don't use obsavestring in dwarf2read
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;