aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2004-02-23 20:02:37 +0000
committerDaniel Jacobowitz <drow@false.org>2004-02-23 20:02:37 +0000
commitb86503378caff512de89271b53e0549389bd9972 (patch)
tree56698bf31a9137c3091f06c89912c7313633eed3
parente50920560b60d1f8a42ee21248c2b430b796be34 (diff)
downloadfsf-binutils-gdb-b86503378caff512de89271b53e0549389bd9972.zip
fsf-binutils-gdb-b86503378caff512de89271b53e0549389bd9972.tar.gz
fsf-binutils-gdb-b86503378caff512de89271b53e0549389bd9972.tar.bz2
* dwarf2read.c (dwarf2_read_abbrevs): Return 1 iff we saw any
DW_FORM_ref_addr tags. (create_comp_unit_tree): Add prototype. Take an objfile instead of a compilation unit. (dwarf2_build_psymtabs_hard): Build the compilation unit tree as soon as we find an inter-CU reference. Update call to create_comp_unit_tree. (dwarf2_find_containing_comp_unit): Don't create the tree here. (psymtab_to_symtab_1): Update to support no tree having been built. (set_die_type): Likewise.
-rw-r--r--gdb/ChangeLog.intercu13
-rw-r--r--gdb/dwarf2read.c65
2 files changed, 54 insertions, 24 deletions
diff --git a/gdb/ChangeLog.intercu b/gdb/ChangeLog.intercu
index 5281235..31e1d56 100644
--- a/gdb/ChangeLog.intercu
+++ b/gdb/ChangeLog.intercu
@@ -1,5 +1,18 @@
2004-02-23 Daniel Jacobowitz <drow@mvista.com>
+ * dwarf2read.c (dwarf2_read_abbrevs): Return 1 iff we saw any
+ DW_FORM_ref_addr tags.
+ (create_comp_unit_tree): Add prototype. Take an objfile instead
+ of a compilation unit.
+ (dwarf2_build_psymtabs_hard): Build the compilation unit tree
+ as soon as we find an inter-CU reference. Update call to
+ create_comp_unit_tree.
+ (dwarf2_find_containing_comp_unit): Don't create the tree here.
+ (psymtab_to_symtab_1): Update to support no tree having been built.
+ (set_die_type): Likewise.
+
+2004-02-23 Daniel Jacobowitz <drow@mvista.com>
+
* dwarf2read.c (dwarf2_per_objfile_data): New.
(struct dwarf2_per_objfile_data): New.
(dwarf2_per_objfile): New.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index c1c07f2..803f5fe 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -673,7 +673,7 @@ static void psymtab_to_symtab_1 (struct partial_symtab *);
char *dwarf2_read_section (struct objfile *, asection *);
-static void dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu);
+static int dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu);
static void dwarf2_empty_abbrev_table (void *);
@@ -969,6 +969,8 @@ static void set_die_type (struct die_info *, struct type *,
static void reset_die_and_siblings_types (struct die_info *,
struct dwarf2_cu *);
+static splay_tree create_comp_unit_tree (struct objfile *);
+
/* Allocation function for the libiberty splay tree which uses an obstack. */
static void *
splay_tree_obstack_allocate (int size, void *data)
@@ -1335,6 +1337,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
struct abbrev_info *abbrev;
unsigned int bytes_read;
struct dwarf2_per_cu_data *this_cu;
+ int saw_ref_addr;
beg_of_comp_unit = info_ptr;
@@ -1351,9 +1354,12 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
cu.partial_dies = NULL;
/* Read the abbrevs for this compilation unit into a table */
- dwarf2_read_abbrevs (abfd, &cu);
+ saw_ref_addr = dwarf2_read_abbrevs (abfd, &cu);
back_to_inner = make_cleanup (dwarf2_empty_abbrev_table, &cu);
+ if (saw_ref_addr && cu_tree == NULL)
+ cu_tree = create_comp_unit_tree (objfile);
+
/* Read the compilation unit die */
abbrev = peek_die_abbrev (info_ptr, &bytes_read, &cu);
info_ptr = load_partial_die (&comp_unit_die, abbrev, bytes_read,
@@ -1378,9 +1384,6 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
/* Store the function that reads in the rest of the symbol table */
pst->read_symtab = dwarf2_psymtab_to_symtab;
- if (cu_tree == NULL)
- cu_tree = dwarf2_per_objfile->cu_tree;
-
if (cu_tree != NULL)
{
splay_tree_node node;
@@ -1542,10 +1545,9 @@ load_comp_unit (struct dwarf2_per_cu_data *this_cu, struct objfile *objfile)
So there's no point in building this tree incrementally. */
static splay_tree
-create_comp_unit_tree (struct dwarf2_cu *cu)
+create_comp_unit_tree (struct objfile *objfile)
{
splay_tree cu_tree;
- struct objfile *objfile = cu->objfile;
char *info_ptr = dwarf_info_buffer;
/* Initialize the compilation unit tree. */
@@ -1579,12 +1581,6 @@ create_comp_unit_tree (struct dwarf2_cu *cu)
this_cu->length = cu_header.length;
splay_tree_insert (cu_tree, this_cu->offset, (splay_tree_value) this_cu);
- if (this_cu->offset == cu->header.offset)
- {
- this_cu->cu = cu;
- cu->per_cu = this_cu;
- }
-
info_ptr = beg_of_comp_unit + cu_header.length
+ cu_header.initial_length_size;
}
@@ -2280,15 +2276,27 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
so much trouble to keep lazy during partial symbol reading. If this
proves to be unavoidable then we may want to strip out the lazy code
during partial symbol reading also. */
- cu.per_cu = dwarf2_find_containing_comp_unit (offset + 1, &cu);
- /* As in partial symbol table building, this leaks a pointer to our stack
- frame into a global data structure. Be sure to clear it before we
- return. */
- cu.per_cu->cu = &cu;
- make_cleanup (clear_per_cu_pointer, &cu);
- cu.read_in_chain = NULL;
+ if (dwarf2_per_objfile->cu_tree == NULL)
+ cu.per_cu = NULL;
+ else
+ {
+ splay_tree_node node;
+ struct dwarf2_per_cu_data *per_cu;
+
+ node = splay_tree_lookup (dwarf2_per_objfile->cu_tree, cu.header.offset);
+ gdb_assert (node != NULL);
+ cu.per_cu = (struct dwarf2_per_cu_data *) node->value;
- cu.per_cu->psymtab = pst;
+ /* As in partial symbol table building, this leaks a pointer to
+ our stack frame into a global data structure. Be sure to
+ clear it before we return. */
+ cu.per_cu->cu = &cu;
+ make_cleanup (clear_per_cu_pointer, &cu);
+
+ cu.per_cu->psymtab = pst;
+ }
+
+ cu.read_in_chain = NULL;
cu.list_in_scope = &file_symbols;
@@ -4652,7 +4660,7 @@ dwarf2_read_section (struct objfile *objfile, asection *sectp)
dies from a section we read in all abbreviations and install them
in a hash table. */
-static void
+static int
dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu)
{
struct comp_unit_head *cu_header = &cu->header;
@@ -4662,6 +4670,7 @@ dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu)
unsigned int abbrev_form, hash_number;
struct attr_abbrev *cur_attrs;
unsigned int allocated_attrs;
+ int saw_ref_addr = 0;
/* Initialize dwarf2 abbrevs */
obstack_init (&cu->abbrev_obstack);
@@ -4701,6 +4710,10 @@ dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu)
= xrealloc (cur_attrs, (allocated_attrs
* sizeof (struct attr_abbrev)));
}
+
+ if (abbrev_form == DW_FORM_ref_addr)
+ saw_ref_addr = 1;
+
cur_attrs[cur_abbrev->num_attrs].name = abbrev_name;
cur_attrs[cur_abbrev->num_attrs++].form = abbrev_form;
abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
@@ -4736,6 +4749,8 @@ dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu)
}
xfree (cur_attrs);
+
+ return saw_ref_addr;
}
/* Empty the abbrev table for a new compilation unit. */
@@ -8859,8 +8874,7 @@ dwarf2_find_containing_comp_unit (unsigned long offset,
splay_tree_node node;
cu_tree = dwarf2_per_objfile->cu_tree;
- if (cu_tree == NULL)
- cu_tree = create_comp_unit_tree (cu);
+ gdb_assert (cu_tree != NULL);
node = splay_tree_predecessor (cu_tree, offset);
gdb_assert (node != NULL);
@@ -8966,6 +8980,9 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
die->type = type;
+ if (cu->per_cu == NULL)
+ return;
+
type_hash = PST_PRIVATE (cu->per_cu->psymtab)->type_hash;
if (type_hash == NULL)
{