pub struct UnwindCursor<'a> { /* private fields */ }Expand description
A cursor that can move up the call chain and gather information about stack frames.
This struct provides functionality for reading and writing the CPU registers
that were preserved in stack frames, as well as moving “up” the call chain
to previous function calls. It can be initialized to point to a certain frame
using the data in an UnwindContext.
Implementations§
Source§impl<'a> UnwindCursor<'a>
impl<'a> UnwindCursor<'a>
Sourcepub fn new(context: &UnwindContext<'a>) -> Result<Self, UnwindError>
pub fn new(context: &UnwindContext<'a>) -> Result<Self, UnwindError>
Initializes a cursor for local unwinding using the state captured by the
given UnwindContext.
Sourcepub fn step(&mut self) -> Result<bool, UnwindError>
pub fn step(&mut self) -> Result<bool, UnwindError>
Advances to the next (older) frame of the call chain.
Returns true if was another frame to step to or false if the cursor has reached the end.
§Errors
This function may return one of the following errors:
UnwindError::Unspecifiedif an unspecified error occurredUnwindError::NoInfoiflibunwindwas unable to locate the required unwind infoUnwindError::BadVersionif the unwind info has an unsupported version or formatUnwindError::InvalidIPif the instruction pointer of the next frame is invalidUnwindError::BadFrameif the next frame is invalid
Sourcepub fn register(&self, register: unw_regnum_t) -> Result<usize, UnwindError>
pub fn register(&self, register: unw_regnum_t) -> Result<usize, UnwindError>
Retrieves the value of the given register for the cursor’s current frame.
§Errors
This function may return one of the following errors:
UnwindError::Unspecifiedif an unspecified error occurredUnwindError::BadRegisterif the register was invalid or inaccessible in the current frame
Sourcepub unsafe fn set_register(
&self,
register: unw_regnum_t,
value: unw_word_t,
) -> Result<(), UnwindError>
pub unsafe fn set_register( &self, register: unw_regnum_t, value: unw_word_t, ) -> Result<(), UnwindError>
Sets the value of the given register in the cursor’s current frame to the given value.
§Safety
The caller must ensure that updating the stack frame as described above will not cause undefined behavior.
§Errors
This function may return one of the following errors:
UnwindError::Unspecifiedif an unspecified error occurredUnwindError::BadRegisterif the register was invalid or inaccessible in the current frameUnwindError::WriteToReadOnlyRegisterif the register was read-only
Sourcepub fn fp_register(&self, register: unw_regnum_t) -> Result<usize, UnwindError>
pub fn fp_register(&self, register: unw_regnum_t) -> Result<usize, UnwindError>
Retrieves the value of the given floating point register for the cursor’s current frame.
§Errors
This function may return one of the following errors:
UnwindError::Unspecifiedif an unspecified error occurredUnwindError::BadRegisterif the register was invalid or inaccessible in the current frame
Sourcepub unsafe fn set_fp_register(
&self,
register: unw_regnum_t,
value: unw_fpreg_t,
) -> Result<(), UnwindError>
pub unsafe fn set_fp_register( &self, register: unw_regnum_t, value: unw_fpreg_t, ) -> Result<(), UnwindError>
Sets the value of the given floating-point register in the cursor’s current frame to the given value.
§Safety
The caller must ensure that updating the stack frame as described above will not cause undefined behavior.
§Errors
This function may return one of the following errors:
UnwindError::Unspecifiedif an unspecified error occurredUnwindError::BadRegisterif the register was invalid or inaccessible in the current frameUnwindError::WriteToReadOnlyRegisterif the register was read-only
Sourcepub fn is_fp_register(&self, register: unw_regnum_t) -> bool
pub fn is_fp_register(&self, register: unw_regnum_t) -> bool
Checks whether the given register is a floating-point register.
Sourcepub fn is_signal_frame(&self) -> Result<bool, UnwindError>
pub fn is_signal_frame(&self) -> Result<bool, UnwindError>
Checks whether the current frame is a “signal frame,” which is defined as a frame created in response to a potentially asynchronous interruption such as a device interrupt.
Signal frames offer access to a larger range of registers because their nature requires saving the contents of registers normally treated as “scratch” registers.
Corresponds to unw_is_signal_frame.
§Errors
If libunwind is unable to determine whether the cursor is pointing to
a signal frame, UnwindError::NoInfo is returned.
Sourcepub fn register_name(&self, register: unw_regnum_t) -> Option<&'static CStr>
pub fn register_name(&self, register: unw_regnum_t) -> Option<&'static CStr>
Returns the name of the given register as a string, or [None] if the
register does not exist.
Sourcepub const unsafe fn from_raw(raw: unw_cursor_t) -> Self
pub const unsafe fn from_raw(raw: unw_cursor_t) -> Self
Creates a new UnwindCursor from a raw cursor acquired through FFI.
§Safety
The returned cursor must be dropped before the stack frame it points at is destroyed.
Trait Implementations§
Source§impl<'a> Clone for UnwindCursor<'a>
impl<'a> Clone for UnwindCursor<'a>
Source§fn clone(&self) -> UnwindCursor<'a>
fn clone(&self) -> UnwindCursor<'a>
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<'a> !Freeze for UnwindCursor<'a>
impl<'a> !RefUnwindSafe for UnwindCursor<'a>
impl<'a> Send for UnwindCursor<'a>
impl<'a> !Sync for UnwindCursor<'a>
impl<'a> Unpin for UnwindCursor<'a>
impl<'a> UnwindSafe for UnwindCursor<'a>
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)