miden_core/operations/decorators/debug.rs
1use core::fmt;
2
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6// DEBUG OPTIONS
7// ================================================================================================
8
9/// Options of the `Debug` decorator.
10///
11/// These options define the debug info which gets printed out when the Debug decorator is
12/// executed.
13#[derive(Copy, Clone, Debug, Eq, PartialEq)]
14#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
15pub enum DebugOptions {
16 /// Print out the entire contents of the stack for the current execution context.
17 StackAll,
18 /// Prints out the top n items of the stack for the current context.
19 StackTop(u8),
20 /// Prints out the entire contents of RAM.
21 MemAll,
22 /// Prints out the contents of memory stored in the provided interval. Interval boundaries are
23 /// both inclusive.
24 ///
25 /// First parameter specifies the interval starting address, second -- the ending address.
26 MemInterval(u32, u32),
27 /// Prints out locals stored in the provided interval of the currently executing procedure.
28 /// Interval boundaries are both inclusive.
29 ///
30 /// First parameter specifies the starting address, second -- the ending address, and the third
31 /// specifies the overall number of locals.
32 LocalInterval(u16, u16, u16),
33 /// Prints out the top n items of the advice stack for the current context.
34 AdvStackTop(u16),
35}
36
37impl crate::prettier::PrettyPrint for DebugOptions {
38 fn render(&self) -> crate::prettier::Document {
39 crate::prettier::display(self)
40 }
41}
42
43impl fmt::Display for DebugOptions {
44 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45 match self {
46 Self::StackAll => write!(f, "stack"),
47 Self::StackTop(n) => write!(f, "stack.{n}"),
48 Self::MemAll => write!(f, "mem"),
49 Self::MemInterval(n, m) => write!(f, "mem.{n}.{m}"),
50 Self::LocalInterval(start, end, _) => {
51 write!(f, "local.{start}.{end}")
52 },
53 Self::AdvStackTop(n) => write!(f, "adv_stack.{n}"),
54 }
55 }
56}