Trait gimli::read::cfi::UnwindContextStorage
source · pub trait UnwindContextStorage<T: ReaderOffset>: Sized {
type Rules: ArrayLike<Item = (Register, RegisterRule<T>)>;
type Stack: ArrayLike<Item = UnwindTableRow<T, Self>>;
}
Expand description
Specification of what storage should be used for UnwindContext
.
Normally you would only need to use StoreOnHeap
, which places the stack
on the heap using Box
. This is the default storage type parameter for UnwindContext
.
You may want to supply your own storage type for one of the following reasons:
- In rare cases you may run into failed unwinds due to the fixed stack size
used by
StoreOnHeap
, so you may want to try a largerBox
. If denial of service is not a concern, then you could also try aVec
-based stack which can grow as needed. - You may want to avoid heap allocations entirely. You can use a fixed-size
stack with in-line arrays, which will place the entire storage in-line into
UnwindContext
.
Here’s an implementation which uses a fixed-size stack and allocates everything in-line,
which will cause UnwindContext
to be large:
struct StoreOnStack;
impl<T: ReaderOffset> UnwindContextStorage<T> for StoreOnStack {
type Rules = [(Register, RegisterRule<T>); 192];
type Stack = [UnwindTableRow<T, Self>; 4];
}
let mut ctx = UnwindContext::<_, StoreOnStack>::new_in();
// 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...
}
Required Associated Types§
sourcetype Rules: ArrayLike<Item = (Register, RegisterRule<T>)>
type Rules: ArrayLike<Item = (Register, RegisterRule<T>)>
The storage used for register rules in a unwind table row.
Note that this is nested within the stack.
sourcetype Stack: ArrayLike<Item = UnwindTableRow<T, Self>>
type Stack: ArrayLike<Item = UnwindTableRow<T, Self>>
The storage used for unwind table row stack.
Object Safety§
This trait is not object safe.