libdwarf
Using dwarf_offset_list()

Example using dwarf_offset_list.

An example calling dwarf_offset_list

Parameters
dbgthe Dwarf_Debug of interest
dieoffsetThe section offset of a Dwarf_Die
is_infoPass in TRUE if the dieoffset is for the .debug_info section, else pass in FALSE meaning the dieoffset is for the DWARF4 .debug_types section.
errorThe usual error detail return.
Returns
Returns DW_DLV_OK etc
*/
int exampleoffset_list(Dwarf_Debug dbg, Dwarf_Off dieoffset,
Dwarf_Bool is_info,Dwarf_Error * error)
{
Dwarf_Unsigned offcnt = 0;
Dwarf_Off *offbuf = 0;
int errv = 0;
errv = dwarf_offset_list(dbg,dieoffset, is_info,
&offbuf,&offcnt, error);
if (errv != DW_DLV_OK) {
return errv;
}
for (i = 0; i < offcnt; ++i) {
/* use offbuf[i] */
/* No need to free the offbuf entry, it
is just an offset value. */
}
dwarf_dealloc(dbg, offbuf, DW_DLA_LIST);
return DW_DLV_OK;
}
struct Dwarf_Debug_s * Dwarf_Debug
Definition: libdwarf.h:603
struct Dwarf_Error_s * Dwarf_Error
Definition: libdwarf.h:597
unsigned long long Dwarf_Unsigned
Definition: libdwarf.h:196
int Dwarf_Bool
Definition: libdwarf.h:202
unsigned long long Dwarf_Off
Definition: libdwarf.h:198
int dwarf_offset_list(Dwarf_Debug dw_dbg, Dwarf_Off dw_offset, Dwarf_Bool dw_is_info, Dwarf_Off **dw_offbuf, Dwarf_Unsigned *dw_offcount, Dwarf_Error *dw_error)
Return an array of DIE children offsets.
void dwarf_dealloc(Dwarf_Debug dw_dbg, void *dw_space, Dwarf_Unsigned dw_type)
The generic dealloc (free) function. It requires you know the correct DW_DLA value to pass in,...