Skip to content

feat(dap): custom-request extension point for host debug requests#417

Merged
nkane merged 1 commit into
mainfrom
feat/dap-custom-request
Jun 4, 2026
Merged

feat(dap): custom-request extension point for host debug requests#417
nkane merged 1 commit into
mainfrom
feat/dap-custom-request

Conversation

@nkane
Copy link
Copy Markdown
Owner

@nkane nkane commented Jun 4, 2026

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.dispatch is 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

  • New AttachConfig.CustomRequestHandler func(command string, args json.RawMessage) (body any, handled bool, err error), copied through AttachExisting.
  • Invoked from dispatch's default case under the CPU lock → coherent state reads.
  • handled=false defers to the standard "not implemented" error; handled=true,err!=nil → error response; handled=true,err==nil → success response with body.

Tests

TestCustomRequestHandler (success+body, asserts the lock is held during the handler, handled-with-error, handled=false → not-implemented) and TestCustomRequestHandler_NilDefersToNotImplemented. Full ./dap/ suite + vet + golangci-lint green.

Closes #416

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
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

TUI smoke renders

Rendered from 8678d9c by the smoke CI job. Replaced on every push to this PR.

chippy-source-scroll (#227)

chippy-source-scroll

chippy-syms (#226)

chippy-syms

chippy-bp-and-run (#225)

chippy-bp-and-run

chippy-console (#232)

chippy-console

@nkane nkane merged commit fae99a3 into main Jun 4, 2026
13 checks passed
@nkane nkane deleted the feat/dap-custom-request branch June 4, 2026 14:01
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.

dap: custom-request extension point for host-specific debug requests

1 participant