On Thu, 2018-01-25 at 16:06 +0100, Mark Wielaard wrote:
> Currently storing a lot of Dwarf_Dies might be inefficient since it
> costs a lot of memory since the sizeof (Dwarf_Die) == 32 bytes on 64bit
> arches. You can try storing just the Dwarf_Off from dwarf_dieoffset.
> Which is just 8 bytes. But then you have to keep track of whether to
> call dwarf_dieoffset, if the Dwarf_Die came from the main .debug_info,
> or call dwarf_dieoffset_types, if it came from .debug_types. And you'll
> have to keep track of whether it came from the main Dwarf or the alt
> Dwarf (dwz multi file). With DWARF5 or GNU DebugFission split-dwarf
> you will also need to know which split Dwarf file the original DIE
> came from.
> A Dwarf_Die consists of an addr pointer where the actual DIE data
> comes from, a CU pointer that provides context (and has a pointer
> to the Dwarf file the Die is associated with) and a (cached)
> Dwarf_Abbrev pointer that is initialized when the Dwarf_Die is
> first read and describes how to interpret the DIE data.
> libdw already keeps track of the data pointers (sections) of a
> Dwarf file and given an offset it can already reconstruct the
> other Dwarf_Die fields. So this patch introduces dwarf_die_addr_die.
> Given a Dwarf_Die addr dwarf_die_addr_die returns a (reconstructed)
> Dwarf_Die, or NULL if the given addr didn't come from a valid
> Dwarf_Die. In particular it will make sure that the correct Dwarf_CU
> pointer is set for the Dwarf_Die, the Dwarf_Abbrev pointer will not
> be set up yet (it will only be once the Dwarf_Die is used to read
> attributes, children or siblings).
> This functions can be used to keep a reference to a Dwarf_Die which
> you want to refer to later. The addr, and the result of this function,
> is only valid while the associated Dwarf is valid.
> Since libdw already had to lookup the Dwarf_CU given an offset, this
> function is as efficient as dwarf_dieoffset (or dwarf_dieoffset_types)
> without having to know the original origin of the Dwarf_Die. It will
> search both the .debug_info and .debug_types data sections from both
> the main Dwarf or the alt Dwarf file. Once split dwarf support is added
> it will also look in any split dwarf .dwo (or the .dwp) file.
> The only limitation, compared to using a Dwarf_Off and dwarf_dieoffset,
> is that it only works during runtime while the main Dwarf object is
> valid (till dwarf_end has been called on it).

I pushed this to master now.

Reply via email to