libdwarf
Functions
Ranges: code addresses in DWARF3-4

Functions

int dwarf_get_ranges_b (Dwarf_Debug dw_dbg, Dwarf_Off dw_rangesoffset, Dwarf_Die dw_die, Dwarf_Off *dw_return_realoffset, Dwarf_Ranges **dw_rangesbuf, Dwarf_Signed *dw_rangecount, Dwarf_Unsigned *dw_bytecount, Dwarf_Error *dw_error)
 Access to code ranges from a CU or just reading through the raw .debug_ranges section. More...
 
void dwarf_dealloc_ranges (Dwarf_Debug dw_dbg, Dwarf_Ranges *dw_rangesbuf, Dwarf_Signed dw_rangecount)
 Dealloc the array dw_rangesbuf. More...
 

Detailed Description

In DWARF3 and DWARF4 the DW_AT_ranges attribute provides an offset into the .debug_ranges section, which contains code address ranges.

See also
Dwarf_Ranges

DWARF3 and DWARF4. DW_AT_ranges with an unsigned constant FORM (DWARF3) or DW_FORM_sec_offset(DWARF4).

Function Documentation

◆ dwarf_get_ranges_b()

int dwarf_get_ranges_b ( Dwarf_Debug  dw_dbg,
Dwarf_Off  dw_rangesoffset,
Dwarf_Die  dw_die,
Dwarf_Off dw_return_realoffset,
Dwarf_Ranges **  dw_rangesbuf,
Dwarf_Signed dw_rangecount,
Dwarf_Unsigned dw_bytecount,
Dwarf_Error dw_error 
)

Adds return of the dw_realoffset to accommodate DWARF4 GNU split-dwarf, where the ranges could be in the tieddbg (meaning the real executable, a.out, not in a dwp). DWARF4 split-dwarf is an extension, not standard DWARF4.

If printing all entries in the section pass in an initial dw_rangesoffset of zero and dw_die of NULL. Then increment dw_rangesoffset by dw_bytecount and call again to get the next batch of ranges. With a specific option dwarfdump can do this. This not a normal thing to do!

See also
Example getting .debug_ranges data
Parameters
dw_dbgThe Dwarf_Debug of interest
dw_rangesoffsetThe offset to read from in the section.
dw_diePass in the DIE whose DW_AT_ranges brought us to ranges.
dw_return_realoffsetThe actual offset in the section actually read. In a tieddbg this
dw_rangesbufA pointer to an array of structs is returned here.
dw_rangecountThe count of structs in the array is returned here.
dw_bytecountThe number of bytes in the .debug_ranges section applying to the returned array. This makes possible just marching through the section by offset.
dw_errorThe usual error detail return pointer.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_dealloc_ranges()

void dwarf_dealloc_ranges ( Dwarf_Debug  dw_dbg,
Dwarf_Ranges dw_rangesbuf,
Dwarf_Signed  dw_rangecount 
)
Parameters
dw_dbgThe Dwarf_Debug of interest.
dw_rangesbufThe dw_rangesbuf pointer returned by dwarf_get_ranges_b
dw_rangecountThe dw_rangecount returned by dwarf_get_ranges_b