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...
 
int dwarf_get_ranges_baseaddress (Dwarf_Debug dw_dbg, Dwarf_Die dw_die, Dwarf_Bool *dw_known_base, Dwarf_Unsigned *dw_baseaddress, Dwarf_Bool *dw_at_ranges_offset_present, Dwarf_Unsigned *dw_at_ranges_offset, Dwarf_Error *dw_error)
 Find ranges base address. 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 dwp DWARF4 extension object the base offset is added to dw_rangesoffset and returned here.
dw_rangesbufA pointer to an array of structs is returned here. The struct contents are the raw values in the section.
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

◆ dwarf_get_ranges_baseaddress()

int dwarf_get_ranges_baseaddress ( Dwarf_Debug  dw_dbg,
Dwarf_Die  dw_die,
Dwarf_Bool dw_known_base,
Dwarf_Unsigned dw_baseaddress,
Dwarf_Bool dw_at_ranges_offset_present,
Dwarf_Unsigned dw_at_ranges_offset,
Dwarf_Error dw_error 
)

The function allows callers to calculate actual address from .debug_ranges data in a simple and efficient way.

Parameters
dw_dbgThe Dwarf_Debug of interest.
dw_diePass in any non-null valid Dwarf_Die to find the applicable .debug_ranges base address. The dw_die need not be a CU-DIE. A null dw_die is allowed.
dw_known_baseif dw_die is non-null and there is a known base address for the CU DIE that (a DW_at_low_pc in the CU DIE) dw_known_base will be set TRUE, Otherwise the value FALSE will be returned through dw_known_base.
dw_baseaddressif dw_known_base is retured as TRUE then dw_baseaddress will be set with the correct pc value. Otherwise zero will be set through dw_baseaddress.
dw_at_ranges_offset_presentSet to 1 (TRUE) if the dw_die has the attribute DW_AT_ranges, otherwise set to zero (FALSE).
dw_at_ranges_offsetSet to the value of dw_die DW_AT_ranges attribute of dw_die if and only iff dw_at_ranges_offset_present was set to 1.
dw_errorThe usual error detail return pointer.
Returns
Returns DW_DLV_OK or DW_DLV_ERROR. Never returns DW_DLV_NO_ENTRY.