Low-level wrapper around VS Code's Debug API and Debug Adapter Protocol (DAP). Executes actual debugging commands and retrieves debug state.
VS Code's debug API is powerful but requires careful handling. DebuggingExecutor encapsulates this complexity, providing a clean interface for the handler layer while dealing with DAP custom requests, breakpoint management, and state retrieval.
- Execute VS Code debug commands (step, continue, restart, etc.)
- Start and stop debug sessions
- Manage breakpoints (add, remove, list, clear)
- Retrieve current debug state (file, line, frame info)
- Execute DAP custom requests for variables and expression evaluation
- Determine if a debug session is ready for operations
┌───────────────────┐
│ DebuggingHandler │
└───────────────────┘
│
▼ Uses
┌───────────────────┐
│ DebuggingExecutor │ ◄── You are here
└───────────────────┘
│
▼ Calls
┌───────────────────┐
│ VS Code Debug API │
│ (DAP Protocol) │
└───────────────────┘
Stepping and control operations use VS Code's command system:
workbench.action.debug.stepOverworkbench.action.debug.stepIntoworkbench.action.debug.stepOutworkbench.action.debug.continueworkbench.action.debug.pauseworkbench.action.debug.restart
For data retrieval, the executor uses DAP's custom request mechanism:
| Request | Purpose |
|---|---|
stackTrace |
Get call stack and frame names |
scopes |
Get variable scopes for a frame |
variables |
Get variables within a scope |
evaluate |
Evaluate expressions in REPL context |
All custom requests go through dapRequest(), which caps each call so an
unresponsive adapter rejects with an error instead of hanging the caller.
A session is considered "ready" when:
vscode.debug.activeDebugSessionexists- Location info is available (file name and line number)
This handles cases where the debugger is still initializing (common with Python).
getCurrentDebugState() queries multiple VS Code APIs:
vscode.debug.activeDebugSession- Session existencevscode.debug.activeStackItem- Frame/thread contextvscode.window.activeTextEditor- Current file and line- DAP
stackTracerequest - Frame name
- Class definition:
src/debuggingExecutor.ts - Interface:
IDebuggingExecutor - State retrieval:
getCurrentDebugState() - DAP requests:
getVariables(),evaluateExpression() - Bounded DAP calls:
dapRequest() - Session readiness:
hasActiveSession()
Breakpoints use VS Code's SourceBreakpoint class:
- Line numbers are 0-indexed internally, 1-indexed in API
- Breakpoints are identified by URI and line position
- The executor provides read-only access to all breakpoints via
getBreakpoints()
For coreclr debug type, the executor uses a different approach:
- Opens the test file directly
- Executes
testing.debugCurrentFilecommand
This handles .NET's test debugging workflow which differs from other languages.