libdwarf: Example getting .debug_ranges data

libdwarf

Loading...
Searching...
No Matches
Example getting .debug_ranges data

Example accessing ranges data.

Example accessing ranges data.

If have_base_addr is false there is no die (as in reading the raw .debug_ranges section) or there is some serious data corruption somewhere.

*/
static
void functionusingrange(Dwarf_Signed i,Dwarf_Ranges *r,
Dwarf_Bool *have_base_addr,
Dwarf_Unsigned *baseaddr)
{
Dwarf_Unsigned base = *baseaddr;
printf("[%4ld] ",(signed long)i);
switch(r->dwr_type) {
case DW_RANGES_ENTRY:
printf(
"DW_RANGES_ENTRY: raw addr1 " PRX
" addr2 " PRX,
r->dwr_addr1,r->dwr_addr2);
if (r->dwr_addr1 == r->dwr_addr2) {
printf(" (empty range)");
}
printf("\n");
if (*have_base_addr) {
printf(" "
"DW_RANGES_ENTRY: cooked addr1 0x%08llx"
" addr2 " PRX "\n" ,
r->dwr_addr1+base,r->dwr_addr2+base);
}
break;
case DW_RANGES_ADDRESS_SELECTION:
printf(
"Base Address : " PRX "\n",
r->dwr_addr2);
have_base_addr = TRUE;
baseaddr = r->dwr_addr2;
break;
case DW_RANGES_END:
printf(
"DW_RANGES_END : 0,0\n");
have_base_addr = FALSE;
baseaddr = 0;
break;
default:
printf(
"ERROR : incorrect dwr_type is 0x%lx\n",
(unsigned long)r->dwr_type);
}
}
/* On call the rangesoffset is a default zero.
Dwarf_Ranges
struct Dwarf_Ranges_s Dwarf_Ranges
Dwarf_Bool
int Dwarf_Bool
Definition libdwarf.h:202
Dwarf_Unsigned
unsigned long long Dwarf_Unsigned
Definition libdwarf.h:196
Dwarf_Signed
signed long long Dwarf_Signed
Definition libdwarf.h:197