Debugging Architecture (DAP)
Relevant source files
The following files were used as context for generating this wiki page:- extensions/typescript-language-features/package.nls.json
- extensions/markdown-language-features/package.json
- extensions/markdown-language-features/package.nls.json
- extensions/html-language-features/package.nls.json
- extensions/github/package.json
- extensions/make/package.json
- extensions/yaml/syntaxes/yaml.tmLanguage.json
The provided source files do not contain direct implementation details of the Debug Adapter Protocol (DAP) itself. However, they offer significant insight into the user-facing debugging features and the diagnostic/tracing architecture for various language services, which are integral components of the overall debugging experience in VS Code. This includes user walkthroughs for debugging, configuration for tracing language server communication, and problem matchers for build tasks.
User-Facing Debugging Features
The VS Code extension for TypeScript and JavaScript provides a guided experience for new users to get started with running and debugging their code.
JavaScript Debugging Walkthrough
A walkthrough titled "Get started with JavaScript and Node.js" is available to guide users through the initial setup and debugging process.
This diagram illustrates the user flow through the JavaScript debugging walkthrough.
The steps defined for this walkthrough are:
| Step Title | Description | Source |
|---|---|---|
Install Node.js | Prompts the user to install Node.js to run JavaScript code, build apps, and use npm. | extensions/typescript-language-features/package.nls.json |
Create a JavaScript File | Guides the user to create a new file with a .js extension. | extensions/typescript-language-features/package.nls.json |
Run and Debug your JavaScript | Explains how to run JS files with Node.js and introduces the VS Code debugger for step-by-step code execution. Triggers the javascript-walkthrough.commands.debugJsFile command. | extensions/typescript-language-features/package.nls.json |
Explore More | Provides links to documentation for further learning about JavaScript and Node.js in VS Code. | extensions/typescript-language-features/package.nls.json |
Sources: extensions/typescript-language-features/package.nls.json
Language Server Tracing and Diagnostics
A key part of the debugging architecture is the ability to diagnose and trace the communication between the VS Code client and various language servers. This is crucial for troubleshooting IntelliSense, validation, and other language-specific features.
TypeScript Server (TSServer) Diagnostics
The TypeScript and JavaScript language features extension provides extensive configuration for logging and tracing the TypeScript Server (tsserver). This allows developers to diagnose performance issues and other problems.
This sequence diagram shows how a user enables and accesses TSServer trace logs.
The following settings are available for tsserver diagnostics:
| Setting | Description |
|---|---|
typescript.tsserver.enableTracing | Enables tracing TS server performance to a directory. |
typescript.tsserver.log | Enables logging of the TS server to a file. Can be set to off, debug, or trace. |
typescript.tsserver.trace | Enables tracing of messages sent to the TS server. Can be set to off, messages, or verbose. |
Sources: extensions/typescript-language-features/package.nls.json, extensions/markdown-language-features/package.json
Related commands are also provided to manage the tsserver:
typescript.openTsServerLog.title: "Open TS Server log"typescript.restartTsServer: "Restart TS Server"
Sources: extensions/typescript-language-features/package.nls.json
Markdown Language Server Diagnostics
Similar to the TSServer, the Markdown language features extension provides settings to trace its language server.
| Setting | Description | Default |
|---|---|---|
markdown.trace.server | Traces the communication between VS Code and the Markdown language server. | off |
markdown.server.log | Controls the logging level of the Markdown language server. | off |
Sources: extensions/markdown-language-features/package.json, extensions/markdown-language-features/package.nls.json
HTML Language Server Diagnostics
The HTML extension also includes a tracing option for its language server.
html.trace.server.desc: "Traces the communication between VS Code and the HTML language server."
Sources: extensions/html-language-features/package.nls.json
Task-Based Diagnostics
VS Code's debugging and diagnostics architecture extends to its task execution engine, using "problem matchers" to parse task output for errors.
TypeScript Problem Matchers
The TypeScript extension contributes problem matchers to integrate tsc (the TypeScript compiler) output into the editor's "Problems" view. This allows developers to see compilation errors directly in the editor without actively debugging.
typescript.problemMatchers.tsc.label: "TypeScript problems" (for single-run compilation)typescript.problemMatchers.tscWatch.label: "TypeScript problems (watch mode)" (fortsc --watchmode)
These matchers parse the output from the tsc command and create diagnostics within VS Code, effectively providing a passive debugging and error-checking mechanism.
Sources: extensions/typescript-language-features/package.nls.json