Struct framehop::UnwindIterator
source · pub struct UnwindIterator<'u, 'c, 'r, U: Unwinder + ?Sized, F: FnMut(u64) -> Result<u64, ()>> { /* private fields */ }
Expand description
An iterator for unwinding the entire stack, starting from the initial register values.
The first yielded frame is the instruction pointer. Subsequent addresses are return addresses.
This iterator attempts to detect if stack unwinding completed successfully, or if the
stack was truncated prematurely. If it thinks that it successfully found the root
function, it will complete with Ok(None)
, otherwise it will complete with Err(...)
.
However, the detection does not work in all cases, so you should expect Err(...)
to
be returned even during normal operation. As a result, it is not recommended to use
this iterator as a FallibleIterator
, because you might lose the entire stack if the
last iteration returns Err(...)
.
Lifetimes:
'u
: The lifetime of theUnwinder
.'c
: The lifetime of the unwinder cache.'r
: The lifetime of the exclusive access to theread_stack
callback.
Implementations§
source§impl<'u, 'c, 'r, U: Unwinder + ?Sized, F: FnMut(u64) -> Result<u64, ()>> UnwindIterator<'u, 'c, 'r, U, F>
impl<'u, 'c, 'r, U: Unwinder + ?Sized, F: FnMut(u64) -> Result<u64, ()>> UnwindIterator<'u, 'c, 'r, U, F>
sourcepub fn new(
unwinder: &'u U,
pc: u64,
regs: U::UnwindRegs,
cache: &'c mut U::Cache,
read_stack: &'r mut F
) -> Self
pub fn new( unwinder: &'u U, pc: u64, regs: U::UnwindRegs, cache: &'c mut U::Cache, read_stack: &'r mut F ) -> Self
Create a new iterator. You’d usually use Unwinder::iter_frames
instead.
source§impl<'u, 'c, 'r, U: Unwinder + ?Sized, F: FnMut(u64) -> Result<u64, ()>> UnwindIterator<'u, 'c, 'r, U, F>
impl<'u, 'c, 'r, U: Unwinder + ?Sized, F: FnMut(u64) -> Result<u64, ()>> UnwindIterator<'u, 'c, 'r, U, F>
sourcepub fn next(&mut self) -> Result<Option<FrameAddress>, Error>
pub fn next(&mut self) -> Result<Option<FrameAddress>, Error>
Yield the next frame in the stack.
The first frame is Ok(Some(FrameAddress::InstructionPointer(...)))
.
Subsequent frames are Ok(Some(FrameAddress::ReturnAddress(...)))
.
If a root function has been reached, this iterator completes with Ok(None)
.
Otherwise it completes with Err(...)
, usually indicating that a certain stack
address could not be read.
Trait Implementations§
source§impl<'u, 'c, 'r, U: Unwinder + ?Sized, F: FnMut(u64) -> Result<u64, ()>> FallibleIterator for UnwindIterator<'u, 'c, 'r, U, F>
impl<'u, 'c, 'r, U: Unwinder + ?Sized, F: FnMut(u64) -> Result<u64, ()>> FallibleIterator for UnwindIterator<'u, 'c, 'r, U, F>
§type Item = FrameAddress
type Item = FrameAddress
source§fn next(&mut self) -> Result<Option<FrameAddress>, Error>
fn next(&mut self) -> Result<Option<FrameAddress>, Error>
source§fn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
source§fn count(self) -> Result<usize, Self::Error>where
Self: Sized,
fn count(self) -> Result<usize, Self::Error>where
Self: Sized,
source§fn last(self) -> Result<Option<Self::Item>, Self::Error>where
Self: Sized,
fn last(self) -> Result<Option<Self::Item>, Self::Error>where
Self: Sized,
source§fn nth(&mut self, n: usize) -> Result<Option<Self::Item>, Self::Error>
fn nth(&mut self, n: usize) -> Result<Option<Self::Item>, Self::Error>
n
th element of the iterator.source§fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
source§fn chain<I>(self, it: I) -> Chain<Self, I>
fn chain<I>(self, it: I) -> Chain<Self, I>
source§fn zip<I>(
self,
o: I
) -> Zip<Self, <I as IntoFallibleIterator>::IntoFallibleIter>
fn zip<I>( self, o: I ) -> Zip<Self, <I as IntoFallibleIterator>::IntoFallibleIter>
source§fn map<F, B>(self, f: F) -> Map<Self, F>
fn map<F, B>(self, f: F) -> Map<Self, F>
source§fn for_each<F>(self, f: F) -> Result<(), Self::Error>
fn for_each<F>(self, f: F) -> Result<(), Self::Error>
source§fn filter<F>(self, f: F) -> Filter<Self, F>
fn filter<F>(self, f: F) -> Filter<Self, F>
source§fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
source§fn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
source§fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
source§fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
source§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n
values of this iterator.source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n
values of this
iterator.source§fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
Ok(None)
. Read moresource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
source§fn collect<T>(self) -> Result<T, Self::Error>
fn collect<T>(self) -> Result<T, Self::Error>
source§fn partition<B, F>(self, f: F) -> Result<(B, B), Self::Error>
fn partition<B, F>(self, f: F) -> Result<(B, B), Self::Error>
source§fn fold<B, F>(self, init: B, f: F) -> Result<B, Self::Error>
fn fold<B, F>(self, init: B, f: F) -> Result<B, Self::Error>
source§fn try_fold<B, E, F>(&mut self, init: B, f: F) -> Result<B, E>
fn try_fold<B, E, F>(&mut self, init: B, f: F) -> Result<B, E>
source§fn all<F>(&mut self, f: F) -> Result<bool, Self::Error>
fn all<F>(&mut self, f: F) -> Result<bool, Self::Error>
source§fn any<F>(&mut self, f: F) -> Result<bool, Self::Error>
fn any<F>(&mut self, f: F) -> Result<bool, Self::Error>
source§fn find<F>(&mut self, f: F) -> Result<Option<Self::Item>, Self::Error>
fn find<F>(&mut self, f: F) -> Result<Option<Self::Item>, Self::Error>
source§fn find_map<B, F>(&mut self, f: F) -> Result<Option<B>, Self::Error>
fn find_map<B, F>(&mut self, f: F) -> Result<Option<B>, Self::Error>
None
result.