probe-web / @probe-web/dap
@probe-web/dap
A Debug Adapter Protocol adapter for probe-rs that runs in the page, a worker, or Node, on top of @probe-web/client's Debugger. ProbeDebugAdapter takes DAP requests through handleMessage() and sends responses and events to onDidSendMessage() listeners, the shape VS Code web's DebugAdapterInlineImplementation expects, so an editor can debug firmware without a native adapter process.
npm install @probe-web/dapimport type { DebugProtocol as DP } from '@vscode/debugprotocol';
import { ProbeDebugAdapter } from '@probe-web/dap';
const adapter = new ProbeDebugAdapter(); // connects with connectProbeRs by default
adapter.onDidSendMessage((m) => console.log(m)); // responses and events
let seq = 1;
const send = (command: string, args?: unknown) =>
adapter.handleMessage({ seq: seq++, type: 'request', command, arguments: args } as DP.Request);
send('initialize', { adapterID: 'probe-rs', linesStartAt1: true, columnsStartAt1: true });
send('launch', { url: 'ws://127.0.0.1:3000', token: 'secret', chip: 'MCXA153', program: '/firmware/app.elf' });
// On the `initialized` event: setBreakpoints, then configurationDone to run.launch/attachconnect toprobe-rs serveover WebSocket by default;transport: 'webusb'runs probe-rs in a worker instead (Chromium only, the probe must already be granted, and there is no disassembly).launchflashesprogramand resets the target;attachleaves it as it is.- One core, reported as thread 1. Pass
connectto supply your own debugger.
See examples/monaco-ide and examples/node-ci/dap.ts for complete clients.
API reference: https://beriberikix.github.io/probe-web/api/dap/
A Debug Adapter Protocol (DAP) adapter for probe-rs that runs in the page, a worker, or Node, on top of @probe-web/client's Debugger.
ProbeDebugAdapter has the shape VS Code web's DebugAdapterInlineImplementation expects: requests go in through handleMessage(), responses and events come out through onDidSendMessage(). Any DAP client can drive it the same way. By default launch / attach connect with connectProbeRs, which opens a probe-rs session over a probe-rs serve WebSocket or over WebUSB in this page, flashes the program on launch, and loads its debug info.
Example
import type { DebugProtocol as DP } from '@vscode/debugprotocol';
import { ProbeDebugAdapter } from '@probe-web/dap';
const adapter = new ProbeDebugAdapter(); // connects with connectProbeRs
adapter.onDidSendMessage((m) => console.log(m)); // responses and events
let seq = 1;
const send = (command: string, args?: unknown) =>
adapter.handleMessage({ seq: seq++, type: 'request', command, arguments: args } as DP.Request);
send('initialize', { adapterID: 'probe-rs', linesStartAt1: true, columnsStartAt1: true });
send('launch', { url: 'ws://127.0.0.1:3000', token: 'secret', chip: 'MCXA153', program: '/firmware/app.elf' });
// After the `initialized` event: setBreakpoints, then configurationDone to run.