Skip to main content

JitDebugger

Struct JitDebugger 

Source
pub struct JitDebugger { /* private fields */ }
Expand description

Interactive JIT debugger

The main orchestrator that coordinates all debugging components to provide a comprehensive debugging experience for JIT-compiled code.

§Features

  • Step-by-step execution: Execute code one instruction/node at a time
  • Breakpoint management: Set conditional and unconditional breakpoints
  • Watch expressions: Monitor variable and expression values
  • State inspection: Examine variables, memory, and call stack
  • Performance profiling: Track execution timing and statistics
  • Interactive interface: Command-line interface with rich formatting

§Examples

§Basic Usage

use torsh_jit::debugger::{JitDebugger, DebuggerConfig};
use torsh_jit::ComputationGraph;

let mut debugger = JitDebugger::new(DebuggerConfig::default());
let graph = ComputationGraph::new();
// let result = debugger.debug_graph(graph)?;

§Advanced Configuration

use torsh_jit::debugger::{JitDebugger, DebuggerConfig, UiMode};

let config = DebuggerConfig {
    enable_single_step: true,
    enable_breakpoints: true,
    enable_watches: true,
    enable_memory_view: true,
    enable_disassembly: true,
    max_trace_length: 10000,
    ui_mode: UiMode::Interactive,
};

let mut debugger = JitDebugger::new(config);

Implementations§

Source§

impl JitDebugger

Source

pub fn new(config: DebuggerConfig) -> Self

Create a new JIT debugger

§Arguments
  • config - Configuration for the debugger
§Examples
use torsh_jit::debugger::{JitDebugger, DebuggerConfig};

let debugger = JitDebugger::new(DebuggerConfig::default());
Source

pub fn debug_graph( &mut self, graph: ComputationGraph, ) -> JitResult<DebugSessionResult>

Start a debugging session for a computation graph

This method starts an interactive debugging session that allows step-by-step execution through the computation graph with full debugging capabilities.

§Arguments
  • graph - The computation graph to debug
§Returns

A DebugSessionResult containing the execution trace, final state, command history, and statistics from the debugging session.

§Examples
use torsh_jit::debugger::{JitDebugger, DebuggerConfig};
use torsh_jit::ComputationGraph;

let mut debugger = JitDebugger::new(DebuggerConfig::default());
let graph = ComputationGraph::new();
// let result = debugger.debug_graph(graph)?;
// println!("Executed {} steps", result.execution_trace.len());
// println!("Final state: {:?}", result.final_state);
Source

pub fn debug_ir(&mut self, ir_module: IrModule) -> JitResult<DebugSessionResult>

Start a debugging session for an IR module

This method starts an interactive debugging session for IR (Intermediate Representation) code, allowing instruction-level debugging with full state inspection.

§Arguments
  • ir_module - The IR module to debug
§Returns

A DebugSessionResult containing the execution trace, final state, command history, and statistics from the debugging session.

§Examples
use torsh_jit::debugger::{JitDebugger, DebuggerConfig};
use torsh_jit::ir::IrModule;

let mut debugger = JitDebugger::new(DebuggerConfig::default());
let ir_module = IrModule::new("main".to_string());
// let result = debugger.debug_ir(ir_module)?;
Source

pub fn set_breakpoint( &mut self, location: BreakpointLocation, ) -> JitResult<BreakpointId>

Set a breakpoint at a specific location

§Arguments
  • location - The location where the breakpoint should be set
§Returns

The ID of the newly created breakpoint

§Examples
use torsh_jit::debugger::{JitDebugger, DebuggerConfig, BreakpointLocation};
use torsh_jit::NodeId;

let mut debugger = JitDebugger::new(DebuggerConfig::default());
let location = BreakpointLocation::GraphNode(NodeId::new(5));
let bp_id = debugger.set_breakpoint(location)?;
Source

pub fn remove_breakpoint(&mut self, id: BreakpointId) -> JitResult<()>

Remove a breakpoint

§Arguments
  • id - The ID of the breakpoint to remove
§Examples
use torsh_jit::debugger::{JitDebugger, DebuggerConfig, BreakpointLocation};
use torsh_jit::NodeId;

let mut debugger = JitDebugger::new(DebuggerConfig::default());
let location = BreakpointLocation::GraphNode(NodeId::new(0));
let bp_id = debugger.set_breakpoint(location)?;
debugger.remove_breakpoint(bp_id)?;
Source

pub fn add_watch(&mut self, expression: String) -> JitResult<WatchId>

Add a watch expression

§Arguments
  • expression - The expression to watch
§Returns

The ID of the newly created watch

§Examples
use torsh_jit::debugger::{JitDebugger, DebuggerConfig};

let mut debugger = JitDebugger::new(DebuggerConfig::default());
let watch_id = debugger.add_watch("variable_name".to_string())?;
Source

pub fn remove_watch(&mut self, id: WatchId) -> JitResult<()>

Remove a watch expression

§Arguments
  • id - The ID of the watch to remove
Source

pub fn get_current_state(&self) -> Option<DebugState>

Get current debugging state

§Returns

The current debug state if a session is active, None otherwise

Source

pub fn evaluate_expression( &self, expression: &str, ) -> JitResult<EvaluationResult>

Evaluate an expression in the current context

§Arguments
  • expression - The expression to evaluate
§Returns

The evaluation result

Source

pub fn breakpoints(&self) -> &BreakpointManager

Get breakpoint manager

Source

pub fn breakpoints_mut(&mut self) -> &mut BreakpointManager

Get mutable breakpoint manager

Source

pub fn watch_manager(&self) -> &WatchManager

Get watch manager

Source

pub fn watch_manager_mut(&mut self) -> &mut WatchManager

Get mutable watch manager

Source

pub fn interface(&self) -> &DebuggerInterface

Get debugger interface

Source

pub fn interface_mut(&mut self) -> &mut DebuggerInterface

Get mutable debugger interface

Source

pub fn execution_engine(&self) -> &DebugExecutionEngine

Get execution engine

Source

pub fn execution_engine_mut(&mut self) -> &mut DebugExecutionEngine

Get mutable execution engine

Source

pub fn config(&self) -> &DebuggerConfig

Get configuration

Source

pub fn update_config(&mut self, config: DebuggerConfig)

Update configuration

Source

pub fn has_active_session(&self) -> bool

Check if there is an active debug session

Source

pub fn clear_session(&mut self)

Clear the current debug session

Source

pub fn get_session_statistics(&self) -> Option<DebugStatistics>

Get debug statistics from the current session

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V