Skip to main content

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

All debugging functionality is available through the 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

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

Common Patterns

Dynamic Debug Configurations

Auto-attach Debugger

Best Practices

  • Provide sensible default configurations
  • Validate configurations before starting
  • Support both launch and attach modes
  • Document all configuration properties
  • Use debug adapter server for better performance
  • Cache debug adapter instances when possible
  • Implement efficient variable evaluation
  • Handle large data sets appropriately
  • Provide clear error messages
  • Support variable substitution in configurations
  • Implement proper breakpoint handling
  • Show meaningful debug console output

Resources