Skip to content

Add debugger support (DAP)#702

Open
TristanSpeakEasy wants to merge 5 commits intodop251:masterfrom
speakeasy-api:feat/debugger
Open

Add debugger support (DAP)#702
TristanSpeakEasy wants to merge 5 commits intodop251:masterfrom
speakeasy-api:feat/debugger

Conversation

@TristanSpeakEasy
Copy link

@TristanSpeakEasy TristanSpeakEasy commented Feb 25, 2026

This adds debugger support to goja using the Debug Adapter Protocol (DAP), so you can step-debug JavaScript/TypeScript running in goja from VS Code.

The core API lives in debugger.go and vm_debug.go — breakpoints (line, conditional, hit count, log points), stepping, pause, variable inspection, eval while paused, exception breakpoints, and source map support. The DAP server is in a separate debugger/ submodule to keep the go-dap dependency out of the main module.

When no debugger is attached there's zero overhead — everything is gated behind vm.dbg != nil.

The changes to existing files are kept minimal: compiler.go/compiler_expr.go/compiler_stmt.go emit debug variable maps when debugMode is set, runtime.go adds the attach/detach API and CompileForDebug, and vm.go dispatches to the debug-aware execution loop and hooks into save/restore context for frame tracking.

A VS Code extension is included in debugger/vscode-goja-debugger/ with a pre-built .vsix.

Tests: 33 tests for the core debug API in debugger_test.go, 17 DAP integration tests in debugger/server_test.go.

Note: The debugger/go.mod currently has a replace github.com/dop251/goja => ../ directive so it compiles against the local parent module during development. Once this PR is merged, that replace should be removed and the github.com/dop251/goja dependency updated to point at the merged commit (or a tagged release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant