On Sun, 2014-08-17 at 12:52 +0200, Dodji Seketeli wrote: > Mark Wielaard <m...@redhat.com> writes: > > > In both systemtap and libabigail there is a need to get the actual Dwarf > > underlying an Dwarf_Die or Dwarf_Attribute. Following a DIE reference > > might end up in an alternate Dwarf since the addition of DWZ multifile > > forms. Both Dwarf_Die and Dwarf_Attribute already contain a Dwarf_CU > > handle. Add a function dwarf_cu_getdwarf to retrieve the underlying > > Dwarf using the Dwarf_CU. > > Thanks Mark! > > This, indeed, is going to be useful for libabigail at least. This new > dwarf_cu_getdwarf function, along with the existing dwarf_diecu function > will allow us to get the actual Dwarf a given DIE comes from. And with > the recently added dwarf_getalt function, we'll be able to tel if the > DIE comes from the alternate Dwarf or not. This is awesome.
Glad it is useful. Do note that the existing dwarf_diecu gives you the top-level Dwarf_Die for the CU, not a Dwarf_CU. Both the original Dwarf_Die and the result from dwarf_diecu should have the same Dwarf_CU handle that you can use with dwarf_cu_getdwarf. The Dwarf_CU represents the actual DWARF CU concept, from which you can get some extra information not like address or offset size used in the particular DIE tree (see also dwarf_cudie that returns both that extra information and the top level Dwarf_DIE for the CU). While the top-level Dwarf_Die is the compile/partial/type_unit DIE (all other DIEs in the CU are children of this DIE). Cheers, Mark