UnwindCursor

Struct UnwindCursor 

Source
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>

Source

pub fn new(context: &UnwindContext<'a>) -> Result<Self, UnwindError>

Initializes a cursor for local unwinding using the state captured by the given UnwindContext.

Source

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:

Source

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:

Source

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:

Source

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:

Source

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:

Source

pub fn is_fp_register(&self, register: unw_regnum_t) -> bool

Checks whether the given register is a floating-point register.

Source

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.

Source

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.

Source

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>

Source§

fn clone(&self) -> UnwindCursor<'a>

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnwindCursor<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto 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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.