Trait gimli::UnwindSection[][src]

pub trait UnwindSection<R: Reader>: Clone + Debug + _UnwindSectionPrivate<R> {
    type Offset: UnwindOffset<R::Offset>;
    fn entries<'bases>(
        &self,
        bases: &'bases BaseAddresses
    ) -> CfiEntriesIter<'bases, Self, R> { ... }
fn cie_from_offset<'bases>(
        &self,
        bases: &'bases BaseAddresses,
        offset: Self::Offset
    ) -> Result<CommonInformationEntry<Self, R, R::Offset>> { ... }
fn unwind_info_for_address<'bases>(
        &self,
        bases: &'bases BaseAddresses,
        ctx: UninitializedUnwindContext<Self, R>,
        address: u64
    ) -> UnwindResult<(UnwindTableRow<R>, UninitializedUnwindContext<Self, R>), UninitializedUnwindContext<Self, R>> { ... } }

A section holding unwind information: either .debug_frame or .eh_frame. See DebugFrame and EhFrame respectively.

Associated Types

The offset type associated with this CFI section. Either DebugFrameOffset or EhFrameOffset.

Provided Methods

Iterate over the CommonInformationEntrys and FrameDescriptionEntrys in this .debug_frame section.

Can be used with FallibleIterator.

Parse the CommonInformationEntry at the given offset.

Find the frame unwind information for the given address.

If found, the unwind information is returned along with the reset context in the form Ok((unwind_info, context)). If not found, Err(gimli::Error::NoUnwindInfoForAddress) is returned. If parsing or CFI evaluation fails, the error is returned.

use gimli::{BaseAddresses, EhFrame, EndianSlice, NativeEndian, UninitializedUnwindContext,
            UnwindSection};

// Get the `.eh_frame` section from the object file. Alternatively,
// use `EhFrame` with the `.eh_frame` section of the object file.
let eh_frame = EhFrame::new(read_eh_frame_section(), NativeEndian);

// Get the address of the PC for a frame you'd like to unwind.
let address = get_frame_pc();

// This context is reusable, which cuts down on heap allocations.
let ctx = UninitializedUnwindContext::new();

// Optionally provide base addresses for any relative pointers. If a
// base address isn't provided and a pointer is found that is relative to
// it, we will return an `Err`.
let bases = BaseAddresses::default()
    .set_text(address_of_text_section_in_memory)
    .set_data(address_of_data_section_in_memory);

let (unwind_info, ctx) = eh_frame.unwind_info_for_address(&bases, ctx, address)
    .map_err(|(err, ctx)| {
        // Recover the uninitialized `ctx` to reuse it in future unwinding.
        recover(ctx);
        err
    })?;

do_stuff_with(unwind_info);

Implementors