Skip to main content

TraceHandler

Trait TraceHandler 

Source
pub trait TraceHandler:
    Send
    + Sync
    + 'static {
    // Required method
    fn on_trace(&self, process: &ProcessorState<'_>) -> Result<(), TraceError>;
}
Expand description

Handles an optional, read-only trace event emitted by the VM.

Assembly programs emit trace events with trace, trace.CONST, or trace.event("..."). When the handler runs, SystemEvent::TraceEvent is at stack position 0 and the user trace event ID is at position 1. The handler receives a read-only ProcessorState and cannot return advice mutations.

The instruction expansions are:

  • trace expands to push.<sys::trace_event> emit drop.
  • trace.CONST and trace.event("...") expand to push.<trace_id> push.<sys::trace_event> emit drop drop.

Required Methods§

Source

fn on_trace(&self, process: &ProcessorState<'_>) -> Result<(), TraceError>

Handles the trace event when triggered.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F> TraceHandler for F
where F: for<'a> Fn(&'a ProcessorState<'_>) -> Result<(), TraceError> + Send + Sync + 'static,

Default implementation for both free functions and closures with signature fn(&ProcessorState) -> Result<(), TraceError>