mirror of
https://github.com/bearlanguageorg/bear.git
synced 2026-08-26 15:37:18 +00:00
Debugger
This commit is contained in:
+32
@@ -34,6 +34,30 @@ struct Handler {
|
||||
sp int // stack pointer right after the handler record
|
||||
}
|
||||
|
||||
// DbgMode says what the debugger should do after an interactive session ends.
|
||||
enum DbgMode {
|
||||
run // keep going until the next breakpoint (or the end)
|
||||
step // stop at the very next instruction
|
||||
next // stop after the current line returns to this frame level
|
||||
finish // stop when the current function returns
|
||||
}
|
||||
|
||||
// DbgState is the interactive debugger's runtime state, checked once per
|
||||
// instruction while enabled.
|
||||
struct DbgState {
|
||||
mut:
|
||||
enabled bool
|
||||
breakpoints []int // source lines to stop at (first instruction of the line)
|
||||
mode DbgMode
|
||||
start_bp int // frame base captured when next/finish began
|
||||
last_line int // line at the moment the session stopped
|
||||
}
|
||||
|
||||
struct FnEntry {
|
||||
idx int
|
||||
entry int
|
||||
}
|
||||
|
||||
struct Vm {
|
||||
mut:
|
||||
code []u8
|
||||
@@ -57,6 +81,14 @@ mut:
|
||||
const_strs int // strings[0..const_strs] are bytecode constants, never collected
|
||||
last_heap int // heap size at the last GC check (allocation trigger)
|
||||
build_root string // directory of the .vrmm build module (build_root() builtin)
|
||||
dbg DbgState // interactive debugger state (vr debug)
|
||||
dbg_locals []obj.DbgLocal // local name -> slot per function (debugger)
|
||||
profiling bool // instruction/call counting (vr run --profile)
|
||||
prof_instr []u64 // instructions executed per function index
|
||||
prof_calls []u64 // calls made per function index
|
||||
fn_of_ip []int // code offset -> function index (for profiling)
|
||||
max_ops i64 // instruction budget; 0 = unlimited (fuzzing safety)
|
||||
ops i64 // instructions executed so far
|
||||
}
|
||||
|
||||
fn bool_i64(b bool) i64 {
|
||||
|
||||
Reference in New Issue
Block a user