pub struct Loadable<I, M: Composite> { /* private fields */ }Expand description
A program image and the composite that executes its borrowed instructions.
Construct the image explicitly before pairing it with a machine. Only
Image is supported; the image remains unchanged throughout an invocation.
Ordinary outer structs can own several loadables with different instruction
sets. Section selection and image construction remain caller responsibilities.
Implementations§
Source§impl<Inst, V, Ty, Info, M> Loadable<Image<Inst, V, Ty, Info>, M>
impl<Inst, V, Ty, Info, M> Loadable<Image<Inst, V, Ty, Info>, M>
Sourcepub fn set_breakpoint<F>(&mut self, pc: u32) -> IsBreakpointToggled
pub fn set_breakpoint<F>(&mut self, pc: u32) -> IsBreakpointToggled
Install a gutter breakpoint in the owned image.
Sourcepub fn clear_breakpoint<F>(&mut self, pc: u32) -> IsBreakpointToggled
pub fn clear_breakpoint<F>(&mut self, pc: u32) -> IsBreakpointToggled
Restore a gutter breakpoint’s instruction in the owned image.
Sourcepub fn resume_with_breaks<F>(&mut self, action: DebugAction) -> Result<()>
pub fn resume_with_breaks<F>(&mut self, action: DebugAction) -> Result<()>
Continue or single-step an invocation through the selected debugger.
Source§impl<Inst, V, Ty, Info, M: Composite> Loadable<Image<Inst, V, Ty, Info>, M>
impl<Inst, V, Ty, Info, M: Composite> Loadable<Image<Inst, V, Ty, Info>, M>
Sourcepub fn image(&self) -> &Image<Inst, V, Ty, Info>
pub fn image(&self) -> &Image<Inst, V, Ty, Info>
Inspect the paired image without changing an invocation’s program data.
Sourcepub fn machine_mut(&mut self) -> &mut M
pub fn machine_mut(&mut self) -> &mut M
Configure the execution machine or its devices.
Direct changes to execution state can affect whether an invocation can resume. The caller is responsible for keeping those changes consistent with the paired image.
Sourcepub fn parts_mut(&mut self) -> (&Image<Inst, V, Ty, Info>, &mut M)
pub fn parts_mut(&mut self) -> (&Image<Inst, V, Ty, Info>, &mut M)
Borrow the image and mutably borrow the machine for custom runners.
Within execution_state::run, pass &image.module and the machine
to execution_state::execute_instruction to drive a step. Keep any
direct changes to invocation state consistent with the paired image.
Sourcepub fn into_parts(self) -> (Image<Inst, V, Ty, Info>, M)
pub fn into_parts(self) -> (Image<Inst, V, Ty, Info>, M)
Consume the owner, returning its image and machine without resetting them.
Source§impl<Inst, V, Ty, Info, M, S> Loadable<Image<Inst, V, Ty, Info>, M>
impl<Inst, V, Ty, Info, M, S> Loadable<Image<Inst, V, Ty, Info>, M>
Sourcepub fn new(image: Image<Inst, V, Ty, Info>, machine: M) -> Self
pub fn new(image: Image<Inst, V, Ty, Info>, machine: M) -> Self
Pair an image with a machine, resetting its previous invocation state.
Device state is retained. No parsing, lowering, or image validation is performed here; construction of a valid image is the caller’s job.
When reusing a machine with a different image, call
Debugger::forget_breakpoints
on each debugger before using it with the new image. Saved instructions
belong to the discarded image; retaining them can overwrite new code
when a breakpoint is cleared. To keep the old image usable, restore its
instructions with Debugger::clear_all
before separating it from the machine instead.
Sourcepub fn replace_image(&mut self, image: Image<Inst, V, Ty, Info>) -> Result<()>
pub fn replace_image(&mut self, image: Image<Inst, V, Ty, Info>) -> Result<()>
Install an already constructed image and reset execution state.
Device state is retained. Image construction happens before this call; mutations made by the caller while constructing it are not rolled back.
After replacement succeeds, call
Debugger::forget_breakpoints
on each debugger before using it again. This discards instructions saved
from the old image, which must never be restored into the replacement.
Do not forget them before this call: if replacement is rejected, the old
image still needs those instructions to clear or resume its breakpoints.
Invocation-only Self::reset calls retain the image and its breakpoints.
See the debugger Cargo example for the replacement and reuse sequence.
§Errors
Rejects replacement while an invocation is active, including one that
could resume after an execution error. Call Self::reset to abandon
that invocation first. Rejection leaves the current image and execution
state unchanged.
Source§impl<Inst, V, Ty, Info, M, S> Loadable<Image<Inst, V, Ty, Info>, M>where
M: HasProgram<Program = ExecutionState<S>> + Dispatch<LocalModule<Inst, V, Ty, Info>, Instruction = Inst>,
impl<Inst, V, Ty, Info, M, S> Loadable<Image<Inst, V, Ty, Info>, M>where
M: HasProgram<Program = ExecutionState<S>> + Dispatch<LocalModule<Inst, V, Ty, Info>, Instruction = Inst>,
Sourcepub fn execute(&mut self, arguments: &[Word]) -> Result<()>
pub fn execute(&mut self, arguments: &[Word]) -> Result<()>
Start at the program entrypoint with the supplied arguments.
Instructions and metadata borrow the image while dispatch mutates the separate machine. No instruction cloning is required.
§Errors
Returns the runner’s entry or execution errors. Earlier machine mutations are retained; reset or resume according to the invocation’s state.
Sourcepub fn resume(&mut self) -> Result<()>
pub fn resume(&mut self) -> Result<()>
Continue the existing invocation against the same paired image.
§Errors
Returns the runner’s state, instruction-fetch, or dispatch errors without
rolling back machine mutations. A halted invocation remains halted.
A suspended invocation also remains suspended; use
Self::resume_with_breaks to continue from a debugger breakpoint.