libdwarf
Accessing accessing raw rnglist

Example showing access to rnglist.

This is accessing DWARF5 .debug_rnglists.

*/
int example_raw_rnglist(Dwarf_Debug dbg,Dwarf_Error *error)
{
Dwarf_Unsigned count = 0;
int res = 0;
res = dwarf_load_rnglists(dbg,&count,error);
if (res != DW_DLV_OK) {
return res;
}
for (i =0 ; i < count ; ++i) {
Dwarf_Unsigned header_offset = 0;
Dwarf_Small offset_size = 0;
Dwarf_Small extension_size = 0;
unsigned version = 0; /* 5 */
Dwarf_Small address_size = 0;
Dwarf_Small segment_selector_size = 0;
Dwarf_Unsigned offset_entry_count = 0;
Dwarf_Unsigned offset_of_offset_array = 0;
Dwarf_Unsigned offset_of_first_rangeentry = 0;
Dwarf_Unsigned offset_past_last_rangeentry = 0;
&header_offset,&offset_size,&extension_size,
&version,&address_size,&segment_selector_size,
&offset_entry_count,&offset_of_offset_array,
&offset_of_first_rangeentry,
&offset_past_last_rangeentry,error);
if (res != DW_DLV_OK) {
return res;
}
{
unsigned colmax = 4;
unsigned col = 0;
Dwarf_Unsigned global_offset_of_value = 0;
for ( ; e < offset_entry_count; ++e) {
Dwarf_Unsigned value = 0;
int resc = 0;
i,e,&value,
&global_offset_of_value,error);
if (resc != DW_DLV_OK) {
return resc;
}
/* Do something */
col++;
if (col == colmax) {
col = 0;
}
}
}
{
Dwarf_Unsigned curoffset = offset_of_first_rangeentry;
Dwarf_Unsigned endoffset = offset_past_last_rangeentry;
int rese = 0;
for ( ; curoffset < endoffset; ++ct ) {
unsigned entrylen = 0;
unsigned code = 0;
rese = dwarf_get_rnglist_rle(dbg,i,
curoffset,endoffset,
&entrylen,
&code,&v1,&v2,error);
if (rese != DW_DLV_OK) {
return rese;
}
/* Do something with the values */
curoffset += entrylen;
if (curoffset > endoffset) {
return DW_DLV_ERROR;
}
}
}
}
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 char Dwarf_Small
Definition: libdwarf.h:204
unsigned long long Dwarf_Unsigned
Definition: libdwarf.h:196
int dwarf_get_rnglist_rle(Dwarf_Debug dw_dbg, Dwarf_Unsigned dw_contextnumber, Dwarf_Unsigned dw_entry_offset, Dwarf_Unsigned dw_endoffset, unsigned int *dw_entrylen, unsigned int *dw_entry_kind, Dwarf_Unsigned *dw_entry_operand1, Dwarf_Unsigned *dw_entry_operand2, Dwarf_Error *dw_error)
Access to raw rnglists range data.
int dwarf_load_rnglists(Dwarf_Debug dw_dbg, Dwarf_Unsigned *dw_rnglists_count, Dwarf_Error *dw_error)
Loads all .debug_rnglists headers.
int dwarf_get_rnglist_offset_index_value(Dwarf_Debug dw_dbg, Dwarf_Unsigned dw_context_index, Dwarf_Unsigned dw_offsetentry_index, Dwarf_Unsigned *dw_offset_value_out, Dwarf_Unsigned *dw_global_offset_value_out, Dwarf_Error *dw_error)
Retrieve the section offset of a rnglist.
int dwarf_get_rnglist_context_basics(Dwarf_Debug dw_dbg, Dwarf_Unsigned dw_index, Dwarf_Unsigned *dw_header_offset, Dwarf_Small *dw_offset_size, Dwarf_Small *dw_extension_size, unsigned int *dw_version, Dwarf_Small *dw_address_size, Dwarf_Small *dw_segment_selector_size, Dwarf_Unsigned *dw_offset_entry_count, Dwarf_Unsigned *dw_offset_of_offset_array, Dwarf_Unsigned *dw_offset_of_first_rangeentry, Dwarf_Unsigned *dw_offset_past_last_rangeentry, Dwarf_Error *dw_error)
Access to rnglists header data.