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§
sourcetype UnwindRegs
type UnwindRegs
The unwind registers type for the targeted CPU architecture.
Required Methods§
sourcefn add_module(&mut self, module: Self::Module)
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.
sourcefn remove_module(&mut self, module_avma_range_start: u64)
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.
sourcefn max_known_code_address(&self) -> u64
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.
sourcefn unwind_frame<F>(
&self,
address: FrameAddress,
regs: &mut Self::UnwindRegs,
cache: &mut Self::Cache,
read_stack: &mut F
) -> Result<Option<u64>, Error>
fn unwind_frame<F>( &self, address: FrameAddress, regs: &mut Self::UnwindRegs, cache: &mut Self::Cache, read_stack: &mut F ) -> Result<Option<u64>, Error>
Unwind a single frame, to recover return address and caller register values. This is the main entry point for unwinding.
Provided Methods§
sourcefn 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>
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>
Return an iterator that unwinds frame by frame until the end of the stack is found.