src/vs/workbench/contrib/debug/common/abstractDebugAdapter.ts

226 LOC · 164 covered · 62 uncovered · 40 ranges · 28 concepts · 5 introducers · 14 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filesrc/vs/workbench/contrib/debug/node/debugAdapter.ts · 404 LOCnode/debugAdapter.tssrc/vs/workbench/contrib/debug/test/common/mockDebug.ts · 697 LOCcommon/mockDebug.tsdebugModel.ts ×5 · 39 introduced LOCdebugModel.ts ×5debugModel.ts ×1 · 13 introduced LOCdebugModel.ts ×1debugModel.ts ×1 · 8 introduced LOCdebugModel.ts ×1debugModel.ts ×6 · 20 introduced LOCdebugModel.ts ×6debugStorage.ts ×17 · 98 introduced LOCdebugStorage.ts ×17debugModel.ts ×3 · 29 introduced LOCdebugModel.ts ×3debugModel.ts ×2 · 11 introduced LOCdebugModel.ts ×2debugModel.ts ×2 · 12 introduced LOCdebugModel.ts ×2debugModel.ts ×2 · 13 introduced LOCdebugModel.ts ×2mockDebug.ts ×1 · 2 introduced LOCmockDebug.ts ×1mockDebug.ts ×1 · 2 introduced LOCmockDebug.ts ×1mockDebug.ts ×7 · 30 introduced LOCmockDebug.ts ×7abstractDebugAdapter.ts ×4 · 18 introduced LOCabstractDebugAdapter.ts …debugModel.ts ×1 · 1 introduced LOCdebugModel.ts ×1debugModel.ts ×185 · 988 introduced LOCdebugModel.ts ×185debugAdapter.ts ×16 · 67 introduced LOCdebugAdapter.ts ×16debugger.ts ×3 · 27 introduced LOCdebugger.ts ×3debugger.ts ×5 · 89 introduced LOCdebugger.ts ×5debugger.ts ×2 · 4 introduced LOCdebugger.ts ×2debugger.ts ×26 · 153 introduced LOCdebugger.ts ×26debugUtils.ts ×21 · 86 introduced LOCdebugUtils.ts ×21debugAdapter.ts ×2 · 4 introduced LOCdebugAdapter.ts ×2debugAdapter.ts ×2 · 4 introduced LOCdebugAdapter.ts ×2debugAdapter.ts ×9 · 88 introduced LOCdebugAdapter.ts ×9abstractDebugAdapter.ts ×5 · 31 introduced LOCabstractDebugAdapter.ts …abstractDebugAdapter.ts ×8 · 27 introduced LOCabstractDebugAdapter.ts …debugAdapter.ts ×16 · 89 introduced LOCdebugAdapter.ts ×16abstractDebugAdapter.ts ×17 · 85 introduced LOCabstractDebugAdapter.ts …abstractDebugAdapter.test|title=Debug - AbstractDebugAdapter event ordering does not insert boundaries between events|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/common/abstractDebugAdapter.test|title=Debug - AbstractDebugAdapter event ordering does not insert boundaries between events|occurrence=1abstractDebugAdapter.tes…abstractDebugAdapter.test|title=Debug - AbstractDebugAdapter event ordering inserts task boundary after response|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/common/abstractDebugAdapter.test|title=Debug - AbstractDebugAdapter event ordering inserts task boundary after response|occurrence=1abstractDebugAdapter.tes…abstractDebugAdapter.test|title=Debug - AbstractDebugAdapter event ordering inserts task boundary before response|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/common/abstractDebugAdapter.test|title=Debug - AbstractDebugAdapter event ordering inserts task boundary before response|occurrence=1abstractDebugAdapter.tes…debugModel.test|title=DebugModel DebugModel refreshTopOfCallstack resolves all returned promises when called multiple times|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/common/debugModel.test|title=DebugModel DebugModel refreshTopOfCallstack resolves all returned promises when called multiple times|occurrence=1debugModel.test|title=De…debugModel.test|title=DebugModel ExceptionBreakpoint Restored matches new|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/common/debugModel.test|title=DebugModel ExceptionBreakpoint Restored matches new|occurrence=1debugModel.test|title=De…debugModel.test|title=DebugModel FunctionBreakpoint Id is saved|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/common/debugModel.test|title=DebugModel FunctionBreakpoint Id is saved|occurrence=1debugModel.test|title=De…debugModel.test|title=DebugModel InstructionBreakpoint removeInstructionBreakpoints falls back to instructionReference+offset when address not supplied|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/common/debugModel.test|title=DebugModel InstructionBreakpoint removeInstructionBreakpoints falls back to instructionReference+offset when address not supplied|occurrence=1debugModel.test|title=De…debugModel.test|title=DebugModel InstructionBreakpoint removeInstructionBreakpoints prefers address match when instructionReference has changed|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/common/debugModel.test|title=DebugModel InstructionBreakpoint removeInstructionBreakpoints prefers address match when instructionReference has changed|occurrence=1debugModel.test|title=De…debugModel.test|title=DebugModel InstructionBreakpoint removeInstructionBreakpoints with only address removes the matching entry and leaves others|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/common/debugModel.test|title=DebugModel InstructionBreakpoint removeInstructionBreakpoints with only address removes the matching entry and leaves others|occurrence=1debugModel.test|title=De…debugger.test|title=Debug - Debugger attributes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/node/debugger.test|title=Debug - Debugger attributes|occurrence=1debugger.test|title=Debu…debugger.test|title=Debug - Debugger getSchemaAttributes logs malformed properties and ignores them|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/node/debugger.test|title=Debug - Debugger getSchemaAttributes logs malformed properties and ignores them|occurrence=1debugger.test|title=Debu…debugger.test|title=Debug - Debugger initial config file content|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/node/debugger.test|title=Debug - Debugger initial config file content|occurrence=1debugger.test|title=Debu…streamDebugAdapter.test|title=Debug - StreamDebugAdapter StreamDebugAdapter (NamedPipeDebugAdapter) can initialize a connection|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/node/streamDebugAdapter.test|title=Debug - StreamDebugAdapter StreamDebugAdapter (NamedPipeDebugAdapter) can initialize a connection|occurrence=1streamDebugAdapter.test|…streamDebugAdapter.test|title=Debug - StreamDebugAdapter StreamDebugAdapter (SocketDebugAdapter) can initialize a connection|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/debug/test/node/streamDebugAdapter.test|title=Debug - StreamDebugAdapter StreamDebugAdapter (SocketDebugAdapter) can initialize a connection|occurrence=1streamDebugAdapter.test|…Focused file · src/vs/workbench/contrib/debug/common/abstractDebugAdapter.ts · 226 LOCcommon/abstractDebugAdap…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- abstractDebugAdapter.ts ×17
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { Emitter, Event } from '../../../../base/common/event.js';
7 > import { IDebugAdapter } from './debug.js';
8 > import { timeout } from '../../../../base/common/async.js';
9 > import { localize } from '../../../../nls.js';
10 >
11 > /**
12 > * Abstract implementation of the low level API for a debug adapter.
13 > * Missing is how this API communicates with the debug adapter.
14 > */
15 > export abstract class AbstractDebugAdapter implements IDebugAdapter {
16 > private sequence: number;
17 > private pendingRequests = new Map<number, (e: DebugProtocol.Response) => void>();
18 > private pendingRequestTimers = new Map<number, Timeout>();
19 > private requestCallback: ((request: DebugProtocol.Request) => void) | undefined;
20 > private eventCallback: ((request: DebugProtocol.Event) => void) | undefined;
21 > private messageCallback: ((message: DebugProtocol.ProtocolMessage) => void) | undefined;
22 > private queue: DebugProtocol.ProtocolMessage[] = [];
23 > protected readonly _onError = new Emitter<Error>();
24 > protected readonly _onExit = new Emitter<number | null>();
25 >
26 > constructor() {
27 > this.sequence = 1; abstractDebugAdapter.ts ×8
28 > }
30 > abstract startSession(): Promise<void>;
31 >
32 > abstract stopSession(): Promise<void>;
33 >
34 > abstract sendMessage(message: DebugProtocol.ProtocolMessage): void;
35 >
36 > get onError(): Event<Error> {
37 return this._onError.event;
38 }
40 > get onExit(): Event<number | null> {
41 return this._onExit.event;
42 }
44 > onMessage(callback: (message: DebugProtocol.ProtocolMessage) => void): void {
45 if (this.messageCallback) {
46 this._onError.fire(new Error(`attempt to set more than one 'Message' callback`));
47 }
48 this.messageCallback = callback;
49 }
51 > onEvent(callback: (event: DebugProtocol.Event) => void): void {
52 > if (this.eventCallback) { abstractDebugAdapter.ts ×4
53 this._onError.fire(new Error(`attempt to set more than one 'Event' callback`));
54 }
55 > this.eventCallback = callback; abstractDebugAdapter.ts ×4
56 > }
58 > onRequest(callback: (request: DebugProtocol.Request) => void): void {
59 if (this.requestCallback) {
60 this._onError.fire(new Error(`attempt to set more than one 'Request' callback`));
61 }
62 this.requestCallback = callback;
63 }
65 > sendResponse(response: DebugProtocol.Response): void {
66 if (response.seq > 0) {
67 this._onError.fire(new Error(`attempt to send more than one response for command ${response.command}`));
68 } else {
69 this.internalSend('response', response);
70 }
71 }
73 > sendRequest(command: string, args: any, clb: (result: DebugProtocol.Response) => void, timeout?: number): number {
74 > const request: any = { abstractDebugAdapter.ts ×5
75 > command: command
76 > };
77 > if (args && Object.keys(args).length > 0) {
78 > request.arguments = args;
79 > }
80 > this.internalSend('request', request);
81 > if (typeof timeout === 'number') {
82 > const timer = setTimeout(() => { debugAdapter.ts ×9
83 this.pendingRequestTimers.delete(request.seq);
84 const clb = this.pendingRequests.get(request.seq);
85 if (clb) {
86 this.pendingRequests.delete(request.seq);
87 const err: DebugProtocol.Response = {
88 type: 'response',
89 seq: 0,
90 request_seq: request.seq,
91 success: false,
92 command,
93 message: localize('timeout', "Timeout after {0} ms for '{1}'", timeout, command)
94 };
95 clb(err);
96 }
97 > }, timeout); debugAdapter.ts ×9
98 > this.pendingRequestTimers.set(request.seq, timer);
99 > }
100 > if (clb) { abstractDebugAdapter.ts ×5
101 > // store callback for this request
102 > this.pendingRequests.set(request.seq, clb);
103 > }
104 >
105 > return request.seq;
106 > }
108 > acceptMessage(message: DebugProtocol.ProtocolMessage): void {
109 > if (this.messageCallback) { abstractDebugAdapter.ts ×8
110 this.messageCallback(message);
112 > this.queue.push(message);
113 > if (this.queue.length === 1) {
114 > // first item = need to start processing loop
115 > this.processQueue();
116 > }
117 > }
118 > }
120 > /**
121 > * Returns whether we should insert a timeout between processing messageA
122 > * and messageB. Artificially queueing protocol messages guarantees that any
123 > * microtasks for previous message finish before next message is processed.
124 > * This is essential ordering when using promises anywhere along the call path.
125 > *
126 > * For example, take the following, where `chooseAndSendGreeting` returns
127 > * a person name and then emits a greeting event:
128 > *
129 > * ```
130 > * let person: string;
131 > * adapter.onGreeting(() => console.log('hello', person));
132 > * person = await adapter.chooseAndSendGreeting();
133 > * ```
134 > *
135 > * Because the event is dispatched synchronously, it may fire before person
136 > * is assigned if they're processed in the same task. Inserting a task
137 > * boundary avoids this issue.
138 > */
139 > protected needsTaskBoundaryBetween(messageA: DebugProtocol.ProtocolMessage, messageB: DebugProtocol.ProtocolMessage) {
140 > return messageA.type !== 'event' || messageB.type !== 'event'; abstractDebugAdapter.ts ×4
141 > }
143 > /**
144 > * Reads and dispatches items from the queue until it is empty.
145 > */
146 > private async processQueue() {
147 > let message: DebugProtocol.ProtocolMessage | undefined; abstractDebugAdapter.ts ×8
148 > while (this.queue.length) {
149 > if (!message || this.needsTaskBoundaryBetween(this.queue[0], message)) {
150 > await timeout(0);
151 > }
152 >
153 > message = this.queue.shift();
154 > if (!message) {
155 return; // may have been disposed of
156 }
158 > switch (message.type) {
159 > case 'event':
160 > this.eventCallback?.(<DebugProtocol.Event>message); abstractDebugAdapter.ts ×4
161 > break;
162 > case 'request': abstractDebugAdapter.ts ×8
163 this.requestCallback?.(<DebugProtocol.Request>message);
164 break;
165 > case 'response': { abstractDebugAdapter.ts ×8
166 > const response = <DebugProtocol.Response>message; abstractDebugAdapter.ts ×5
167 > const clb = this.pendingRequests.get(response.request_seq);
168 > if (clb) {
169 > this.pendingRequests.delete(response.request_seq);
170 > this.clearPendingRequestTimer(response.request_seq);
171 > clb(response);
172 > }
173 > break;
174 > }
176 > }
177 > }
179 > private internalSend(typ: 'request' | 'response' | 'event', message: DebugProtocol.ProtocolMessage): void {
180 > message.type = typ; abstractDebugAdapter.ts ×5
181 > message.seq = this.sequence++;
182 > this.sendMessage(message);
183 > }
185 > protected async cancelPendingRequests(): Promise<void> {
186 > if (this.pendingRequests.size === 0) { debugAdapter.ts ×9
187 > return Promise.resolve();
188 > }
189
190 const pending = new Map<number, (e: DebugProtocol.Response) => void>();
191 this.pendingRequests.forEach((value, key) => pending.set(key, value));
192 await timeout(500);
193 pending.forEach((callback, request_seq) => {
194 const err: DebugProtocol.Response = {
195 type: 'response',
196 seq: 0,
197 request_seq,
198 success: false,
199 command: 'canceled',
200 message: 'canceled'
201 };
202 callback(err);
203 this.pendingRequests.delete(request_seq);
204 this.clearPendingRequestTimer(request_seq);
205 });
208 > private clearPendingRequestTimer(requestSeq: number): void {
209 > clearTimeout(this.pendingRequestTimers.get(requestSeq)); abstractDebugAdapter.ts ×5
210 > this.pendingRequestTimers.delete(requestSeq);
211 > }
213 > getPendingRequestIds(): number[] {
214 return Array.from(this.pendingRequests.keys());
215 }
217 > dispose(): void {
218 > for (const timer of this.pendingRequestTimers.values()) { debugAdapter.ts ×9
219 clearTimeout(timer);
220 }
221 > this.pendingRequestTimers.clear(); debugAdapter.ts ×9
222 > this._onError.dispose();
223 > this._onExit.dispose();
224 > this.queue = [];
225 > }