pub mod engine;
pub mod breakpoint;
pub mod stack_trace;
pub mod variable_scope;
pub mod config;
pub mod v8_stubs;
pub mod session;
pub mod cli;
pub mod watch;
pub mod enhanced;
use breakpoint::{Breakpoint, BreakpointCondition, BreakpointManager};
use engine::{DebugState, DebuggerEngine, SimpleEventListener};
use stack_trace::{StackFrame, StackFrameInfo, StackTrace};
use std::collections::{BTreeMap, HashMap};
use variable_scope::{ScopeType, VariableInspector, VariableScope};
use std::time::{Duration, Instant};
pub use enhanced::{
EnhancedDebugger,
ConditionalBreakpoint,
HitCountCondition,
ExceptionBreakpoint,
EnhancedStackFrame,
AsyncStackTrace,
ScopeInfo,
ScopeType as EnhancedScopeType,
VariableInfo as EnhancedVariableInfo,
DebuggerProfiler,
ProfileSample,
HotSpot,
SourceMap,
SourceMapManager,
MappingSegment,
OriginalLocation,
GeneratedLocation,
RemoteDebugConfig,
RemoteDebugSession,
DebugProtocol,
};
#[derive(Debug, Clone, PartialEq)]
pub enum DebugEvent {
BreakpointHit {
breakpoint_id: String,
location: SourceLocation,
},
Exception {
exception: String,
location: SourceLocation,
},
StepCompleted {
step_type: StepType,
location: SourceLocation,
},
ScriptCompiled {
script_id: String,
name: String,
},
ProgramStarted {
script_id: String,
},
ProgramEnded {
exit_code: i32,
},
}
#[derive(Debug, Clone, PartialEq)]
pub enum StepType {
Over, Into, Out, Next, }
#[derive(Debug, Clone, PartialEq)]
pub struct SourceLocation {
pub script_id: String,
pub script_name: String,
pub line_number: u32,
pub column_number: u32,
}
#[derive(Debug, Clone)]
pub struct DebugResult<T> {
pub success: bool,
pub data: Option<T>,
pub error: Option<String>,
}
impl<T> DebugResult<T> {
pub fn ok(data: T) -> Self {
Self {
success: true,
data: Some(data),
error: None,
}
}
pub fn err(error: String) -> Self {
Self {
success: false,
data: None,
error: Some(error),
}
}
pub fn unwrap(self) -> T {
if self.success {
self.data.expect("DebugResult unwrap called on successful result but data is None")
} else {
panic!("DebugResult unwrap failed: {}", self.error.unwrap_or_else(|| "Unknown error".to_string()))
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum DebugCommand {
Continue,
StepOver,
StepInto,
StepOut,
Next,
Evaluate(String),
SetBreakpoint {
script_id: String,
line_number: u32,
condition: Option<String>,
},
RemoveBreakpoint(String),
ListBreakpoints,
PrintVariable(String),
ListVariables,
Backtrace,
Quit,
}
#[derive(Debug, Clone)]
pub struct DebugStats {
pub breakpoints_set: u64,
pub breakpoints_hit: u64,
pub steps_executed: u64,
pub exceptions_caught: u64,
pub variables_inspected: u64,
pub watches_added: u64,
pub start_time: std::time::Instant,
}
impl Default for DebugStats {
fn default() -> Self {
Self {
breakpoints_set: 0,
breakpoints_hit: 0,
steps_executed: 0,
exceptions_caught: 0,
variables_inspected: 0,
watches_added: 0,
start_time: std::time::Instant::now(),
}
}
}
impl DebugStats {
pub fn new() -> Self {
Self::default()
}
pub fn elapsed(&self) -> std::time::Duration {
self.start_time.elapsed()
}
}
pub fn init() {
}