libdwarf
Accessing rnglists section

Example showing access to rnglists on an Attribute.

This is accessing DWARF5 .debug_rnglists. The section first appears in DWARF5.

*/
int example_rnglist_for_attribute(Dwarf_Attribute attr,
Dwarf_Unsigned attrvalue,Dwarf_Error *error)
{
/* attrvalue must be the DW_AT_ranges
DW_FORM_rnglistx or DW_FORM_sec_offset value
extracted from attr. */
int res = 0;
Dwarf_Half theform = 0;
Dwarf_Unsigned entries_count;
Dwarf_Unsigned global_offset_of_rle_set;
Dwarf_Rnglists_Head rnglhead = 0;
theform,
attrvalue,
&rnglhead,
&entries_count,
&global_offset_of_rle_set,
error);
if (res != DW_DLV_OK) {
return res;
}
for (i = 0; i < entries_count; ++i) {
unsigned entrylen = 0;
unsigned code = 0;
Dwarf_Unsigned rawlowpc = 0;
Dwarf_Unsigned rawhighpc = 0;
Dwarf_Bool debug_addr_unavailable = FALSE;
Dwarf_Unsigned lowpc = 0;
Dwarf_Unsigned highpc = 0;
/* Actual addresses are most likely what one
wants to know, not the lengths/offsets
recorded in .debug_rnglists. */
i,&entrylen,&code,
&rawlowpc,&rawhighpc,
&debug_addr_unavailable,
&lowpc,&highpc,error);
if (res != DW_DLV_OK) {
return res;
}
if (code == DW_RLE_end_of_list) {
/* we are done */
break;
}
if (code == DW_RLE_base_addressx ||
code == DW_RLE_base_address) {
/* We do not need to use these, they
have been accounted for already. */
continue;
}
if (debug_addr_unavailable) {
/* lowpc and highpc are not real addresses */
continue;
}
/* Here do something with lowpc and highpc, these
are real addresses */
}
return DW_DLV_OK;
}
struct Dwarf_Rnglists_Head_s * Dwarf_Rnglists_Head
Definition: libdwarf.h:835
struct Dwarf_Error_s * Dwarf_Error
Definition: libdwarf.h:580
struct Dwarf_Attribute_s * Dwarf_Attribute
Definition: libdwarf.h:641
unsigned short Dwarf_Half
Definition: libdwarf.h:203
unsigned long long Dwarf_Unsigned
Definition: libdwarf.h:196
int Dwarf_Bool
Definition: libdwarf.h:202
int dwarf_rnglists_get_rle_head(Dwarf_Attribute dw_attr, Dwarf_Half dw_theform, Dwarf_Unsigned dw_index_or_offset_value, Dwarf_Rnglists_Head *dw_head_out, Dwarf_Unsigned *dw_count_of_entries_in_head, Dwarf_Unsigned *dw_global_offset_of_rle_set, Dwarf_Error *dw_error)
Get Access to DWARF5 rnglists.
void dwarf_dealloc_rnglists_head(Dwarf_Rnglists_Head dw_head)
Dealloc a Dwarf_Rnglists_Head.
int dwarf_get_rnglists_entry_fields_a(Dwarf_Rnglists_Head dw_head, Dwarf_Unsigned dw_entrynum, unsigned int *dw_entrylen, unsigned int *dw_rle_value_out, Dwarf_Unsigned *dw_raw1, Dwarf_Unsigned *dw_raw2, Dwarf_Bool *dw_debug_addr_unavailable, Dwarf_Unsigned *dw_cooked1, Dwarf_Unsigned *dw_cooked2, Dwarf_Error *dw_error)
Access rnglist entry details.