libdwarf: Ranges: code addresses in DWARF3-4

libdwarf

Loading...
Searching...
No Matches
Functions
Ranges: code addresses in DWARF3-4

## Functions
DW_API 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.
DW_API void | dwarf_dealloc_ranges (Dwarf_Debug dw_dbg, Dwarf_Ranges *dw_rangesbuf, Dwarf_Signed dw_rangecount)
| Dealloc the array dw_rangesbuf.
DW_API 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.

## 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_dealloc_ranges()

DW_API void dwarf_dealloc_ranges | ( | Dwarf_Debug | dw_dbg,
|  | Dwarf_Ranges * | dw_rangesbuf,
|  | Dwarf_Signed | dw_rangecount )

Dealloc the array dw_rangesbuf.

Parameters

  dw_dbg | The Dwarf_Debug of interest.
  dw_rangesbuf | The dw_rangesbuf pointer returned by dwarf_get_ranges_b
  dw_rangecount | The dw_rangecount returned by dwarf_get_ranges_b

## ◆ dwarf_get_ranges_b()

DW_API 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.

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_dbg | The Dwarf_Debug of interest
  dw_rangesoffset | The offset to read from in the section.
  dw_die | Pass in the DIE whose DW_AT_ranges brought us to ranges.
  dw_return_realoffset | The 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_rangesbuf | A pointer to an array of structs is returned here. The struct contents are the raw values in the section.
  dw_rangecount | The count of structs in the array is returned here.
  dw_bytecount | The number of bytes in the .debug_ranges section applying to the returned array. This makes possible just marching through the section by offset.
  dw_error | The usual error detail return pointer.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_get_ranges_baseaddress()

DW_API 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.

The function allows callers to calculate actual address from .debug_ranges data in a simple and efficient way by returning the CU DIE ranges baseaddress.

Parameters

  dw_dbg | The Dwarf_Debug of interest.
  dw_die | Pass 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_base | if 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_baseaddress | if dw_known_base is returned 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_present | Set to 1 (TRUE) if dw_die has the attribute DW_AT_ranges.
  dw_at_ranges_offset | Set to the value of DW_AT_ranges attribute of dw_die if dw_at_ranges_offset_present was set to TRUE. The offset is of the beginning of the .debug_ranges section range lists applying to this DIE.
  dw_error | The usual error detail return pointer.

Returns
  Returns DW_DLV_OK or DW_DLV_ERROR. Never returns DW_DLV_NO_ENTRY.