libdwarf
Example dwarf_child call

Accessing a DIE child. More...

Accessing a DIE child.

If the DIE has children (for example inner scopes in a function or members of a struct) this retrieves the DIE which appears first. The child itself may be of its own sibling chain.

*/
void example5(Dwarf_Die in_die)
{
Dwarf_Die return_kid = 0;
Dwarf_Error error = 0;
int res = 0;
res = dwarf_child(in_die,&return_kid, &error);
if (res == DW_DLV_OK) {
/* Use return_kid here. */
dwarf_dealloc_die(return_kid);
/* The original form of dealloc still works
dwarf_dealloc(dbg, return_kid, DW_DLA_DIE);
*/
/* return_die is no longer usable for anything, we
ensure we do not use it accidentally with: */
return_kid = 0;
}
}
dwarf_child
int dwarf_child(Dwarf_Die dw_die, Dwarf_Die *dw_return_childdie, Dwarf_Error *dw_error)
Get the child DIE, if any. The child may be the first of a list of sibling DIEs.
dwarf_dealloc_die
void dwarf_dealloc_die(Dwarf_Die dw_die)
Deallocate (free) a DIE.
Dwarf_Die
struct Dwarf_Die_s * Dwarf_Die
Definition: libdwarf.h:542
Dwarf_Error
struct Dwarf_Error_s * Dwarf_Error
Definition: libdwarf.h:531