libdwarf
Using dwarf_globals_by_type()

Example reading .debug_pubtypes.

The .debug_pubtypes section was in DWARF4, it could appear as an extension in other DWARF versions.. In libdwarf 0.5.0 and earlier the function dwarf_get_pubtypes() was used instead.

*/
int exampleg(Dwarf_Debug dbg, Dwarf_Error *error)
{
Dwarf_Signed count = 0;
Dwarf_Global *types = 0;
Dwarf_Signed i = 0;
int res = 0;
res = dwarf_globals_by_type(dbg,DW_GL_PUBTYPES,
&types,&count,error);
/* Alternatively the 0.5.0 and earlier call:
res=dwarf_get_pubtypes(dbg, &types,&count, error); */
if (res != DW_DLV_OK) {
return res;
}
for (i = 0; i < count; ++i) {
/* use types[i] */
}
dwarf_globals_dealloc(dbg, types, count);
return DW_DLV_OK;
}
struct Dwarf_Debug_s * Dwarf_Debug
Definition: libdwarf.h:586
struct Dwarf_Global_s * Dwarf_Global
Definition: libdwarf.h:608
struct Dwarf_Error_s * Dwarf_Error
Definition: libdwarf.h:580
signed long long Dwarf_Signed
Definition: libdwarf.h:197
int dwarf_globals_by_type(Dwarf_Debug dw_dbg, int dw_requested_section, Dwarf_Global **dw_contents, Dwarf_Signed *dw_count, Dwarf_Error *dw_error)
Allocate Any Fast Access DWARF2-DWARF4.
void dwarf_globals_dealloc(Dwarf_Debug dw_dbg, Dwarf_Global *dw_global_like, Dwarf_Signed dw_count)
Dealloc the Dwarf_Global data.