feat(dap): custom-request extension point for host debug requests#417
Merged
Conversation
dap.Server.dispatch was a closed command switch — unknown requests hit the default case and returned "not implemented", with no way for a hosting process to serve its own debug requests over the DAP connection. Add AttachConfig.CustomRequestHandler, invoked from dispatch's fallback path under the CPU lock so a handler reading live debuggee state observes a coherent (mid-instruction-free) snapshot: - handled=false -> standard "not implemented" error - handled=true, err!= -> error response carrying err - handled=true, err== -> success response with body as the JSON body Generic + protocol-neutral: hosts namespace their own commands. nessy uses this to expose NES PPU / OAM / mapper / APU debug state to the chippy TUI debugger panels (nessy#28) without forking the protocol. Closes #416
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.




What
Add
AttachConfig.CustomRequestHandler— an opt-in extension point letting a hosting process serve its own DAP request commands over the same connection.Why
dap.Server.dispatchis a closed switch; unknown commands return "not implemented" with no host override. nessy needs to expose NES-specific debug state (PPU nametables/CHR/palette, OAM, mapper + APU registers, per-dot events) to the chippy TUI debugger panels (nessy#28) without forking the protocol.How
AttachConfig.CustomRequestHandler func(command string, args json.RawMessage) (body any, handled bool, err error), copied throughAttachExisting.defaultcase under the CPU lock → coherent state reads.handled=falsedefers to the standard "not implemented" error;handled=true,err!=nil→ error response;handled=true,err==nil→ success response withbody.Tests
TestCustomRequestHandler(success+body, asserts the lock is held during the handler, handled-with-error, handled=false → not-implemented) andTestCustomRequestHandler_NilDefersToNotImplemented. Full./dap/suite + vet + golangci-lint green.Closes #416