[rfa/dwarf] Support for attributes pointing to a different CU

Jim Blandy jimb@redhat.com
Thu Sep 23 22:19:00 GMT 2004


Daniel Jacobowitz <drow@false.org> writes:
> This is the last logical piece I could break out of the intercu support. 
> We're almost there.  Only things left after this are dependence tracking
> and the queueing of multiple full CUs - 400 lines or so.
> 
> The core change of this patch is in follow_die_ref.  Instead of taking an
> offset and returning a DIE, it now takes an attribute and the CU in which
> the attribute was found, and returns a DIE and the CU in which the DIE
> was found.
> 
> The bulky text change of this patch is in dwarf2_attr.  It divides into two
> interfaces: anywhere that we are prepared to find a reference to another
> DIE, we need to call dwarf2_attr_with_cu instead.  Then, any further
> operations on the returned reference need to be sure to use the returned CU.
> The reason for this is a little subtle - we're returning a reference.  If
> the reference is, for example, DW_FORM_ref4, then it's an offset within some
> particular CU.  If the attribute containing this reference was found by
> chasing DW_AT_specification, and DW_AT_specification was DW_FORM_ref_addr,
> then the return value of dwarf2_attr_with_cu is a relative offset to a
> different CU than the caller passed in.  So if we are going to follow the
> reference, we need to know the compilation unit in which it resides.

I may be missing something, but it seems to me some of this effort is
necessary because we hold some die references as CU-relative, and
others as .debug_info relative, depending on the form the attribute
happened to use.  Wouldn't it be a simplification to have
read_attribute_value always store all DW_FORM_ref* attributes as
DW_ADDR offsets from the beginning of .debug_info?  Then dwarf2_attr's
interface could remain unchanged, and we could drop all the spec_cu
variables carrying the CU to the next call to
dwarf2_get_ref_die_offset.  Then, dwarf2_get_ref_die_offset could be
deleted altogether, and its calls replaced with uses of DW_ADDR.

(This change wasn't possible in the past because we didn't pass a CU
to dwarf2_attr.)



More information about the Gdb-patches mailing list