Skip to main content

PrintDebugger

Struct PrintDebugger 

Source
pub struct PrintDebugger {
    pub source_map: SourceMap<String>,
    pub stack: bool,
    pub stack_bytes: bool,
    pub visit_stack: bool,
    pub registers: bool,
    pub registers_bytes: bool,
    pub visit_registers: bool,
    pub operation_details: bool,
    pub step_through: bool,
    pub mode: PrintDebuggerMode,
    /* private fields */
}
Expand description

A debugger that prints every step to standard output.

Everything is off by default, so a bare PrintDebugger only announces the scopes and operations it passes. Turn the parts you want on with the builder methods, or start from PrintDebugger::full.

A value on the stack or in a register is only printed as a value when its type was registered with PrintDebugger::printable or one of its siblings. Anything else is printed as raw bytes.

Fields§

§source_map: SourceMap<String>

Names the printed places after the original source.

§stack: bool

Print how many bytes the stack holds.

§stack_bytes: bool

Print the raw bytes of the stack.

§visit_stack: bool

Print each value on the stack, one by one.

§registers: bool

Print the register count and the scope barriers.

§registers_bytes: bool

Print the raw bytes of the register storage.

§visit_registers: bool

Print each register, one by one.

§operation_details: bool

Print the whole operation rather than only its name.

§step_through: bool

Wait for a line on standard input after every printout.

§mode: PrintDebuggerMode

When to print around an operation or a scope.

Implementations§

Source§

impl PrintDebugger

Source

pub fn full() -> PrintDebugger

A debugger with everything turned on, step_through included.

Source

pub fn stack(self, mode: bool) -> PrintDebugger

Sets PrintDebugger::stack, builder style.

Source

pub fn stack_bytes(self, mode: bool) -> PrintDebugger

Sets PrintDebugger::stack_bytes, builder style.

Source

pub fn visit_stack(self, mode: bool) -> PrintDebugger

Sets PrintDebugger::visit_stack, builder style.

Source

pub fn registers(self, mode: bool) -> PrintDebugger

Sets PrintDebugger::registers, builder style.

Source

pub fn registers_bytes(self, mode: bool) -> PrintDebugger

Sets PrintDebugger::registers_bytes, builder style.

Source

pub fn visit_registers(self, mode: bool) -> PrintDebugger

Sets PrintDebugger::visit_registers, builder style.

Source

pub fn operation_details(self, mode: bool) -> PrintDebugger

Sets PrintDebugger::operation_details, builder style.

Source

pub fn step_through(self, mode: bool) -> PrintDebugger

Sets PrintDebugger::step_through, builder style.

With it on, every printout waits for a line on standard input, so the script only moves when you press enter.

Source

pub fn mode(self, mode: PrintDebuggerMode) -> PrintDebugger

Sets PrintDebugger::mode, builder style.

Source

pub fn printable<T>(self) -> PrintDebugger
where T: Debug + 'static,

Prints values of type T with their Debug output.

Source

pub fn printable_custom<T>( self, f: impl Fn(&PrintDebugger, &T) -> String + Send + Sync + 'static, ) -> PrintDebugger
where T: 'static,

Prints values of type T with a function of your own.

Source

pub fn printable_raw<T>( self, f: impl Fn(&PrintDebugger, *const ()) -> String + Send + Sync + 'static, ) -> PrintDebugger
where T: 'static,

PrintDebugger::printable_custom with the value as a raw pointer.

For a type that cannot be named as a Rust reference here. The pointer given to f holds a value of T.

Source

pub fn basic_printables(self) -> PrintDebugger

Registers the Rust primitives, char and String as printable.

Source

pub fn display<T>(&self, data: &T) -> Option<(&'static str, String)>

Formats data with what was registered for its type.

Returns the type name and the text, or None when the type was never registered as printable.

Source

pub fn display_raw( &self, type_hash: TypeHash, pointer: *const (), ) -> Option<(&'static str, String)>

PrintDebugger::display for a value whose type is only known at runtime.

pointer must hold a value of the type named by type_hash, which is what the caller has to get right.

Trait Implementations§

Source§

impl Default for PrintDebugger

Source§

fn default() -> PrintDebugger

Returns the “default value” for a type. Read more
Source§

impl<SE> VmDebugger<SE> for PrintDebugger
where SE: ScriptExpression + Debug,

Source§

fn on_enter_scope( &mut self, scope: &VmScope<'_, SE>, context: &mut Context, _: &Registry, )

Called once before the first operation of a scope.
Source§

fn on_exit_scope( &mut self, scope: &VmScope<'_, SE>, context: &mut Context, _: &Registry, )

Called when a step leaves the scope with nothing more to run, which is after its last operation or when an operation ends it early.
Source§

fn on_enter_operation( &mut self, scope: &VmScope<'_, SE>, operation: &ScriptOperation<'_, SE>, position: usize, context: &mut Context, _: &Registry, )

Called before each operation, with its index in the scope.
Source§

fn on_exit_operation( &mut self, scope: &VmScope<'_, SE>, operation: &ScriptOperation<'_, SE>, position: usize, context: &mut Context, _: &Registry, )

Called after each operation, with the index it ran at.
Source§

fn into_handle(self) -> Arc<RwLock<dyn VmDebugger<SE> + Send + Sync>>
where Self: Sized + Send + Sync + 'static,

Wraps this debugger in a shared handle a scope can take.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Finalize for T

Source§

unsafe fn finalize_raw(data: *mut ())

Drops the value stored at data in place. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Initialize for T
where T: Default,

Source§

fn initialize() -> T

Returns the initial value of this type.
Source§

unsafe fn initialize_raw(data: *mut ())

Writes the initial value into already allocated memory. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.