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
impl JitDebugger
Sourcepub fn new(config: DebuggerConfig) -> Self
pub fn new(config: DebuggerConfig) -> Self
Sourcepub fn debug_graph(
&mut self,
graph: ComputationGraph,
) -> JitResult<DebugSessionResult>
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);Sourcepub fn debug_ir(&mut self, ir_module: IrModule) -> JitResult<DebugSessionResult>
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)?;Sourcepub fn set_breakpoint(
&mut self,
location: BreakpointLocation,
) -> JitResult<BreakpointId>
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)?;Sourcepub fn remove_breakpoint(&mut self, id: BreakpointId) -> JitResult<()>
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)?;Sourcepub fn add_watch(&mut self, expression: String) -> JitResult<WatchId>
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())?;Sourcepub fn remove_watch(&mut self, id: WatchId) -> JitResult<()>
pub fn remove_watch(&mut self, id: WatchId) -> JitResult<()>
Sourcepub fn get_current_state(&self) -> Option<DebugState>
pub fn get_current_state(&self) -> Option<DebugState>
Sourcepub fn evaluate_expression(
&self,
expression: &str,
) -> JitResult<EvaluationResult>
pub fn evaluate_expression( &self, expression: &str, ) -> JitResult<EvaluationResult>
Sourcepub fn breakpoints(&self) -> &BreakpointManager
pub fn breakpoints(&self) -> &BreakpointManager
Get breakpoint manager
Sourcepub fn breakpoints_mut(&mut self) -> &mut BreakpointManager
pub fn breakpoints_mut(&mut self) -> &mut BreakpointManager
Get mutable breakpoint manager
Sourcepub fn watch_manager(&self) -> &WatchManager
pub fn watch_manager(&self) -> &WatchManager
Get watch manager
Sourcepub fn watch_manager_mut(&mut self) -> &mut WatchManager
pub fn watch_manager_mut(&mut self) -> &mut WatchManager
Get mutable watch manager
Sourcepub fn interface(&self) -> &DebuggerInterface
pub fn interface(&self) -> &DebuggerInterface
Get debugger interface
Sourcepub fn interface_mut(&mut self) -> &mut DebuggerInterface
pub fn interface_mut(&mut self) -> &mut DebuggerInterface
Get mutable debugger interface
Sourcepub fn execution_engine(&self) -> &DebugExecutionEngine
pub fn execution_engine(&self) -> &DebugExecutionEngine
Get execution engine
Sourcepub fn execution_engine_mut(&mut self) -> &mut DebugExecutionEngine
pub fn execution_engine_mut(&mut self) -> &mut DebugExecutionEngine
Get mutable execution engine
Sourcepub fn config(&self) -> &DebuggerConfig
pub fn config(&self) -> &DebuggerConfig
Get configuration
Sourcepub fn update_config(&mut self, config: DebuggerConfig)
pub fn update_config(&mut self, config: DebuggerConfig)
Update configuration
Sourcepub fn has_active_session(&self) -> bool
pub fn has_active_session(&self) -> bool
Check if there is an active debug session
Sourcepub fn clear_session(&mut self)
pub fn clear_session(&mut self)
Clear the current debug session
Sourcepub fn get_session_statistics(&self) -> Option<DebugStatistics>
pub fn get_session_statistics(&self) -> Option<DebugStatistics>
Get debug statistics from the current session
Auto Trait Implementations§
impl Freeze for JitDebugger
impl RefUnwindSafe for JitDebugger
impl Send for JitDebugger
impl Sync for JitDebugger
impl Unpin for JitDebugger
impl UnsafeUnpin for JitDebugger
impl UnwindSafe for JitDebugger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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