libdwarf: using dwarf_validate_die_sibling

libdwarf

Loading...
Searching...
No Matches
using dwarf_validate_die_sibling

Example of a DIE tree validation.

Example of a DIE tree validation.

Here we show how one uses dwarf_validate_die_sibling(). Dwarfdump uses this function as a part of its validation of DIE trees.

It is not something you need to use. But one must use it in a specific pattern for it to work properly.

dwarf_validate_die_sibling() depends on data set by dwarf_child() preceeding dwarf_siblingof_b() . dwarf_child() records a little bit of information invisibly in the Dwarf_Debug data.

*/
int example_sibvalid(Dwarf_Debug dbg,
Dwarf_Die in_die,
Dwarf_Error*error)
{
int cres = DW_DLV_OK;
int sibres = DW_DLV_OK;
Dwarf_Die die = 0;
Dwarf_Die sibdie = 0;
Dwarf_Die child = 0;
Dwarf_Bool is_info = dwarf_get_die_infotypes_flag(die);
die = in_die;
for ( ; die ; die = sibdie) {
int vres = 0;
Dwarf_Unsigned offset = 0;
/* Maybe print something you extract from the DIE
Dwarf_Die
struct Dwarf_Die_s * Dwarf_Die
Definition libdwarf.h:627
Dwarf_Error
struct Dwarf_Error_s * Dwarf_Error
Definition libdwarf.h:611
Dwarf_Debug
struct Dwarf_Debug_s * Dwarf_Debug
Definition libdwarf.h:617
Dwarf_Bool
int Dwarf_Bool
Definition libdwarf.h:202
Dwarf_Unsigned
unsigned long long Dwarf_Unsigned
Definition libdwarf.h:196
dwarf_get_die_infotypes_flag
DW_API Dwarf_Bool dwarf_get_die_infotypes_flag(Dwarf_Die dw_die)
Return the is_info flag.