Skip to main content

FrameHandle

Struct FrameHandle 

Source
pub struct FrameHandle { /* private fields */ }
Available on crate feature debug only.
Expand description

A handle to a stack frame, valid as long as execution is not resumed in the associated Store.

This handle can be held and cloned and used to refer to a frame within a paused store. It is cheap: it internally consists of a pointer to the actual frame, together with some metadata to determine when that pointer has gone stale.

At the API level, any usage of this frame handle requires a mutable borrow of the Store, because the Store logically owns the stack(s) for any execution within it. However, the existence of the handle itself does not hold a borrow on the Store; hence, the Store can continue to be used and queried, and some state (e.g. memories, tables, GC objects) can even be mutated, as long as execution is not resumed. The intent of this API is to allow a wide variety of debugger implementation strategies that expose stack frames and also allow other commands/actions at the same time.

The user can use FrameHandle::is_valid to determine if the handle is still valid and usable.

Implementations§

Source§

impl FrameHandle

Source

pub fn is_valid(&self, store: impl AsContextMut) -> bool

Available on crate feature runtime only.

Determine whether this handle can still be used to refer to a frame.

Source

pub fn parent(&self, store: impl AsContextMut) -> Result<Option<FrameHandle>>

Available on crate feature runtime only.

Get a handle to the next frame up the activation (the one that called this frame), if any.

Source

pub fn instance(&self, store: impl AsContextMut) -> Result<Instance>

Available on crate feature runtime only.

Get the instance associated with the current frame.

Source

pub fn module<'a, T: 'static>( &self, store: impl Into<StoreContextMut<'a, T>>, ) -> Result<Option<&'a Module>>

Available on crate feature runtime only.

Get the module associated with the current frame, if any (i.e., not a container instance for a host-created entity).

Source

pub fn wasm_function_index_and_pc( &self, store: impl AsContextMut, ) -> Result<Option<(DefinedFuncIndex, u32)>>

Available on crate feature runtime only.

Get the raw function index associated with the current frame, and the PC as an offset within its code section, if it is a Wasm function directly from the given Module (rather than a trampoline).

Source

pub fn num_locals(&self, store: impl AsContextMut) -> Result<u32>

Available on crate feature runtime only.

Get the number of locals in this frame.

Source

pub fn num_stacks(&self, store: impl AsContextMut) -> Result<u32>

Available on crate feature runtime only.

Get the depth of the operand stack in this frame.

Source

pub fn local(&self, store: impl AsContextMut, index: u32) -> Result<Val>

Available on crate feature runtime only.

Get the type and value of the given local in this frame.

§Panics

Panics if the index is out-of-range (greater than num_locals()).

Source

pub fn stack(&self, store: impl AsContextMut, index: u32) -> Result<Val>

Available on crate feature runtime only.

Get the type and value of the given operand-stack value in this frame.

Index 0 corresponds to the bottom-of-stack, and higher indices from there are more recently pushed values. In other words, index order reads the Wasm virtual machine’s abstract stack state left-to-right.

Trait Implementations§

Source§

impl Clone for FrameHandle

Available on crate feature runtime only.
Source§

fn clone(&self) -> FrameHandle

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.