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