Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.goandvm_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 separatedebugger/submodule to keep thego-dapdependency 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.goemit debug variable maps whendebugModeis set,runtime.goadds the attach/detach API andCompileForDebug, andvm.godispatches 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 indebugger/server_test.go.Note: The
debugger/go.modcurrently has areplace github.com/dop251/goja => ../directive so it compiles against the local parent module during development. Once this PR is merged, thatreplaceshould be removed and thegithub.com/dop251/gojadependency updated to point at the merged commit (or a tagged release).