libdwarf
Reading an aranges section

Example reading .debug_aranges.

An example accessing the .debug_aranges section. Looking all the aranges entries. This example is not searching for anything.

Parameters
dbgThe Dwarf_Debug of interest.
dw_errorOn error dw_error is set to point to the error details.
Returns
DW_DLV_OK etc.
*/
static void cleanupbadarange(Dwarf_Debug dbg,
{
Dwarf_Signed k = i;
for ( ; k < count; ++k) {
dwarf_dealloc(dbg,arange[k] , DW_DLA_ARANGE);
arange[k] = 0;
}
}
int exampleu(Dwarf_Debug dbg,Dwarf_Error *error)
{
/* It is a historical accident that the count is signed.
No negative count is possible. */
Dwarf_Signed count = 0;
Dwarf_Arange *arange = 0;
int res = 0;
res = dwarf_get_aranges(dbg, &arange,&count, error);
if (res == DW_DLV_OK) {
Dwarf_Signed i = 0;
for (i = 0; i < count; ++i) {
Dwarf_Arange ara = arange[i];
Dwarf_Unsigned segment = 0;
Dwarf_Unsigned segment_entry_size = 0;
Dwarf_Addr start = 0;
Dwarf_Unsigned length = 0;
Dwarf_Off cu_die_offset = 0;
&segment,&segment_entry_size,
&start, &length,
&cu_die_offset,error);
if (res != DW_DLV_OK) {
cleanupbadarange(dbg,arange,i,count);
dwarf_dealloc(dbg, arange, DW_DLA_LIST);
return res;
}
/* Do something with ara */
dwarf_dealloc(dbg, ara, DW_DLA_ARANGE);
arange[i] = 0;
}
dwarf_dealloc(dbg, arange, DW_DLA_LIST);
}
return res;
}
struct Dwarf_Debug_s * Dwarf_Debug
Definition: libdwarf.h:603
struct Dwarf_Error_s * Dwarf_Error
Definition: libdwarf.h:597
struct Dwarf_Arange_s * Dwarf_Arange
Definition: libdwarf.h:682
int dwarf_get_arange_info_b(Dwarf_Arange dw_arange, Dwarf_Unsigned *dw_segment, Dwarf_Unsigned *dw_segment_entry_size, Dwarf_Addr *dw_start, Dwarf_Unsigned *dw_length, Dwarf_Off *dw_cu_die_offset, Dwarf_Error *dw_error)
Get the data in an arange entry.
int dwarf_get_aranges(Dwarf_Debug dw_dbg, Dwarf_Arange **dw_aranges, Dwarf_Signed *dw_arange_count, Dwarf_Error *dw_error)
Get access to CUs given code addresses.
signed long long Dwarf_Signed
Definition: libdwarf.h:197
unsigned long long Dwarf_Unsigned
Definition: libdwarf.h:196
unsigned long long Dwarf_Off
Definition: libdwarf.h:198
unsigned long long Dwarf_Addr
Definition: libdwarf.h:199
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,...