midenc_codegen_masm/emulator/
debug.rs1use std::fmt;
2
3use midenc_hir::{Felt, FunctionIdent, OperandStack};
4
5use super::{Addr, InstructionPointer, InstructionWithOp};
6
7pub struct CallFrame {
9 pub function: FunctionIdent,
10 pub fp: Addr,
11 pub ip: Option<InstructionPointer>,
12}
13
14pub struct DebugInfo<'a> {
16 pub cycle: usize,
18 pub function: FunctionIdent,
20 pub fp: Addr,
22 pub ip: Option<InstructionWithOp>,
24 pub stack: &'a OperandStack<Felt>,
26}
27impl DebugInfo<'_> {
28 pub fn to_owned(self) -> DebugInfoWithStack {
29 let stack = self.stack.clone();
30 DebugInfoWithStack {
31 cycle: self.cycle,
32 function: self.function,
33 fp: self.fp,
34 ip: self.ip,
35 stack,
36 }
37 }
38}
39impl<'a> fmt::Debug for DebugInfo<'a> {
40 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
41 use midenc_hir::Stack;
42
43 f.debug_struct("DebugInfo")
44 .field("cycle", &self.cycle)
45 .field("function", &self.function)
46 .field("fp", &self.fp)
47 .field("ip", &self.ip)
48 .field("stack", &self.stack.debug())
49 .finish()
50 }
51}
52
53pub struct DebugInfoWithStack {
55 pub cycle: usize,
57 pub function: FunctionIdent,
59 pub fp: Addr,
61 pub ip: Option<InstructionWithOp>,
63 pub stack: OperandStack<Felt>,
65}
66impl fmt::Debug for DebugInfoWithStack {
67 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
68 use midenc_hir::Stack;
69
70 f.debug_struct("DebugInfo")
71 .field("cycle", &self.cycle)
72 .field("function", &self.function)
73 .field("fp", &self.fp)
74 .field("ip", &self.ip)
75 .field("stack", &self.stack.debug())
76 .finish()
77 }
78}