Debugging in VS Code
This guide covers setting up debugging for Run programs in Visual Studio Code.
Prerequisites
Section titled “Prerequisites”- VS Code 1.80+
- The
runcompiler installed and on yourPATH - GDB or LLDB installed on your system
Quick Start
Section titled “Quick Start”Using the Extension (Recommended)
Section titled “Using the Extension (Recommended)”- Install the Run Debug extension from
editors/vscode/(see extension README) - Open a
.runfile - Press
F5to start debugging
Without the Extension
Section titled “Without the Extension”You can use the generic DAP support with a launch.json configuration:
{ "version": "0.2.0", "configurations": [ { "type": "run", "request": "launch", "name": "Debug Run Program", "program": "${file}" } ]}Features
Section titled “Features”Breakpoints
Section titled “Breakpoints”- Click in the gutter to toggle breakpoints
- Right-click a breakpoint for conditional options:
- Expression condition: e.g.,
i > 10 - Hit count: Break after N hits
- Expression condition: e.g.,
Stepping
Section titled “Stepping”| Action | Shortcut |
|---|---|
| Continue | F5 |
| Step Over | F10 |
| Step Into | F11 |
| Step Out | Shift+F11 |
Variable Inspection
Section titled “Variable Inspection”- Hover over variables to see their values
- Use the Variables pane in the Debug sidebar
- Variables display Run type names (e.g.,
intinstead ofint64_t) - SSA temporaries are automatically hidden
Debug Console
Section titled “Debug Console”Type Run expressions in the Debug Console to evaluate them:
> myVariable42> obj.field"hello"Rich Inspection (Custom Requests)
Section titled “Rich Inspection (Custom Requests)”The DAP server supports custom inspection commands for Run runtime types. These can be accessed via the Debug Console or extensions:
run/inspectGenRef: Inspect generational reference validityrun/inspectChannel: View channel buffer state and waitersrun/inspectMap: View map entry count
Batch Commands (AI Agent Support)
Section titled “Batch Commands (AI Agent Support)”The runBatch custom request allows multiple DAP commands in a single request, reducing round-trips for AI coding agents:
{ "command": "runBatch", "arguments": { "commands": [ { "command": "setBreakpoints", "args": { "source": {"path": "main.run"}, "breakpoints": [{"line": 5}] } }, { "command": "continue", "args": {} } ] }}Architecture
Section titled “Architecture”VS Code <--DAP/stdio--> run debug --dap <--GDB/MI--> GDB/LLDB <--> ./program- VS Code sends DAP requests over stdin
- The Run DAP server compiles the program with debug symbols
- GDB or LLDB is launched via the MI protocol
- Debug operations are translated between DAP and GDB/MI
- Source mapping uses
#linedirectives to map C code back to.runsource