Struct gimli::read::UnwindContext

source ·
pub struct UnwindContext<T, S = StoreOnHeap>{
    stack: ArrayVec<S::Stack>,
    initial_rule: Option<(Register, RegisterRule<T>)>,
    is_initialized: bool,
}
Expand description

Common context needed when evaluating the call frame unwinding information.

By default, this structure is small and allocates its internal storage on the heap using Box during UnwindContext::new.

This can be overridden by providing a custom UnwindContextStorage type parameter. When using a custom storage with in-line arrays, the UnwindContext type itself will be big, so in that case it’s recommended to place UnwindContext on the heap, e.g. using Box::new(UnwindContext::<R, MyCustomStorage>::new_in()).

To avoid re-allocating the context multiple times when evaluating multiple CFI programs, the same UnwindContext can be reused for multiple unwinds.

use gimli::{UnwindContext, UnwindTable};

// An uninitialized context.
let mut ctx = UnwindContext::new();

// Initialize the context by evaluating the CIE's initial instruction program,
// and generate the unwind table.
let mut table = some_fde.rows(&eh_frame, &bases, &mut ctx)?;
while let Some(row) = table.next_row()? {
    // Do stuff with each row...
}

Fields§

§stack: ArrayVec<S::Stack>§initial_rule: Option<(Register, RegisterRule<T>)>§is_initialized: bool

Implementations§

source§

impl<T: ReaderOffset> UnwindContext<T>

source

pub fn new() -> Self

Construct a new call frame unwinding context.

source§

impl<T, S> UnwindContext<T, S>

§Signal Safe Methods

These methods are guaranteed not to allocate, acquire locks, or perform any other signal-unsafe operations, if an non-allocating storage is used.

source

pub fn new_in() -> Self

Construct a new call frame unwinding context.

source

fn initialize<Section, R>( &mut self, section: &Section, bases: &BaseAddresses, cie: &CommonInformationEntry<R>, ) -> Result<()>
where R: Reader<Offset = T>, Section: UnwindSection<R>,

Run the CIE’s initial instructions and initialize this UnwindContext.

source

fn reset(&mut self)

source

fn row(&self) -> &UnwindTableRow<T, S>

source

fn row_mut(&mut self) -> &mut UnwindTableRow<T, S>

source

fn save_initial_rules(&mut self) -> Result<()>

source

fn start_address(&self) -> u64

source

fn set_start_address(&mut self, start_address: u64)

source

fn set_register_rule( &mut self, register: Register, rule: RegisterRule<T>, ) -> Result<()>

source

fn get_initial_rule(&self, register: Register) -> Option<RegisterRule<T>>

Returns None if we have not completed evaluation of a CIE’s initial instructions.

source

fn set_cfa(&mut self, cfa: CfaRule<T>)

source

fn cfa_mut(&mut self) -> &mut CfaRule<T>

source

fn push_row(&mut self) -> Result<()>

source

fn pop_row(&mut self) -> Result<()>

Trait Implementations§

source§

impl<T, S> Clone for UnwindContext<T, S>

source§

fn clone(&self) -> UnwindContext<T, S>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T, S> Debug for UnwindContext<T, S>

source§

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

Formats the value using the given formatter. Read more
source§

impl<T, S> Default for UnwindContext<T, S>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T, S> PartialEq for UnwindContext<T, S>

source§

fn eq(&self, other: &UnwindContext<T, S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, S> Eq for UnwindContext<T, S>
where T: ReaderOffset + Eq, S: UnwindContextStorage<T> + Eq, S::Stack: Eq,

source§

impl<T, S> StructuralPartialEq for UnwindContext<T, S>

Auto Trait Implementations§

§

impl<T, S> Freeze for UnwindContext<T, S>
where <<S as UnwindContextStorage<T>>::Stack as Sealed>::Storage: Freeze, T: Freeze,

§

impl<T, S> RefUnwindSafe for UnwindContext<T, S>

§

impl<T, S> Send for UnwindContext<T, S>
where <<S as UnwindContextStorage<T>>::Stack as Sealed>::Storage: Send, T: Send,

§

impl<T, S> Sync for UnwindContext<T, S>
where <<S as UnwindContextStorage<T>>::Stack as Sealed>::Storage: Sync, T: Sync,

§

impl<T, S> Unpin for UnwindContext<T, S>
where <<S as UnwindContextStorage<T>>::Stack as Sealed>::Storage: Unpin, T: Unpin,

§

impl<T, S> UnwindSafe for UnwindContext<T, S>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

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

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

type Error = Infallible

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

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

Performs the conversion.
source§

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

source§

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

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

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

Performs the conversion.