[commit]: dw2_expand_symtabs_with_filename: ignore type units

Doug Evans
2010-12-08T18:11:04Z

Hi.

fyi, I checked this in.

A supplemental patch is to rename expand_symtabs_with_filename.
expand_code_symtabs_with_filename?
Let me know if you want this change too.

Btw, prior to this patch "break main" on one program here
expanded gdb's memory usage by 2.5G. :-)

2010-12-08 Doug Evans <dje@google.com>

* symfile.h (quick_symbol_functions): Clarify usage of
expand_symtabs_with_filename.
* dwarf2read.c (dw2_expand_symtabs_with_filename): Only iterate over
comp units, not type units.

Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.78
diff -u -p -r1.78 symfile.h
--- symfile.h 24 Nov 2010 19:01:51 -0000 1.78
+++ symfile.h 8 Dec 2010 17:23:17 -0000
@@ -209,7 +209,10 @@ struct quick_symbol_functions
void (*expand_all_symtabs) (struct objfile *objfile);

/* Read all symbol tables associated with OBJFILE which have the
- file name FILENAME. */
+ file name FILENAME.
+ This is for the purposes of examining code only, e.g., expand_line_sal.
+ The routine may ignore debug info that is known to not be useful with
+ code, e.g., DW_TAG_type_unit for dwarf debug info. */
void (*expand_symtabs_with_filename) (struct objfile *objfile,
const char *filename);

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.484
diff -u -p -r1.484 dwarf2read.c
--- dwarf2read.c 8 Dec 2010 17:31:52 -0000 1.484
+++ dwarf2read.c 8 Dec 2010 17:44:00 -0000
@@ -2323,8 +2323,13 @@ dw2_expand_symtabs_with_filename (struct
int i;

dw2_setup (objfile);
- for (i = 0; i < (dwarf2_per_objfile->n_comp_units
- + dwarf2_per_objfile->n_type_comp_units); ++i)
+
+ /* We don't need to consider type units here.
+ This is only called for examining code, e.g. expand_line_sal.
+ There can be an order of magnitude (or more) more type units
+ than comp units, and we avoid them if we can. */
+
+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
int j;
struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);