Repository navigation
Start the VS Code DAP bridge from launch.json alone - #38
Merged
Merged
Conversation
`mrdbg --open` now accepts the command line vscode-rdbg's `launch` gives `rdbg` when `rdbgPath` points at mrdbg (`--command --open --stop-at-load --host=H --port=P -- ruby script`), treats --host/--port as the DAP side, finds the device from MRDEBUG_SOCK / MRDEBUG_HOST / MRDEBUG_PORT, and prints the `DEBUGGER: ...` lines vscode-rdbg waits for before attaching. Failures go to stderr as `Error: ...`, which vscode-rdbg shows the user. This replaces the tasks.json + preLaunchTask setup in the README. Also: `--flag=value` spelling for every value flag, MRDEBUG_HOST for a bare `mrdbg`, and DapBridge refusing rdbg's `,command` evaluate (sent by vscode-rdbg at launch) without touching the device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VTDDhUqXPJBvErqqWKwULV
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.
Summary
Connecting VS Code used to take two files: a
tasks.jsonbackground task that startedmrdbg --dap-port, and anattachconfig inlaunch.jsonthat named it as itspreLaunchTask. This PR cuts that down to a singlelaunch.jsonentry.vscode-rdbg's
launchrequest runs the program named byrdbgPath. It passes that program--command --open --stop-at-load --host=H --port=P -- ruby script, then waits for twoDEBUGGER: ...lines on stderr before attaching toH:P.mrdbg --opennow behaves that way:{ "type": "rdbg", "request": "launch", "name": "Debug on device", "rdbgPath": "/path/to/build/host/bin/mrdbg", "debugPort": "localhost:12345", "script": "${file}", "env": { "MRDEBUG_HOST": "192.168.0.10", "MRDEBUG_PORT": "4711" } }Changes
Options--open/-O(previously rejected as unsupported) now marks a launch.--host/--portgive the DAP listen address, not the device's.--commandand--stop-at-loadare accepted and ignored.--is collected and ignored. The program must already be waiting inbinding.debugger.--flag=valuespelling.CLI.launch_dapmrdbgdoes:MRDEBUG_SOCK, elseMRDEBUG_HOST:MRDEBUG_PORT.DEBUGGER: Debugger can attach via TCP/IP (H:P)andDEBUGGER: wait for debugger connection....debugPort, device unreachable) on stderr asError: .... vscode-rdbg shows such a message and aborts the launch.CLI.serve_dap: the bridge loop now shared by the existing--dap-portattach path and the new launch path. The attach path now binds the DAP port before printingDAP bridge listening on, which closes a small race.MRDEBUG_HOST: new env var, also honored by a baremrdbg. Default127.0.0.1.DapBridge: refuses,-prefixed expressions (rdbg's command syntax) without touching the device. vscode-rdbg sends,eval $stdout.sync=trueat the start of every launch session.launch.jsonsetup instead oftasks.json+preLaunchTask, and keeps the manual--dap-port+attachroute. CLAUDE.md documents the vscode-rdbg contract this relies on.Caveat
This relies on how vscode-rdbg internally launches
rdbg(the argv shape and the stderr strings it matches, fromsrc/extension.ts'slaunchOnConsole/runDebuggeeWithTCP). That is not a public API, so a vscode-rdbg update could break it. The manualattachroute still works either way.Test plan
rake test:unit: 0 KO. New tests cover--openand--flag=valueparsing,launch_dap's two failure paths,default_host, and the,commandevaluate refusal.rake test:smokepasses.mrubyprocess waiting inbinding.debugger(MRDEBUG_PORT). A Python script played vscode-rdbg's part: it spawnedmrdbgwith vscode-rdbg's exact argv, waited for the stderr lines, then connected and sentinitialize,launch,,eval,setBreakpoints,configurationDone,evaluate,continue(breakpoint hit),stackTraceanddisconnect. All succeeded, and the program ran to completion.🤖 Generated with Claude Code
https://claude.ai/code/session_01VTDDhUqXPJBvErqqWKwULV