Trait framehop::Unwinder

source ·
pub trait Unwinder: Clone {
    type UnwindRegs;
    type Cache;
    type Module;

    // Required methods
    fn add_module(&mut self, module: Self::Module);
    fn remove_module(&mut self, module_avma_range_start: u64);
    fn max_known_code_address(&self) -> u64;
    fn unwind_frame<F>(
        &self,
        address: FrameAddress,
        regs: &mut Self::UnwindRegs,
        cache: &mut Self::Cache,
        read_stack: &mut F
    ) -> Result<Option<u64>, Error>
       where F: FnMut(u64) -> Result<u64, ()>;

    // Provided method
    fn iter_frames<'u, 'c, 'r, F>(
        &'u self,
        pc: u64,
        regs: Self::UnwindRegs,
        cache: &'c mut Self::Cache,
        read_stack: &'r mut F
    ) -> UnwindIterator<'u, 'c, 'r, Self, F>
       where F: FnMut(u64) -> Result<u64, ()> { ... }
}
Expand description

Unwinder is the trait that each CPU architecture’s concrete unwinder type implements. This trait’s methods are what let you do the actual unwinding.

Required Associated Types§

source

type UnwindRegs

The unwind registers type for the targeted CPU architecture.

source

type Cache

The unwind cache for the targeted CPU architecture. This is an associated type because the cache stores unwind rules, whose concrete type depends on the CPU arch, and because the cache can support different allocation policies.

source

type Module

The module type. This is an associated type because the concrete type varies depending on the type you use to give the module access to the unwind section data.

Required Methods§

source

fn add_module(&mut self, module: Self::Module)

Add a module that’s loaded in the profiled process. This is how you provide unwind information and address ranges.

This should be called whenever a new module is loaded into the process.

source

fn remove_module(&mut self, module_avma_range_start: u64)

Remove a module that was added before using add_module, keyed by the start address of that module’s address range. If no match is found, the call is ignored. This should be called whenever a module is unloaded from the process.

source

fn max_known_code_address(&self) -> u64

Returns the highest code address that is known in this process based on the module address ranges. Returns 0 if no modules have been added.

This method can be used together with PtrAuthMask::from_max_known_address to make an educated guess at a pointer authentication mask for Aarch64 return addresses.

source

fn unwind_frame<F>( &self, address: FrameAddress, regs: &mut Self::UnwindRegs, cache: &mut Self::Cache, read_stack: &mut F ) -> Result<Option<u64>, Error>
where F: FnMut(u64) -> Result<u64, ()>,

Unwind a single frame, to recover return address and caller register values. This is the main entry point for unwinding.

Provided Methods§

source

fn iter_frames<'u, 'c, 'r, F>( &'u self, pc: u64, regs: Self::UnwindRegs, cache: &'c mut Self::Cache, read_stack: &'r mut F ) -> UnwindIterator<'u, 'c, 'r, Self, F>
where F: FnMut(u64) -> Result<u64, ()>,

Return an iterator that unwinds frame by frame until the end of the stack is found.

Object Safety§

This trait is not object safe.

Implementors§