vihaco_stdlib/debugger/
loadable.rs1use super::{DebugAction, Debugger, DebuggerState, HasBreakpointInstruction, IsBreakpointToggled};
5use crate::{ExecutionState, Image, Loadable};
6use vihaco_module::module::LocalModule;
7use vihaco_runtime::{Composite, Dispatch, Field, HasProgram};
8
9impl<Inst, V, Ty, Info, M> Loadable<Image<Inst, V, Ty, Info>, M>
10where
11 M: Composite + HasProgram<Program = ExecutionState<DebuggerState>>,
12{
13 pub fn set_breakpoint<F>(&mut self, pc: u32) -> IsBreakpointToggled
15 where
16 M: Field<F, Child = Debugger<u32, Inst>>,
17 Inst: HasBreakpointInstruction,
18 {
19 let (image, machine) = self.breakpoint_parts_mut();
20 <M as Field<F>>::get_mut(machine).set_breakpoint(&mut image.module, pc)
21 }
22
23 pub fn clear_breakpoint<F>(&mut self, pc: u32) -> IsBreakpointToggled
25 where
26 M: Field<F, Child = Debugger<u32, Inst>>,
27 Inst: HasBreakpointInstruction,
28 {
29 let (image, machine) = self.breakpoint_parts_mut();
30 <M as Field<F>>::get_mut(machine).clear_breakpoint(&mut image.module, pc)
31 }
32
33 pub fn resume_with_breaks<F>(&mut self, action: DebugAction) -> eyre::Result<()>
35 where
36 M: Field<F, Child = Debugger<u32, Inst>>
37 + Dispatch<LocalModule<Inst, V, Ty, Info>, Instruction = Inst>,
38 Inst: Clone,
39 {
40 let (image, machine) = self.parts_mut();
41 super::resume_with_breaks::<F, _, _, _, _, _>(&image.module, machine, action)
42 }
43}