Module read
Read DWARF debugging information.
Example Usage
Print out all of the functions in the debuggee program:
#
Full example programs:
-
ddbug, a utility giving insight into code generation by making debugging information readable -
dwprod, a tiny utility to list the compilers used to create each compilation unit within a shared library or executable (viaDW_AT_producer) -
dwarf-validate, a program to validate the integrity of some DWARF and its references between sections and compilation units.
API Structure
-
Basic familiarity with DWARF is assumed.
-
The
Dwarftype contains the commonly used DWARF sections. It has methods that simplify access to debugging data that spans multiple sections. Use of this type is optional, but recommended. -
The
DwarfPackagetype contains the DWARF package (DWP) sections. It has methods to find a DWARF object (DWO) within the package. -
Each section gets its own type. Consider these types the entry points to the library:
-
DebugAbbrev: The.debug_abbrevsection. -
DebugAddr: The.debug_addrsection. -
DebugAranges: The.debug_arangessection. -
DebugFrame: The.debug_framesection. -
DebugInfo: The.debug_infosection. -
DebugLine: The.debug_linesection. -
DebugLineStr: The.debug_line_strsection. -
DebugLoc: The.debug_locsection. -
DebugLocLists: The.debug_loclistssection. -
DebugPubNames: The.debug_pubnamessection. -
DebugPubTypes: The.debug_pubtypessection. -
DebugRanges: The.debug_rangessection. -
DebugRngLists: The.debug_rnglistssection. -
DebugStr: The.debug_strsection. -
DebugStrOffsets: The.debug_str_offsetssection. -
DebugTypes: The.debug_typessection. -
DebugCuIndex: The.debug_cu_indexsection. -
DebugTuIndex: The.debug_tu_indexsection. -
EhFrame: The.eh_framesection. -
EhFrameHdr: The.eh_frame_hdrsection.
-
-
Each section type exposes methods for accessing the debugging data encoded in that section. For example, the
DebugInfostruct has theunitsmethod for iterating over the compilation units defined within it. -
Offsets into a section are strongly typed: an offset into
.debug_infois theDebugInfoOffsettype. It cannot be used to index into theDebugLinetype becauseDebugLinerepresents the.debug_linesection. There are similar types for offsets relative to a compilation unit rather than a section.
Using with FallibleIterator
The standard library's Iterator trait and related APIs do not play well
with iterators where the next operation is fallible. One can make the
Iterator's associated Item type be a Result<T, E>, however the
provided methods cannot gracefully handle the case when an Err is
returned.
This situation led to the
fallible-iterator crate's
existence. You can read more of the rationale for its existence in its
docs. The crate provides the helpers you have come to expect (eg map,
filter, etc) for iterators that can fail.
gimli's many lazy parsing iterators are a perfect match for the
fallible-iterator crate's FallibleIterator trait because parsing is not
done eagerly. Parse errors later in the input might only be discovered after
having iterated through many items.
To use gimli iterators with FallibleIterator, import the crate and trait
into your code:
#
#
#
Structs
- StoreOnHeap Indicates that storage should be allocated on heap.
- UnitOffset An offset into the current compilation or type unit.
Enums
- Error An error that occurred when parsing.
Traits
- Section A convenience trait for loading DWARF sections from object files. To be used like: