Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
Step vs. continue
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Jun 1, 2023
1 parent 16703c8 commit f998867
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions internal/debug/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

const replUsage = `Commands:
s, step -- Step through events
c, continue -- Continue execution until a breakpoint is reached or the module exits
r, restart -- Restart the debugger
q, quit -- Quit the debugger
h, help -- Show this usage information
Expand All @@ -26,10 +27,11 @@ var (

// REPL provides a read-eval-print loop for debugging WebAssembly modules.
type REPL struct {
input *bufio.Scanner
tracer *Tracer
writer io.Writer
closed bool
input *bufio.Scanner
tracer *Tracer
writer io.Writer
stepping bool
closed bool
}

// NewREPL creates a new REPL using the specified input and writer stream.
Expand All @@ -48,18 +50,13 @@ func (r *REPL) OnEvent(ctx context.Context, event Event) {

r.tracer.OnEvent(ctx, event)

// TODO: support breakpoints
executing := true
switch event.(type) {
case *ModuleBeforeEvent:
case *ModuleAfterEvent:
case *FunctionCallBeforeEvent:
return
case *FunctionCallAfterEvent:
return
case *FunctionCallAbortEvent:
return
case *SystemCallBeforeEvent:
return
case *SystemCallAfterEvent:
case *ModuleBeforeEvent, *ModuleAfterEvent:
executing = false
}
if executing && !r.stepping {
return
}

Expand All @@ -76,15 +73,17 @@ read_input:

switch command {
case "s", "step":
// TODO
r.stepping = true

case "c", "continue":
r.stepping = false

case "r", "restart":
r.print("Restarting the debugger\n")
r.print("Restarting...\n")
r.closed = true
panic(RestartError)

case "q", "quit":
r.print("Quitting the debugger\n")
r.closed = true
panic(QuitError)

Expand Down

0 comments on commit f998867

Please sign in to comment.