Debugging API
The Debugging API allows extensions to integrate debugging capabilities into VS Code. You can create debug adapters, provide debug configurations, and control debug sessions programmatically.Namespace
debug namespace.
Debug Sessions
Accessing Active Session
string
Unique identifier of the debug session
string
Debug session type from the configuration
string
Human-readable session name (can be modified)
WorkspaceFolder | undefined
Workspace folder for this session
DebugConfiguration
Resolved debug configuration with substituted variables
Debug Session Events
- Session Lifecycle
- Custom Events
- Stack Item
Starting Debug Sessions
Start Debugging
WorkspaceFolder | undefined
Workspace folder for resolving variables
string | DebugConfiguration
required
Configuration name or object
DebugSessionOptions
Additional session options
Stop Debugging
Breakpoints
Managing Breakpoints
Breakpoint Events
Debug Configuration Provider
Providing Debug Configurations
Use
DebugConfigurationProviderTriggerKind.Initial for initial launch.json configurations, and Dynamic for configurations shown in the debug dropdown.Debug Adapter
Debug Adapter Descriptor Factory
Debug Adapter Tracker
Custom Requests
Sending Custom Requests
Debug Console
Writing to Debug Console
Package.json Contributions
Define debug configurations in your extension manifest:package.json
Debug Configuration
DebugConfiguration Interface
Creating Configurations
Debug Adapter Protocol
Implementing Debug Adapter
Evaluatable Expressions
Evaluatable Expression Provider
Inline Values Provider
Advanced Features
Parent-Child Debug Sessions
Debug Protocol Breakpoints
Testing Integration
Link Debug Session to Test Run
Common Patterns
Dynamic Debug Configurations
Auto-attach Debugger
Best Practices
Configuration
Configuration
- Provide sensible default configurations
- Validate configurations before starting
- Support both launch and attach modes
- Document all configuration properties
Performance
Performance
- Use debug adapter server for better performance
- Cache debug adapter instances when possible
- Implement efficient variable evaluation
- Handle large data sets appropriately
User Experience
User Experience
- Provide clear error messages
- Support variable substitution in configurations
- Implement proper breakpoint handling
- Show meaningful debug console output
Resources
Related APIs
- Commands API - Execute debug commands
- Workspace API - Access workspace files
- Languages API - Provide debug hover info