Documentation
¶
Overview ¶
Package debug provides a breakpoint/stepping debugger engine for the Gad VM.
An Engine implements gad.DebugStepper: attach it with vm.SetDebugger(engine) and run the VM in its own goroutine. The engine pauses execution at breakpoints and step boundaries, publishing StopEvents on Stops(); a controller (a DAP server, a CLI or the web UI) consumes those events, inspects state via the engine's accessors, and resumes with Continue / StepInto / StepOver / StepOut.
The engine drives the generated debug loop (vm_loop_debug.go); the production VM loop is unaffected.
Index ¶
- type Breakpoint
- type Engine
- func (e *Engine) Continue()
- func (e *Engine) EvalInFrame(expr string, repr bool) (string, error)
- func (e *Engine) EvalObject(expr string) (gad.Object, error)
- func (e *Engine) Frames() []Frame
- func (e *Engine) Locals() []Variable
- func (e *Engine) Pause()
- func (e *Engine) SetBreakpoints(lines []int) []int
- func (e *Engine) SetConditionalBreakpoints(bps []Breakpoint)
- func (e *Engine) Step(vm *gad.VM)
- func (e *Engine) StepInto()
- func (e *Engine) StepOut()
- func (e *Engine) StepOver()
- func (e *Engine) Stops() <-chan StopEvent
- type Frame
- type StopEvent
- type StopReason
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Breakpoint ¶
Breakpoint describes a source breakpoint. Disabled breakpoints never pause; a non-empty Condition pauses only when the expression evaluates truthy (`!value.IsFalsy()`) in the current frame's scope.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is a gad.DebugStepper implementing breakpoints and stepping.
func New ¶
New creates an Engine. When stopOnEntry is true, execution pauses before the first instruction.
func (*Engine) Continue ¶
func (e *Engine) Continue()
Continue resumes until the next breakpoint or pause.
func (*Engine) EvalInFrame ¶
EvalInFrame evaluates expr against the paused frame's locals and returns the result rendered with str() (or repr() when repr is set). It is valid only while the engine is parked at a stop; otherwise it returns an error.
func (*Engine) EvalObject ¶
EvalObject evaluates expr against the paused frame's locals and returns the resulting object (for the tree navigator / inspection). Valid only while parked at a stop.
func (*Engine) SetBreakpoints ¶
SetBreakpoints replaces the breakpoint set with plain (enabled, unconditional) breakpoints on the given source lines and returns the accepted lines (all, here — lines are not validated against the source map).
func (*Engine) SetConditionalBreakpoints ¶
func (e *Engine) SetConditionalBreakpoints(bps []Breakpoint)
SetConditionalBreakpoints replaces the breakpoint set with the given breakpoints (each may carry a Disabled flag and a Condition expression).
func (*Engine) Step ¶
Step implements gad.DebugStepper. It is called before each instruction in the debug loop and blocks while the VM is paused.
func (*Engine) StepInto ¶
func (e *Engine) StepInto()
StepInto resumes until the next source line (entering calls).
func (*Engine) StepOut ¶
func (e *Engine) StepOut()
StepOut resumes until control returns to a shallower frame.
type Frame ¶
type Frame struct {
FuncName string
File string
Line int
Column int
// Locals holds this frame's local variables.
Locals []Variable
}
Frame is a snapshot of a call frame for the stack view.
type StopEvent ¶
type StopEvent struct {
Reason StopReason
File string
Line int
Column int
}
StopEvent is published when execution pauses.
type StopReason ¶
type StopReason string
StopReason explains why execution paused.
const ( StopEntry StopReason = "entry" StopBreakpoint StopReason = "breakpoint" StopStep StopReason = "step" StopPause StopReason = "pause" )