Trait gimli::read::UnwindSection

source ·
pub trait UnwindSection<R: Reader>: Clone + Debug + _UnwindSectionPrivate<R> {
    type Offset: UnwindOffset<R::Offset>;

    // Provided methods
    fn entries<'bases>(
        &self,
        bases: &'bases BaseAddresses,
    ) -> CfiEntriesIter<'bases, Self, R> { ... }
    fn cie_from_offset(
        &self,
        bases: &BaseAddresses,
        offset: Self::Offset,
    ) -> Result<CommonInformationEntry<R>> { ... }
    fn partial_fde_from_offset<'bases>(
        &self,
        bases: &'bases BaseAddresses,
        offset: Self::Offset,
    ) -> Result<PartialFrameDescriptionEntry<'bases, Self, R>> { ... }
    fn fde_from_offset<F>(
        &self,
        bases: &BaseAddresses,
        offset: Self::Offset,
        get_cie: F,
    ) -> Result<FrameDescriptionEntry<R>>
       where F: FnMut(&Self, &BaseAddresses, Self::Offset) -> Result<CommonInformationEntry<R>> { ... }
    fn fde_for_address<F>(
        &self,
        bases: &BaseAddresses,
        address: u64,
        get_cie: F,
    ) -> Result<FrameDescriptionEntry<R>>
       where F: FnMut(&Self, &BaseAddresses, Self::Offset) -> Result<CommonInformationEntry<R>> { ... }
    fn unwind_info_for_address<'ctx, F, A: UnwindContextStorage<R>>(
        &self,
        bases: &BaseAddresses,
        ctx: &'ctx mut UnwindContext<R, A>,
        address: u64,
        get_cie: F,
    ) -> Result<&'ctx UnwindTableRow<R, A>>
       where F: FnMut(&Self, &BaseAddresses, Self::Offset) -> Result<CommonInformationEntry<R>> { ... }
}
Expand description

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

Required Associated Types§

source

type Offset: UnwindOffset<R::Offset>

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

Provided Methods§

source

fn entries<'bases>( &self, bases: &'bases BaseAddresses, ) -> CfiEntriesIter<'bases, Self, R>

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

Can be used with FallibleIterator.

source

fn cie_from_offset( &self, bases: &BaseAddresses, offset: Self::Offset, ) -> Result<CommonInformationEntry<R>>

Parse the CommonInformationEntry at the given offset.

source

fn partial_fde_from_offset<'bases>( &self, bases: &'bases BaseAddresses, offset: Self::Offset, ) -> Result<PartialFrameDescriptionEntry<'bases, Self, R>>

Parse the PartialFrameDescriptionEntry at the given offset.

source

fn fde_from_offset<F>( &self, bases: &BaseAddresses, offset: Self::Offset, get_cie: F, ) -> Result<FrameDescriptionEntry<R>>

Parse the FrameDescriptionEntry at the given offset.

source

fn fde_for_address<F>( &self, bases: &BaseAddresses, address: u64, get_cie: F, ) -> Result<FrameDescriptionEntry<R>>

Find the FrameDescriptionEntry for the given address.

If found, the FDE is returned. If not found, Err(gimli::Error::NoUnwindInfoForAddress) is returned. If parsing fails, the error is returned.

You must provide a function to get its associated CIE. See PartialFrameDescriptionEntry::parse for more information.

Note: this iterates over all FDEs. If available, it is possible to do a binary search with EhFrameHdr::fde_for_address instead.

source

fn unwind_info_for_address<'ctx, F, A: UnwindContextStorage<R>>( &self, bases: &BaseAddresses, ctx: &'ctx mut UnwindContext<R, A>, address: u64, get_cie: F, ) -> Result<&'ctx UnwindTableRow<R, A>>

Find the frame unwind information for the given address.

If found, the unwind information is returned. 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, UnwindContext,
            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 = UnwindContext::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_got(address_of_got_section_in_memory);

let unwind_info = eh_frame.unwind_info_for_address(
    &bases,
    &mut ctx,
    address,
    EhFrame::cie_from_offset,
)?;

do_stuff_with(unwind_info);

Object Safety§

This trait is not object safe.

Implementors§