This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] Patch for dwarf2read.c to handle ref_addr in more places
- To: gdb-patches at sources dot redhat dot com
- Subject: [RFA] Patch for dwarf2read.c to handle ref_addr in more places
- From: Daniel Berlin <dberlin at redhat dot com>
- Date: 06 Aug 2000 12:31:43 -0400
This patch allows us to follow die references that are in a seperate
compilation unit.
It's the first part of what is needed to handle multiple CU's that are
generated by the patch i sent to gcc-patches yesterday.
We only get absolute references in sibling's and type's, so that's
where i handle them.
Without this patch, you'll get "Can't find reference at offset
<whatever>" if the type or sibling is in another CU.
Next up is actual handling of multiple compilation units.
--Dan
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.16
diff -c -3 -p -r1.16 dwarf2read.c
*** dwarf2read.c 2000/08/04 16:51:47 1.16
--- dwarf2read.c 2000/08/06 16:27:52
*************** read_partial_die (struct partial_die_inf
*** 3191,3204 ****
found_spec_attr = 1;
spec_attr = attr;
break;
! case DW_AT_sibling:
! /* Ignore absolute siblings, they might point outside of
! the current compile unit. */
! if (attr.form == DW_FORM_ref_addr)
! complain (&dwarf2_absolute_sibling_complaint);
! else
! part_die->sibling =
! dwarf_info_buffer + dwarf2_get_ref_die_offset (&attr);
break;
default:
break;
--- 3191,3199 ----
found_spec_attr = 1;
spec_attr = attr;
break;
! case DW_AT_sibling:
! part_die->sibling =
! dwarf_info_buffer + dwarf2_get_ref_die_offset (&attr);
break;
default:
break;
*************** die_type (struct die_info *die, struct o
*** 4446,4456 ****
{
ref = dwarf2_get_ref_die_offset (type_attr);
type_die = follow_die_ref (ref);
if (!type_die)
{
! error ("Dwarf Error: Cannot find referent at offset %d.", ref);
! return NULL;
! }
}
type = tag_type_to_type (type_die, objfile, cu_header);
if (!type)
--- 4441,4467 ----
{
ref = dwarf2_get_ref_die_offset (type_attr);
type_die = follow_die_ref (ref);
+
+ /* If we couldn't follow the die ref, it might be in a CU we
+ haven't read. So let's just read the die we need, if we can.
+ */
if (!type_die)
{
! read_full_die (&type_die, objfile->obfd, dwarf_info_buffer+ref, cu_header);
! if (type_die)
! {
! /* Found it, so store it in the ref table so we don't
! have to do this again */
! store_in_ref_table(type_die->offset, type_die);
! }
! else
! {
! /* Still couldn't find it, probably a real error in the
! debug info. */
! error ("Dwarf Error: Cannot find referent at offset %d.", ref);
! return NULL;
! }
! }
}
type = tag_type_to_type (type_die, objfile, cu_header);
if (!type)