Skip to content

Let the VS Code launch bridge listen on a Unix socket - #45

Merged
yuuu merged 1 commit into
mainfrom
feature/dap-unix-socket
Oct 18, 2026
Merged

yuuu merged 1 commit into
mainfrom
feature/dap-unix-socket

Conversation

@yuuu

@yuuu yuuu commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Summary

launch.json no longer needs a debugPort. Without one, vscode-rdbg launches mrdbg --open with no --host/--port and attaches over a Unix domain socket, the same way it does with rdbg. mrdbg now supports that:

debugPort in launch.json vscode-rdbg passes mrdbg listens on
(none, the default off Windows) nothing a fresh socket: $XDG_RUNTIME_DIR/mrdbg-<pid>, else $TMPDIR, else /tmp
a path --sock-path=PATH that path
host:port --host=… --port=… TCP, as before
  • Options: on --open, --sock-path is the DAP side (dap_sock_path), like --host/--port. Adds --util.
  • CLI.launch_dap: picks TCP or a Unix socket, prints DEBUGGER: Debugger can attach via UNIX domain socket (PATH), and removes the socket file on exit.
  • --util=gen-sockpath: vscode-rdbg runs this first with useTerminal: true.
  • DapServer now takes an already-bound server (TCPServer or UNIXServer) from its caller.
  • README and CLAUDE.md updated: debugPort is optional now.

SIGPIPE fix

VS Code closes its end right after disconnect. The terminated event sent when the device then hits EOF raised SIGPIPE and killed the bridge before it could clean up. Over TCP this went unnoticed; with a Unix socket it left a stale socket file behind. DapServer now writes through Transport::Socket (MSG_NOSIGNAL) and ends the session once the client is gone.

Not covered

  • attach without a debugPort (vscode-rdbg's --util=list-socks lookup). The manual mrdbg --dap-port bridge is still TCP only.
  • An automatically chosen TCP port (--port=0, vscode-rdbg's default on Windows) is still rejected.

Testing

  • rake test:unit: 0 KO. New tests cover option parsing, gen_sock_path, --util, and failure reporting.
  • rake test:smoke: 0 failures.
  • An end-to-end script that mimics vscode-rdbg's console-mode launch, against mruby app.rb listening on TCP. It ran four cases: no debugPort, XDG_RUNTIME_DIR set, debugPort as a path, and TCP. Each went through initialize → entry stop → next → evaluate → disconnect, mrdbg exited 0, and no socket file was left behind.
  • Confirmed working from VS Code with a launch.json that has no debugPort.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CpfQQRdc3R13RafigfCNVk

Without a debugPort in launch.json, vscode-rdbg runs `mrdbg --open` with
no --host/--port and attaches over a Unix domain socket, as it does with
rdbg. mrdbg now listens on a fresh socket (XDG_RUNTIME_DIR, else TMPDIR,
else /tmp) in that case, or on the path a debugPort names (--sock-path),
removes it on exit, and supports --util=gen-sockpath for useTerminal.
A TCP debugPort works as before.

DapServer now writes with MSG_NOSIGNAL: the terminated event sent after
VS Code has already closed its end on disconnect raised SIGPIPE and
killed the bridge before it could clean up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CpfQQRdc3R13RafigfCNVk
@yuuu
yuuu merged commit 4eb5aa8 into main Oct 18, 2026
4 checks passed
@yuuu
yuuu deleted the feature/dap-unix-socket branch October 18, 2026 20:15
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