Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/debug/common/debug.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
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 { IAction } from '../../../../base/common/actions.js';
7
import { VSBuffer } from '../../../../base/common/buffer.js';
8
import { CancellationToken } from '../../../../base/common/cancellation.js';
9
import { Color } from '../../../../base/common/color.js';
10
import { Event } from '../../../../base/common/event.js';
11
import { IJSONSchemaSnippet } from '../../../../base/common/jsonSchema.js';
12
import { IDisposable } from '../../../../base/common/lifecycle.js';
13
import severity from '../../../../base/common/severity.js';
14
import { URI, UriComponents, URI as uri } from '../../../../base/common/uri.js';
15
import { IPosition, Position } from '../../../../editor/common/core/position.js';
16
import { IRange } from '../../../../editor/common/core/range.js';
17
import * as editorCommon from '../../../../editor/common/editorCommon.js';
18
import { ITextModel as EditorIModel } from '../../../../editor/common/model.js';
19
import * as nls from '../../../../nls.js';
20
import { ConfigurationTarget } from '../../../../platform/configuration/common/configuration.js';
21
import { RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
22
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
23
import { ITelemetryEndpoint } from '../../../../platform/telemetry/common/telemetry.js';
24
import { IWorkspaceFolder } from '../../../../platform/workspace/common/workspace.js';
25
import { IEditorPane } from '../../../common/editor.js';
26
import { DebugCompoundRoot } from './debugCompoundRoot.js';
27
import { IDataBreakpointOptions, IFunctionBreakpointOptions, IInstructionBreakpointOptions } from './debugModel.js';
28
import { Source } from './debugSource.js';
29
import { ITaskIdentifier } from '../../tasks/common/tasks.js';
30
import { LiveTestResult } from '../../testing/common/testResult.js';
31
import { IEditorService } from '../../../services/editor/common/editorService.js';
32
import { IView } from '../../../common/views.js';
33
34
export const VIEWLET_ID = 'workbench.view.debug';
35
36
export const VARIABLES_VIEW_ID = 'workbench.debug.variablesView';
37
export const WATCH_VIEW_ID = 'workbench.debug.watchExpressionsView';
38
export const CALLSTACK_VIEW_ID = 'workbench.debug.callStackView';
39
export const LOADED_SCRIPTS_VIEW_ID = 'workbench.debug.loadedScriptsView';
40
export const BREAKPOINTS_VIEW_ID = 'workbench.debug.breakPointsView';
41
export const DISASSEMBLY_VIEW_ID = 'workbench.debug.disassemblyView';
42
export const DEBUG_PANEL_ID = 'workbench.panel.repl';
43
export const REPL_VIEW_ID = 'workbench.panel.repl.view';
44
export const CONTEXT_DEBUG_TYPE = new RawContextKey<string>('debugType', undefined, { type: 'string', description: nls.localize('debugType', "Debug type of the active debug session. For example 'python'.") });
45
export const CONTEXT_DEBUG_CONFIGURATION_TYPE = new RawContextKey<string>('debugConfigurationType', undefined, { type: 'string', description: nls.localize('debugConfigurationType', "Debug type of the selected launch configuration. For example 'python'.") });
46
export const CONTEXT_DEBUG_STATE = new RawContextKey<string>('debugState', 'inactive', { type: 'string', description: nls.localize('debugState', "State that the focused debug session is in. One of the following: 'inactive', 'initializing', 'stopped' or 'running'.") });
47
export const CONTEXT_DEBUG_UX_KEY = 'debugUx';
48
export const CONTEXT_DEBUG_UX = new RawContextKey<string>(CONTEXT_DEBUG_UX_KEY, 'default', { type: 'string', description: nls.localize('debugUX', "Debug UX state. When there are no debug configurations it is 'simple', otherwise 'default'. Used to decide when to show welcome views in the debug viewlet.") });
49
export const CONTEXT_HAS_DEBUGGED = new RawContextKey<boolean>('hasDebugged', false, { type: 'boolean', description: nls.localize('hasDebugged', "True when a debug session has been started at least once, false otherwise.") });
50
export const CONTEXT_IN_DEBUG_MODE = new RawContextKey<boolean>('inDebugMode', false, { type: 'boolean', description: nls.localize('inDebugMode', "True when debugging, false otherwise.") });
51
export const CONTEXT_IN_DEBUG_REPL = new RawContextKey<boolean>('inDebugRepl', false, { type: 'boolean', description: nls.localize('inDebugRepl', "True when focus is in the debug console, false otherwise.") });
52
export const CONTEXT_BREAKPOINT_WIDGET_VISIBLE = new RawContextKey<boolean>('breakpointWidgetVisible', false, { type: 'boolean', description: nls.localize('breakpointWidgetVisibile', "True when breakpoint editor zone widget is visible, false otherwise.") });
53
export const CONTEXT_IN_BREAKPOINT_WIDGET = new RawContextKey<boolean>('inBreakpointWidget', false, { type: 'boolean', description: nls.localize('inBreakpointWidget', "True when focus is in the breakpoint editor zone widget, false otherwise.") });
54
export const CONTEXT_BREAKPOINTS_FOCUSED = new RawContextKey<boolean>('breakpointsFocused', true, { type: 'boolean', description: nls.localize('breakpointsFocused', "True when the BREAKPOINTS view is focused, false otherwise.") });
55
export const CONTEXT_WATCH_EXPRESSIONS_FOCUSED = new RawContextKey<boolean>('watchExpressionsFocused', true, { type: 'boolean', description: nls.localize('watchExpressionsFocused', "True when the WATCH view is focused, false otherwise.") });
56
export const CONTEXT_WATCH_EXPRESSIONS_EXIST = new RawContextKey<boolean>('watchExpressionsExist', false, { type: 'boolean', description: nls.localize('watchExpressionsExist', "True when at least one watch expression exists, false otherwise.") });
57
export const CONTEXT_VARIABLES_FOCUSED = new RawContextKey<boolean>('variablesFocused', true, { type: 'boolean', description: nls.localize('variablesFocused', "True when the VARIABLES views is focused, false otherwise") });
58
export const CONTEXT_EXPRESSION_SELECTED = new RawContextKey<boolean>('expressionSelected', false, { type: 'boolean', description: nls.localize('expressionSelected', "True when an expression input box is open in either the WATCH or the VARIABLES view, false otherwise.") });
59
export const CONTEXT_BREAKPOINT_INPUT_FOCUSED = new RawContextKey<boolean>('breakpointInputFocused', false, { type: 'boolean', description: nls.localize('breakpointInputFocused', "True when the input box has focus in the BREAKPOINTS view.") });
60
export const CONTEXT_CALLSTACK_ITEM_TYPE = new RawContextKey<string>('callStackItemType', undefined, { type: 'string', description: nls.localize('callStackItemType', "Represents the item type of the focused element in the CALL STACK view. For example: 'session', 'thread', 'stackFrame'") });
61
export const CONTEXT_CALLSTACK_SESSION_IS_ATTACH = new RawContextKey<boolean>('callStackSessionIsAttach', false, { type: 'boolean', description: nls.localize('callStackSessionIsAttach', "True when the session in the CALL STACK view is attach, false otherwise. Used internally for inline menus in the CALL STACK view.") });
62
export const CONTEXT_CALLSTACK_ITEM_STOPPED = new RawContextKey<boolean>('callStackItemStopped', false, { type: 'boolean', description: nls.localize('callStackItemStopped', "True when the focused item in the CALL STACK is stopped. Used internaly for inline menus in the CALL STACK view.") });
63
export const CONTEXT_CALLSTACK_SESSION_HAS_ONE_THREAD = new RawContextKey<boolean>('callStackSessionHasOneThread', false, { type: 'boolean', description: nls.localize('callStackSessionHasOneThread', "True when the focused session in the CALL STACK view has exactly one thread. Used internally for inline menus in the CALL STACK view.") });
64
export const CONTEXT_CALLSTACK_FOCUSED = new RawContextKey<boolean>('callStackFocused', true, { type: 'boolean', description: nls.localize('callStackFocused', "True when the CALLSTACK view is focused, false otherwise.") });
65
export const CONTEXT_WATCH_ITEM_TYPE = new RawContextKey<string>('watchItemType', undefined, { type: 'string', description: nls.localize('watchItemType', "Represents the item type of the focused element in the WATCH view. For example: 'expression', 'variable'") });
66
export const CONTEXT_CAN_VIEW_MEMORY = new RawContextKey<boolean>('canViewMemory', undefined, { type: 'boolean', description: nls.localize('canViewMemory', "Indicates whether the item in the view has an associated memory refrence.") });
67
export const CONTEXT_BREAKPOINT_ITEM_TYPE = new RawContextKey<string>('breakpointItemType', undefined, { type: 'string', description: nls.localize('breakpointItemType', "Represents the item type of the focused element in the BREAKPOINTS view. For example: 'breakpoint', 'exceptionBreakppint', 'functionBreakpoint', 'dataBreakpoint'") });
68
export const CONTEXT_BREAKPOINT_ITEM_IS_DATA_BYTES = new RawContextKey<boolean>('breakpointItemBytes', undefined, { type: 'boolean', description: nls.localize('breakpointItemIsDataBytes', "Whether the breakpoint item is a data breakpoint on a byte range.") });
69
export const CONTEXT_BREAKPOINT_HAS_MODES = new RawContextKey<boolean>('breakpointHasModes', false, { type: 'boolean', description: nls.localize('breakpointHasModes', "Whether the breakpoint has multiple modes it can switch to.") });
70
export const CONTEXT_BREAKPOINT_SUPPORTS_CONDITION = new RawContextKey<boolean>('breakpointSupportsCondition', false, { type: 'boolean', description: nls.localize('breakpointSupportsCondition', "True when the focused breakpoint supports conditions.") });
71
export const CONTEXT_LOADED_SCRIPTS_SUPPORTED = new RawContextKey<boolean>('loadedScriptsSupported', false, { type: 'boolean', description: nls.localize('loadedScriptsSupported', "True when the focused sessions supports the LOADED SCRIPTS view") });
72
export const CONTEXT_LOADED_SCRIPTS_ITEM_TYPE = new RawContextKey<string>('loadedScriptsItemType', undefined, { type: 'string', description: nls.localize('loadedScriptsItemType', "Represents the item type of the focused element in the LOADED SCRIPTS view.") });
73
export const CONTEXT_FOCUSED_SESSION_IS_ATTACH = new RawContextKey<boolean>('focusedSessionIsAttach', false, { type: 'boolean', description: nls.localize('focusedSessionIsAttach', "True when the focused session is 'attach'.") });
74
export const CONTEXT_FOCUSED_SESSION_IS_NO_DEBUG = new RawContextKey<boolean>('focusedSessionIsNoDebug', false, { type: 'boolean', description: nls.localize('focusedSessionIsNoDebug', "True when the focused session is run without debugging.") });
75
export const CONTEXT_STEP_BACK_SUPPORTED = new RawContextKey<boolean>('stepBackSupported', false, { type: 'boolean', description: nls.localize('stepBackSupported', "True when the focused session supports 'stepBack' requests.") });
76
export const CONTEXT_RESTART_FRAME_SUPPORTED = new RawContextKey<boolean>('restartFrameSupported', false, { type: 'boolean', description: nls.localize('restartFrameSupported', "True when the focused session supports 'restartFrame' requests.") });
77
export const CONTEXT_STACK_FRAME_SUPPORTS_RESTART = new RawContextKey<boolean>('stackFrameSupportsRestart', false, { type: 'boolean', description: nls.localize('stackFrameSupportsRestart', "True when the focused stack frame supports 'restartFrame'.") });
78
export const CONTEXT_JUMP_TO_CURSOR_SUPPORTED = new RawContextKey<boolean>('jumpToCursorSupported', false, { type: 'boolean', description: nls.localize('jumpToCursorSupported', "True when the focused session supports 'jumpToCursor' request.") });
79
export const CONTEXT_STEP_INTO_TARGETS_SUPPORTED = new RawContextKey<boolean>('stepIntoTargetsSupported', false, { type: 'boolean', description: nls.localize('stepIntoTargetsSupported', "True when the focused session supports 'stepIntoTargets' request.") });
80
export const CONTEXT_BREAKPOINTS_EXIST = new RawContextKey<boolean>('breakpointsExist', false, { type: 'boolean', description: nls.localize('breakpointsExist', "True when at least one breakpoint exists.") });
81
export const CONTEXT_DEBUGGERS_AVAILABLE = new RawContextKey<boolean>('debuggersAvailable', false, { type: 'boolean', description: nls.localize('debuggersAvailable', "True when there is at least one debug extensions active.") });
82
export const CONTEXT_DEBUG_EXTENSION_AVAILABLE = new RawContextKey<boolean>('debugExtensionAvailable', true, { type: 'boolean', description: nls.localize('debugExtensionsAvailable', "True when there is at least one debug extension installed and enabled.") });
83
export const CONTEXT_DEBUG_PROTOCOL_VARIABLE_MENU_CONTEXT = new RawContextKey<string>('debugProtocolVariableMenuContext', undefined, { type: 'string', description: nls.localize('debugProtocolVariableMenuContext', "Represents the context the debug adapter sets on the focused variable in the VARIABLES view.") });
84
export const CONTEXT_SET_VARIABLE_SUPPORTED = new RawContextKey<boolean>('debugSetVariableSupported', false, { type: 'boolean', description: nls.localize('debugSetVariableSupported', "True when the focused session supports 'setVariable' request.") });
85
export const CONTEXT_SET_DATA_BREAKPOINT_BYTES_SUPPORTED = new RawContextKey<boolean>('debugSetDataBreakpointAddressSupported', false, { type: 'boolean', description: nls.localize('debugSetDataBreakpointAddressSupported', "True when the focused session supports 'getBreakpointInfo' request on an address.") });
86
export const CONTEXT_SET_EXPRESSION_SUPPORTED = new RawContextKey<boolean>('debugSetExpressionSupported', false, { type: 'boolean', description: nls.localize('debugSetExpressionSupported', "True when the focused session supports 'setExpression' request.") });
87
export const CONTEXT_BREAK_WHEN_VALUE_CHANGES_SUPPORTED = new RawContextKey<boolean>('breakWhenValueChangesSupported', false, { type: 'boolean', description: nls.localize('breakWhenValueChangesSupported', "True when the focused session supports to break when value changes.") });
88
export const CONTEXT_BREAK_WHEN_VALUE_IS_ACCESSED_SUPPORTED = new RawContextKey<boolean>('breakWhenValueIsAccessedSupported', false, { type: 'boolean', description: nls.localize('breakWhenValueIsAccessedSupported', "True when the focused breakpoint supports to break when value is accessed.") });
89
export const CONTEXT_BREAK_WHEN_VALUE_IS_READ_SUPPORTED = new RawContextKey<boolean>('breakWhenValueIsReadSupported', false, { type: 'boolean', description: nls.localize('breakWhenValueIsReadSupported', "True when the focused breakpoint supports to break when value is read.") });
90
export const CONTEXT_TERMINATE_DEBUGGEE_SUPPORTED = new RawContextKey<boolean>('terminateDebuggeeSupported', false, { type: 'boolean', description: nls.localize('terminateDebuggeeSupported', "True when the focused session supports the terminate debuggee capability.") });
91
export const CONTEXT_SUSPEND_DEBUGGEE_SUPPORTED = new RawContextKey<boolean>('suspendDebuggeeSupported', false, { type: 'boolean', description: nls.localize('suspendDebuggeeSupported', "True when the focused session supports the suspend debuggee capability.") });
92
export const CONTEXT_TERMINATE_THREADS_SUPPORTED = new RawContextKey<boolean>('terminateThreadsSupported', false, { type: 'boolean', description: nls.localize('terminateThreadsSupported', "True when the focused session supports the terminate threads capability.") });
93
export const CONTEXT_VARIABLE_EVALUATE_NAME_PRESENT = new RawContextKey<boolean>('variableEvaluateNamePresent', false, { type: 'boolean', description: nls.localize('variableEvaluateNamePresent', "True when the focused variable has an 'evalauteName' field set.") });
94
export const CONTEXT_VARIABLE_IS_READONLY = new RawContextKey<boolean>('variableIsReadonly', false, { type: 'boolean', description: nls.localize('variableIsReadonly', "True when the focused variable is read-only.") });
95
export const CONTEXT_VARIABLE_VALUE = new RawContextKey<boolean>('variableValue', false, { type: 'string', description: nls.localize('variableValue', "Value of the variable, present for debug visualization clauses.") });
96
export const CONTEXT_VARIABLE_TYPE = new RawContextKey<boolean>('variableType', false, { type: 'string', description: nls.localize('variableType', "Type of the variable, present for debug visualization clauses.") });
97
export const CONTEXT_VARIABLE_INTERFACES = new RawContextKey<boolean>('variableInterfaces', false, { type: 'array', description: nls.localize('variableInterfaces', "Any interfaces or contracts that the variable satisfies, present for debug visualization clauses.") });
98
export const CONTEXT_VARIABLE_NAME = new RawContextKey<boolean>('variableName', false, { type: 'string', description: nls.localize('variableName', "Name of the variable, present for debug visualization clauses.") });
99
export const CONTEXT_VARIABLE_LANGUAGE = new RawContextKey<boolean>('variableLanguage', false, { type: 'string', description: nls.localize('variableLanguage', "Language of the variable source, present for debug visualization clauses.") });
100
export const CONTEXT_VARIABLE_EXTENSIONID = new RawContextKey<boolean>('variableExtensionId', false, { type: 'string', description: nls.localize('variableExtensionId', "Extension ID of the variable source, present for debug visualization clauses.") });
101
export const CONTEXT_EXCEPTION_WIDGET_VISIBLE = new RawContextKey<boolean>('exceptionWidgetVisible', false, { type: 'boolean', description: nls.localize('exceptionWidgetVisible', "True when the exception widget is visible.") });
102
export const CONTEXT_MULTI_SESSION_REPL = new RawContextKey<boolean>('multiSessionRepl', false, { type: 'boolean', description: nls.localize('multiSessionRepl', "True when there is more than 1 debug console.") });
103
export const CONTEXT_MULTI_SESSION_DEBUG = new RawContextKey<boolean>('multiSessionDebug', false, { type: 'boolean', description: nls.localize('multiSessionDebug', "True when there is more than 1 active debug session.") });
104
export const CONTEXT_DISASSEMBLE_REQUEST_SUPPORTED = new RawContextKey<boolean>('disassembleRequestSupported', false, { type: 'boolean', description: nls.localize('disassembleRequestSupported', "True when the focused sessions supports disassemble request.") });
105
export const CONTEXT_DISASSEMBLY_VIEW_FOCUS = new RawContextKey<boolean>('disassemblyViewFocus', false, { type: 'boolean', description: nls.localize('disassemblyViewFocus', "True when the Disassembly View is focused.") });
106
export const CONTEXT_LANGUAGE_SUPPORTS_DISASSEMBLE_REQUEST = new RawContextKey<boolean>('languageSupportsDisassembleRequest', false, { type: 'boolean', description: nls.localize('languageSupportsDisassembleRequest', "True when the language in the current editor supports disassemble request.") });
107
export const CONTEXT_FOCUSED_STACK_FRAME_HAS_INSTRUCTION_POINTER_REFERENCE = new RawContextKey<boolean>('focusedStackFrameHasInstructionReference', false, { type: 'boolean', description: nls.localize('focusedStackFrameHasInstructionReference', "True when the focused stack frame has instruction pointer reference.") });
108
109
export const debuggerDisabledMessage = (debugType: string) => nls.localize('debuggerDisabled', "Configured debug type '{0}' is installed but not supported in this environment.", debugType);
110
111
export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug';
112
export const BREAKPOINT_EDITOR_CONTRIBUTION_ID = 'editor.contrib.breakpoint';
113
export const DEBUG_SCHEME = 'debug';
114
export const INTERNAL_CONSOLE_OPTIONS_SCHEMA = {
115
enum: ['neverOpen', 'openOnSessionStart', 'openOnFirstSessionStart'],
116
default: 'openOnFirstSessionStart',
117
description: nls.localize('internalConsoleOptions', "Controls when the internal Debug Console should open.")
118
};
119
120
export interface IDebugViewWithVariables extends IView {
121
readonly treeSelection: IExpression[];
122
}
123
124
// raw
125
126
export interface IRawModelUpdate {
127
sessionId: string;
128
threads: DebugProtocol.Thread[];
129
stoppedDetails?: IRawStoppedDetails;
130
}
131
132
export interface IRawStoppedDetails {
133
reason?: string;
134
description?: string;
135
threadId?: number;
136
text?: string;
137
totalFrames?: number;
138
allThreadsStopped?: boolean;
139
preserveFocusHint?: boolean;
140
framesErrorMessage?: string;
141
hitBreakpointIds?: number[];
142
}
143
144
// model
145
146
export interface ITreeElement {
147
getId(): string;
148
}
149
150
export interface IReplElement extends ITreeElement {
151
toString(includeSource?: boolean): string;
152
readonly sourceData?: IReplElementSource;
153
}
154
155
export interface INestingReplElement extends IReplElement {
156
readonly hasChildren: boolean;
157
getChildren(): Promise<IReplElement[]> | IReplElement[];
158
}
159
160
export interface IReplElementSource {
161
readonly source: Source;
162
readonly lineNumber: number;
163
readonly column: number;
164
}
165
166
export interface IExpressionValue {
167
readonly value: string;
168
readonly type?: string;
169
valueChanged?: boolean;
170
}
171
172
export interface IExpressionContainer extends ITreeElement, IExpressionValue {
173
readonly hasChildren: boolean;
174
getSession(): IDebugSession | undefined;
175
evaluateLazy(): Promise<void>;
176
getChildren(): Promise<IExpression[]>;
177
readonly reference?: number;
178
readonly memoryReference?: string;
179
readonly presentationHint?: DebugProtocol.VariablePresentationHint | undefined;
180
readonly valueLocationReference?: number;
181
}
182
183
export interface IExpression extends IExpressionContainer {
184
name: string;
185
}
186
187
export interface IDebugger {
188
readonly type: string;
189
createDebugAdapter(session: IDebugSession): Promise<IDebugAdapter>;
190
runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments, sessionId: string): Promise<number | undefined>;
191
startDebugging(args: IConfig, parentSessionId: string): Promise<boolean>;
192
getCustomTelemetryEndpoint(): ITelemetryEndpoint | undefined;
193
getInitialConfigurationContent(initialConfigs?: IConfig[]): Promise<string>;
194
}
195
196
export interface IDebuggerMetadata {
197
label: string;
198
type: string;
199
strings?: { [key in DebuggerString]: string };
200
interestedInLanguage(languageId: string): boolean;
201
}
202
203
export const enum State {
204
Inactive,
205
Initializing,
206
Stopped,
207
Running
208
}
209
210
export function getStateLabel(state: State): string {
211
switch (state) {
212
case State.Initializing: return 'initializing';
213
case State.Stopped: return 'stopped';
214
case State.Running: return 'running';
215
default: return 'inactive';
216
}
217
}
218
219
export interface AdapterEndEvent {
220
error?: Error;
221
sessionLengthInSeconds: number;
222
emittedStopped: boolean;
223
}
224
225
export interface LoadedSourceEvent {
226
reason: 'new' | 'changed' | 'removed';
227
source: Source;
228
}
229
230
export type IDebugSessionReplMode = 'separate' | 'mergeWithParent';
231
232
export interface IDebugTestRunReference {
233
runId: string;
234
taskId: string;
235
}
236
237
export interface IDebugSessionOptions {
238
noDebug?: boolean;
239
parentSession?: IDebugSession;
240
lifecycleManagedByParent?: boolean;
241
repl?: IDebugSessionReplMode;
242
compoundRoot?: DebugCompoundRoot;
243
compact?: boolean;
244
startedByUser?: boolean;
245
saveBeforeRestart?: boolean;
246
suppressDebugToolbar?: boolean;
247
suppressDebugStatusbar?: boolean;
248
suppressDebugView?: boolean;
249
/**
250
* Set if the debug session is correlated with a test run. Stopping/restarting
251
* the session will instead stop/restart the test run.
252
*/
253
testRun?: IDebugTestRunReference;
254
}
255
256
export interface IDataBreakpointInfoResponse {
257
dataId: string | null;
258
description: string;
259
canPersist?: boolean;
260
accessTypes?: DebugProtocol.DataBreakpointAccessType[];
261
}
262
263
export interface IMemoryInvalidationEvent {
264
fromOffset: number;
265
toOffset: number;
266
}
267
268
export const enum MemoryRangeType {
269
Valid,
270
Unreadable,
271
Error,
272
}
273
274
export interface IMemoryRange {
275
type: MemoryRangeType;
276
offset: number;
277
length: number;
278
}
279
280
export interface IValidMemoryRange extends IMemoryRange {
281
type: MemoryRangeType.Valid;
282
offset: number;
283
length: number;
284
data: VSBuffer;
285
}
286
287
export interface IUnreadableMemoryRange extends IMemoryRange {
288
type: MemoryRangeType.Unreadable;
289
}
290
291
export interface IErrorMemoryRange extends IMemoryRange {
292
type: MemoryRangeType.Error;
293
error: string;
294
}
295
296
/**
297
* Union type of memory that can be returned from read(). Since a read request
298
* could encompass multiple previously-read ranges, multiple of these types
299
* are possible to return.
300
*/
301
export type MemoryRange = IValidMemoryRange | IUnreadableMemoryRange | IErrorMemoryRange;
302
303
export const DEBUG_MEMORY_SCHEME = 'vscode-debug-memory';
304
305
/**
306
* An IMemoryRegion corresponds to a contiguous range of memory referred to
307
* by a DAP `memoryReference`.
308
*/
309
export interface IMemoryRegion extends IDisposable {
310
/**
311
* Event that fires when memory changes. Can be a result of memory events or
312
* `write` requests.
313
*/
314
readonly onDidInvalidate: Event<IMemoryInvalidationEvent>;
315
316
/**
317
* Whether writes are supported on this memory region.
318
*/
319
readonly writable: boolean;
320
321
/**
322
* Requests memory ranges from the debug adapter. It returns a list of memory
323
* ranges that overlap (but may exceed!) the given offset. Use the `offset`
324
* and `length` of each range for display.
325
*/
326
read(fromOffset: number, toOffset: number): Promise<MemoryRange[]>;
327
328
/**
329
* Writes memory to the debug adapter at the given offset.
330
*/
331
write(offset: number, data: VSBuffer): Promise<number>;
332
}
333
334
/** Data that can be inserted in {@link IDebugSession.appendToRepl} */
335
export interface INewReplElementData {
336
/**
337
* Output string to display
338
*/
339
output: string;
340
341
/**
342
* Expression data to display. Will result in the item being expandable in
343
* the REPL. Its value will be used if {@link output} is not provided.
344
*/
345
expression?: IExpression;
346
347
/**
348
* Output severity.
349
*/
350
sev: severity;
351
352
/**
353
* Originating location.
354
*/
355
source?: IReplElementSource;
356
}
357
358
export interface IDebugEvaluatePosition {
359
line: number;
360
column: number;
361
source: DebugProtocol.Source;
362
}
363
364
export interface IDebugLocationReferenced {
365
line: number;
366
column: number;
367
endLine?: number;
368
endColumn?: number;
369
source: Source;
370
}
371
372
export interface IDebugSession extends ITreeElement, IDisposable {
373
374
readonly configuration: IConfig;
375
readonly unresolvedConfiguration: IConfig | undefined;
376
readonly state: State;
377
readonly root: IWorkspaceFolder | undefined;
378
readonly parentSession: IDebugSession | undefined;
379
readonly subId: string | undefined;
380
readonly compact: boolean;
381
readonly compoundRoot: DebugCompoundRoot | undefined;
382
readonly saveBeforeRestart: boolean;
383
readonly name: string;
384
readonly autoExpandLazyVariables: boolean;
385
readonly suppressDebugToolbar: boolean;
386
readonly suppressDebugStatusbar: boolean;
387
readonly suppressDebugView: boolean;
388
readonly lifecycleManagedByParent: boolean;
389
/** Test run this debug session was spawned by */
390
readonly correlatedTestRun?: LiveTestResult;
391
392
setSubId(subId: string | undefined): void;
393
394
getMemory(memoryReference: string): IMemoryRegion;
395
396
setName(name: string): void;
397
readonly onDidChangeName: Event<string>;
398
getLabel(): string;
399
400
getSourceForUri(modelUri: uri): Source | undefined;
401
getSource(raw?: DebugProtocol.Source): Source;
402
403
setConfiguration(configuration: { resolved: IConfig; unresolved: IConfig | undefined }): void;
404
rawUpdate(data: IRawModelUpdate): void;
405
406
getThread(threadId: number): IThread | undefined;
407
getAllThreads(): IThread[];
408
clearThreads(removeThreads: boolean, reference?: number): void;
409
getStoppedDetails(): IRawStoppedDetails | undefined;
410
411
getReplElements(): IReplElement[];
412
hasSeparateRepl(): boolean;
413
removeReplExpressions(): void;
414
addReplExpression(stackFrame: IStackFrame | undefined, name: string): Promise<void>;
415
appendToRepl(data: INewReplElementData): void;
416
/** Cancel any associated test run set through the DebugSessionOptions */
417
cancelCorrelatedTestRun(): void;
418
419
// session events
420
readonly onDidEndAdapter: Event<AdapterEndEvent | undefined>;
421
readonly onDidChangeState: Event<void>;
422
readonly onDidChangeReplElements: Event<IReplElement | undefined>;
423
424
/** DA capabilities. Set only when there is a running session available. */
425
readonly capabilities: DebugProtocol.Capabilities;
426
/** DA capabilities. These are retained on the session even after is implementation ends. */
427
readonly rememberedCapabilities?: DebugProtocol.Capabilities;
428
429
// DAP events
430
431
readonly onDidLoadedSource: Event<LoadedSourceEvent>;
432
readonly onDidCustomEvent: Event<DebugProtocol.Event>;
433
readonly onDidProgressStart: Event<DebugProtocol.ProgressStartEvent>;
434
readonly onDidProgressUpdate: Event<DebugProtocol.ProgressUpdateEvent>;
435
readonly onDidProgressEnd: Event<DebugProtocol.ProgressEndEvent>;
436
readonly onDidInvalidateMemory: Event<DebugProtocol.MemoryEvent>;
437
438
// DAP request
439
440
initialize(dbgr: IDebugger): Promise<void>;
441
launchOrAttach(config: IConfig): Promise<void>;
442
restart(): Promise<void>;
443
terminate(restart?: boolean /* false */): Promise<void>;
444
disconnect(restart?: boolean /* false */, suspend?: boolean): Promise<void>;
445
446
sendBreakpoints(modelUri: uri, bpts: IBreakpoint[], sourceModified: boolean): Promise<void>;
447
sendFunctionBreakpoints(fbps: IFunctionBreakpoint[]): Promise<void>;
448
dataBreakpointInfo(name: string, variablesReference?: number): Promise<IDataBreakpointInfoResponse | undefined>;
449
dataBytesBreakpointInfo(address: string, bytes: number): Promise<IDataBreakpointInfoResponse | undefined>;
450
sendDataBreakpoints(dbps: IDataBreakpoint[]): Promise<void>;
451
sendInstructionBreakpoints(dbps: IInstructionBreakpoint[]): Promise<void>;
452
sendExceptionBreakpoints(exbpts: IExceptionBreakpoint[]): Promise<void>;
453
breakpointsLocations(uri: uri, lineNumber: number): Promise<IPosition[]>;
454
getDebugProtocolBreakpoint(breakpointId: string): DebugProtocol.Breakpoint | undefined;
455
resolveLocationReference(locationReference: number): Promise<IDebugLocationReferenced>;
456
457
stackTrace(threadId: number, startFrame: number, levels: number, token: CancellationToken): Promise<DebugProtocol.StackTraceResponse | undefined>;
458
exceptionInfo(threadId: number): Promise<IExceptionInfo | undefined>;
459
scopes(frameId: number, threadId: number): Promise<DebugProtocol.ScopesResponse | undefined>;
460
variables(variablesReference: number, threadId: number | undefined, filter: 'indexed' | 'named' | undefined, start: number | undefined, count: number | undefined): Promise<DebugProtocol.VariablesResponse | undefined>;
461
evaluate(expression: string, frameId?: number, context?: string, location?: IDebugEvaluatePosition): Promise<DebugProtocol.EvaluateResponse | undefined>;
462
customRequest(request: string, args: any): Promise<DebugProtocol.Response | undefined>;
463
cancel(progressId: string): Promise<DebugProtocol.CancelResponse | undefined>;
464
disassemble(memoryReference: string, offset: number, instructionOffset: number, instructionCount: number): Promise<DebugProtocol.DisassembledInstruction[] | undefined>;
465
readMemory(memoryReference: string, offset: number, count: number): Promise<DebugProtocol.ReadMemoryResponse | undefined>;
466
writeMemory(memoryReference: string, offset: number, data: string, allowPartial?: boolean): Promise<DebugProtocol.WriteMemoryResponse | undefined>;
467
468
restartFrame(frameId: number, threadId: number): Promise<void>;
469
next(threadId: number, granularity?: DebugProtocol.SteppingGranularity): Promise<void>;
470
stepIn(threadId: number, targetId?: number, granularity?: DebugProtocol.SteppingGranularity): Promise<void>;
471
stepInTargets(frameId: number): Promise<DebugProtocol.StepInTarget[] | undefined>;
472
stepOut(threadId: number, granularity?: DebugProtocol.SteppingGranularity): Promise<void>;
473
stepBack(threadId: number, granularity?: DebugProtocol.SteppingGranularity): Promise<void>;
474
continue(threadId: number): Promise<void>;
475
reverseContinue(threadId: number): Promise<void>;
476
pause(threadId: number): Promise<void>;
477
terminateThreads(threadIds: number[]): Promise<void>;
478
479
completions(frameId: number | undefined, threadId: number, text: string, position: Position, token: CancellationToken): Promise<DebugProtocol.CompletionsResponse | undefined>;
480
setVariable(variablesReference: number | undefined, name: string, value: string): Promise<DebugProtocol.SetVariableResponse | undefined>;
481
setExpression(frameId: number, expression: string, value: string): Promise<DebugProtocol.SetExpressionResponse | undefined>;
482
loadSource(resource: uri): Promise<DebugProtocol.SourceResponse | undefined>;
483
getLoadedSources(): Promise<Source[]>;
484
485
gotoTargets(source: DebugProtocol.Source, line: number, column?: number): Promise<DebugProtocol.GotoTargetsResponse | undefined>;
486
goto(threadId: number, targetId: number): Promise<DebugProtocol.GotoResponse | undefined>;
487
}
488
489
export interface IThread extends ITreeElement {
490
491
/**
492
* Process the thread belongs to
493
*/
494
readonly session: IDebugSession;
495
496
/**
497
* Id of the thread generated by the debug adapter backend.
498
*/
499
readonly threadId: number;
500
501
/**
502
* Name of the thread.
503
*/
504
readonly name: string;
505
506
/**
507
* Information about the current thread stop event. Undefined if thread is not stopped.
508
*/
509
readonly stoppedDetails: IRawStoppedDetails | undefined;
510
511
/**
512
* Information about the exception if an 'exception' stopped event raised and DA supports the 'exceptionInfo' request, otherwise undefined.
513
*/
514
readonly exceptionInfo: Promise<IExceptionInfo | undefined>;
515
516
readonly stateLabel: string;
517
518
/**
519
* Gets the callstack if it has already been received from the debug
520
* adapter.
521
*/
522
getCallStack(): ReadonlyArray<IStackFrame>;
523
524
525
/**
526
* Gets the top stack frame that is not hidden if the callstack has already been received from the debug adapter
527
*/
528
getTopStackFrame(): IStackFrame | undefined;
529
530
/**
531
* Invalidates the callstack cache
532
*/
533
clearCallStack(): void;
534
535
/**
536
* Indicates whether this thread is stopped. The callstack for stopped
537
* threads can be retrieved from the debug adapter.
538
*/
539
readonly stopped: boolean;
540
541
next(granularity?: DebugProtocol.SteppingGranularity): Promise<any>;
542
stepIn(granularity?: DebugProtocol.SteppingGranularity): Promise<any>;
543
stepOut(granularity?: DebugProtocol.SteppingGranularity): Promise<any>;
544
stepBack(granularity?: DebugProtocol.SteppingGranularity): Promise<any>;
545
continue(): Promise<any>;
546
pause(): Promise<any>;
547
terminate(): Promise<any>;
548
reverseContinue(): Promise<any>;
549
}
550
551
export interface IScope extends IExpressionContainer {
552
readonly name: string;
553
readonly expensive: boolean;
554
readonly range?: IRange;
555
readonly hasChildren: boolean;
556
}
557
558
export interface IStackFrame extends ITreeElement {
559
readonly thread: IThread;
560
readonly name: string;
561
readonly presentationHint: string | undefined;
562
readonly frameId: number;
563
readonly range: IRange;
564
readonly source: Source;
565
readonly canRestart: boolean;
566
readonly instructionPointerReference?: string;
567
getScopes(): Promise<IScope[]>;
568
getMostSpecificScopes(range: IRange): Promise<ReadonlyArray<IScope>>;
569
forgetScopes(): void;
570
restart(): Promise<any>;
571
toString(): string;
572
openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<IEditorPane | undefined>;
573
equals(other: IStackFrame): boolean;
574
}
575
576
export function isFrameDeemphasized(frame: IStackFrame): boolean {
577
const hint = frame.presentationHint ?? frame.source.presentationHint;
578
return hint === 'deemphasize' || hint === 'subtle';
579
}
580
581
export interface IEnablement extends ITreeElement {
582
readonly enabled: boolean;
583
}
584
585
export interface IBreakpointData {
586
readonly id?: string;
587
readonly lineNumber: number;
588
readonly column?: number;
589
readonly enabled?: boolean;
590
readonly condition?: string;
591
readonly logMessage?: string;
592
readonly hitCondition?: string;
593
readonly triggeredBy?: string;
594
readonly mode?: string;
595
readonly modeLabel?: string;
596
}
597
598
export interface IBreakpointUpdateData {
599
readonly condition?: string;
600
readonly hitCondition?: string;
601
readonly logMessage?: string;
602
readonly lineNumber?: number;
603
readonly column?: number;
604
readonly triggeredBy?: string;
605
readonly mode?: string;
606
readonly modeLabel?: string;
607
}
608
609
export interface IBaseBreakpoint extends IEnablement {
610
readonly condition?: string;
611
readonly hitCondition?: string;
612
readonly logMessage?: string;
613
readonly verified: boolean;
614
readonly supported: boolean;
615
readonly message?: string;
616
/** The preferred mode of the breakpoint from {@link DebugProtocol.BreakpointMode} */
617
readonly mode?: string;
618
/** The preferred mode label of the breakpoint from {@link DebugProtocol.BreakpointMode} */
619
readonly modeLabel?: string;
620
readonly sessionsThatVerified: string[];
621
getIdFromAdapter(sessionId: string): number | undefined;
622
}
623
624
export interface IBreakpoint extends IBaseBreakpoint {
625
/** URI where the breakpoint was first set by the user. */
626
readonly originalUri: uri;
627
/** URI where the breakpoint is currently shown; may be moved by debugger */
628
readonly uri: uri;
629
readonly lineNumber: number;
630
readonly endLineNumber?: number;
631
readonly column?: number;
632
readonly endColumn?: number;
633
readonly adapterData: any;
634
readonly sessionAgnosticData: { lineNumber: number; column: number | undefined };
635
/** An ID of the breakpoint that triggers this breakpoint. */
636
readonly triggeredBy?: string;
637
/** Pending on the trigger breakpoint, which means this breakpoint is not yet sent to DA */
638
readonly pending: boolean;
639
640
/** Marks that a session did trigger the breakpoint. */
641
setSessionDidTrigger(sessionId: string, didTrigger?: boolean): void;
642
/** Gets whether the `triggeredBy` condition has been met in the given sesison ID. */
643
getSessionDidTrigger(sessionId: string): boolean;
644
645
toDAP(): DebugProtocol.SourceBreakpoint;
646
}
647
648
export interface IFunctionBreakpoint extends IBaseBreakpoint {
649
readonly name: string;
650
toDAP(): DebugProtocol.FunctionBreakpoint;
651
}
652
653
export interface IExceptionBreakpoint extends IBaseBreakpoint {
654
readonly filter: string;
655
readonly label: string;
656
readonly description: string | undefined;
657
}
658
659
export const enum DataBreakpointSetType {
660
Variable,
661
Address,
662
}
663
664
/**
665
* Source for a data breakpoint. A data breakpoint on a variable always has a
666
* `dataId` because it cannot reference that variable globally, but addresses
667
* can request info repeated and use session-specific data.
668
*/
669
export type DataBreakpointSource =
670
| { type: DataBreakpointSetType.Variable; dataId: string }
671
| { type: DataBreakpointSetType.Address; address: string; bytes: number };
672
673
export interface IDataBreakpoint extends IBaseBreakpoint {
674
readonly description: string;
675
readonly canPersist: boolean;
676
readonly src: DataBreakpointSource;
677
readonly accessType: DebugProtocol.DataBreakpointAccessType;
678
toDAP(session: IDebugSession): Promise<DebugProtocol.DataBreakpoint | undefined>;
679
}
680
681
export interface IInstructionBreakpoint extends IBaseBreakpoint {
682
readonly instructionReference: string;
683
readonly offset?: number;
684
/** Original instruction memory address; display purposes only */
685
readonly address: bigint;
686
toDAP(): DebugProtocol.InstructionBreakpoint;
687
}
688
689
export interface IExceptionInfo {
690
readonly id?: string;
691
readonly description?: string;
692
readonly breakMode: string | null;
693
readonly details?: DebugProtocol.ExceptionDetails;
694
}
695
696
// model interfaces
697
698
export interface IViewModel extends ITreeElement {
699
/**
700
* Returns the focused debug session or undefined if no session is stopped.
701
*/
702
readonly focusedSession: IDebugSession | undefined;
703
704
/**
705
* Returns the focused thread or undefined if no thread is stopped.
706
*/
707
readonly focusedThread: IThread | undefined;
708
709
/**
710
* Returns the focused stack frame or undefined if there are no stack frames.
711
*/
712
readonly focusedStackFrame: IStackFrame | undefined;
713
714
setVisualizedExpression(original: IExpression, visualized: IExpression & { treeId: string } | undefined): void;
715
/** Returns the visualized expression if loaded, or a tree it should be visualized with, or undefined */
716
getVisualizedExpression(expression: IExpression): IExpression | string | undefined;
717
getSelectedExpression(): { expression: IExpression; settingWatch: boolean } | undefined;
718
setSelectedExpression(expression: IExpression | undefined, settingWatch: boolean): void;
719
updateViews(): void;
720
721
isMultiSessionView(): boolean;
722
723
onDidFocusSession: Event<IDebugSession | undefined>;
724
onDidFocusThread: Event<{ thread: IThread | undefined; explicit: boolean; session: IDebugSession | undefined }>;
725
onDidFocusStackFrame: Event<{ stackFrame: IStackFrame | undefined; explicit: boolean; session: IDebugSession | undefined }>;
726
onDidSelectExpression: Event<{ expression: IExpression; settingWatch: boolean } | undefined>;
727
onDidEvaluateLazyExpression: Event<IExpressionContainer>;
728
/**
729
* Fired when `setVisualizedExpression`, to migrate elements currently
730
* rendered as `original` to the `replacement`.
731
*/
732
onDidChangeVisualization: Event<{ original: IExpression; replacement: IExpression }>;
733
onWillUpdateViews: Event<void>;
734
735
evaluateLazyExpression(expression: IExpressionContainer): void;
736
}
737
738
export interface IEvaluate {
739
evaluate(session: IDebugSession, stackFrame: IStackFrame, context: string): Promise<void>;
740
}
741
742
export interface IDebugModel extends ITreeElement {
743
getSession(sessionId: string | undefined, includeInactive?: boolean): IDebugSession | undefined;
744
getSessions(includeInactive?: boolean): IDebugSession[];
745
getBreakpoints(filter?: { uri?: uri; originalUri?: uri; lineNumber?: number; column?: number; enabledOnly?: boolean; triggeredOnly?: boolean }): ReadonlyArray<IBreakpoint>;
746
areBreakpointsActivated(): boolean;
747
getFunctionBreakpoints(): ReadonlyArray<IFunctionBreakpoint>;
748
getDataBreakpoints(): ReadonlyArray<IDataBreakpoint>;
749
750
/**
751
* Returns list of all exception breakpoints.
752
*/
753
getExceptionBreakpoints(): ReadonlyArray<IExceptionBreakpoint>;
754
755
/**
756
* Returns list of exception breakpoints for the given session
757
* @param sessionId Session id. If falsy, returns the breakpoints from the last set fallback session.
758
*/
759
getExceptionBreakpointsForSession(sessionId?: string): ReadonlyArray<IExceptionBreakpoint>;
760
761
getInstructionBreakpoints(): ReadonlyArray<IInstructionBreakpoint>;
762
getWatchExpressions(): ReadonlyArray<IExpression & IEvaluate>;
763
registerBreakpointModes(debugType: string, modes: DebugProtocol.BreakpointMode[]): void;
764
getBreakpointModes(forBreakpointType: 'source' | 'exception' | 'data' | 'instruction'): DebugProtocol.BreakpointMode[];
765
onDidChangeBreakpoints: Event<IBreakpointsChangeEvent | undefined>;
766
onDidChangeCallStack: Event<void>;
767
/**
768
* The expression has been added, removed, or repositioned.
769
*/
770
onDidChangeWatchExpressions: Event<IExpression | undefined>;
771
/**
772
* The expression's value has changed.
773
*/
774
onDidChangeWatchExpressionValue: Event<IExpression | undefined>;
775
776
fetchCallstack(thread: IThread, levels?: number): Promise<void>;
777
}
778
779
/**
780
* An event describing a change to the set of [breakpoints](#debug.Breakpoint).
781
*/
782
export interface IBreakpointsChangeEvent {
783
added?: Array<IBreakpoint | IFunctionBreakpoint | IDataBreakpoint | IInstructionBreakpoint>;
784
removed?: Array<IBreakpoint | IFunctionBreakpoint | IDataBreakpoint | IInstructionBreakpoint>;
785
changed?: Array<IBreakpoint | IFunctionBreakpoint | IDataBreakpoint | IInstructionBreakpoint>;
786
sessionOnly: boolean;
787
}
788
789
// Debug configuration interfaces
790
791
export interface IDebugConfiguration {
792
allowBreakpointsEverywhere: boolean;
793
gutterMiddleClickAction: 'logpoint' | 'conditionalBreakpoint' | 'triggeredBreakpoint' | 'none';
794
openDebug: 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart' | 'openOnDebugBreak';
795
openExplorerOnEnd: boolean;
796
inlineValues: boolean | 'auto' | 'on' | 'off'; // boolean for back-compat
797
toolBarLocation: 'floating' | 'docked' | 'commandCenter' | 'hidden';
798
showInStatusBar: 'never' | 'always' | 'onFirstSessionStart';
799
internalConsoleOptions: 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart';
800
extensionHostDebugAdapter: boolean;
801
enableAllHovers: boolean;
802
showSubSessionsInToolBar: boolean;
803
closeReadonlyTabsOnEnd: boolean;
804
console: {
805
fontSize: number;
806
fontFamily: string;
807
lineHeight: number;
808
wordWrap: boolean;
809
closeOnEnd: boolean;
810
collapseIdenticalLines: boolean;
811
historySuggestions: boolean;
812
acceptSuggestionOnEnter: 'off' | 'on';
813
maximumLines: number;
814
};
815
focusWindowOnBreak: boolean;
816
focusEditorOnBreak: boolean;
817
onTaskErrors: 'debugAnyway' | 'showErrors' | 'prompt' | 'abort';
818
showBreakpointsInOverviewRuler: boolean;
819
showInlineBreakpointCandidates: boolean;
820
confirmOnExit: 'always' | 'never';
821
disassemblyView: {
822
showSourceCode: boolean;
823
};
824
autoExpandLazyVariables: 'auto' | 'off' | 'on';
825
enableStatusBarColor: boolean;
826
showVariableTypes: boolean;
827
hideSlowPreLaunchWarning: boolean;
828
}
829
830
export interface IGlobalConfig {
831
version: string;
832
compounds: ICompound[];
833
configurations: IConfig[];
834
}
835
836
interface IEnvConfig {
837
internalConsoleOptions?: 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart';
838
preRestartTask?: string | ITaskIdentifier;
839
postRestartTask?: string | ITaskIdentifier;
840
preLaunchTask?: string | ITaskIdentifier;
841
postDebugTask?: string | ITaskIdentifier;
842
debugServer?: number;
843
noDebug?: boolean;
844
suppressMultipleSessionWarning?: boolean;
845
}
846
847
export interface IConfigPresentation {
848
hidden?: boolean;
849
group?: string;
850
order?: number;
851
}
852
853
export interface IConfig extends IEnvConfig {
854
855
// fundamental attributes
856
type: string;
857
request: string;
858
name: string;
859
presentation?: IConfigPresentation;
860
// platform specifics
861
windows?: IEnvConfig;
862
osx?: IEnvConfig;
863
linux?: IEnvConfig;
864
865
// internals
866
__configurationTarget?: ConfigurationTarget;
867
__sessionId?: string;
868
__restart?: any;
869
__autoAttach?: boolean;
870
port?: number; // TODO
871
}
872
873
export interface ICompound {
874
name: string;
875
stopAll?: boolean;
876
preLaunchTask?: string | ITaskIdentifier;
877
configurations: (string | { name: string; folder: string })[];
878
presentation?: IConfigPresentation;
879
}
880
881
export interface IDebugAdapter extends IDisposable {
882
readonly onError: Event<Error>;
883
readonly onExit: Event<number | null>;
884
onRequest(callback: (request: DebugProtocol.Request) => void): void;
885
onEvent(callback: (event: DebugProtocol.Event) => void): void;
886
startSession(): Promise<void>;
887
sendMessage(message: DebugProtocol.ProtocolMessage): void;
888
sendResponse(response: DebugProtocol.Response): void;
889
sendRequest(command: string, args: any, clb: (result: DebugProtocol.Response) => void, timeout?: number): number;
890
stopSession(): Promise<void>;
891
}
892
893
export interface IDebugAdapterFactory extends ITerminalLauncher {
894
createDebugAdapter(session: IDebugSession): IDebugAdapter;
895
substituteVariables(folder: IWorkspaceFolder | undefined, config: IConfig): Promise<IConfig>;
896
}
897
898
export interface IDebugAdapterExecutableOptions {
899
cwd?: string;
900
env?: { [key: string]: string };
901
}
902
903
export interface IDebugAdapterExecutable {
904
readonly type: 'executable';
905
readonly command: string;
906
readonly args: string[];
907
readonly options?: IDebugAdapterExecutableOptions;
908
}
909
910
export interface IDebugAdapterServer {
911
readonly type: 'server';
912
readonly port: number;
913
readonly host?: string;
914
}
915
916
export interface IDebugAdapterNamedPipeServer {
917
readonly type: 'pipeServer';
918
readonly path: string;
919
}
920
921
export interface IDebugAdapterInlineImpl extends IDisposable {
922
readonly onDidSendMessage: Event<DebugProtocol.Message>;
923
handleMessage(message: DebugProtocol.Message): void;
924
}
925
926
export interface IDebugAdapterImpl {
927
readonly type: 'implementation';
928
}
929
930
export type IAdapterDescriptor = IDebugAdapterExecutable | IDebugAdapterServer | IDebugAdapterNamedPipeServer | IDebugAdapterImpl;
931
932
export interface IPlatformSpecificAdapterContribution {
933
program?: string;
934
args?: string[];
935
runtime?: string;
936
runtimeArgs?: string[];
937
}
938
939
export interface IDebuggerContribution extends IPlatformSpecificAdapterContribution {
940
type: string;
941
label?: string;
942
win?: IPlatformSpecificAdapterContribution;
943
winx86?: IPlatformSpecificAdapterContribution;
944
windows?: IPlatformSpecificAdapterContribution;
945
osx?: IPlatformSpecificAdapterContribution;
946
linux?: IPlatformSpecificAdapterContribution;
947
948
// internal
949
aiKey?: string;
950
951
// supported languages
952
languages?: string[];
953
954
// debug configuration support
955
configurationAttributes?: any;
956
initialConfigurations?: any[];
957
configurationSnippets?: IJSONSchemaSnippet[];
958
variables?: { [key: string]: string };
959
when?: string;
960
hiddenWhen?: string;
961
deprecated?: string;
962
strings?: { [key in DebuggerString]: string };
963
}
964
965
export interface IBreakpointContribution {
966
language: string;
967
when?: string;
968
}
969
970
export enum DebugConfigurationProviderTriggerKind {
971
/**
972
* `DebugConfigurationProvider.provideDebugConfigurations` is called to provide the initial debug configurations for a newly created launch.json.
973
*/
974
Initial = 1,
975
/**
976
* `DebugConfigurationProvider.provideDebugConfigurations` is called to provide dynamically generated debug configurations when the user asks for them through the UI (e.g. via the "Select and Start Debugging" command).
977
*/
978
Dynamic = 2
979
}
980
981
export interface IDebugConfigurationProvider {
982
readonly type: string;
983
readonly triggerKind: DebugConfigurationProviderTriggerKind;
984
resolveDebugConfiguration?(folderUri: uri | undefined, debugConfiguration: IConfig, token: CancellationToken): Promise<IConfig | null | undefined>;
985
resolveDebugConfigurationWithSubstitutedVariables?(folderUri: uri | undefined, debugConfiguration: IConfig, token: CancellationToken): Promise<IConfig | null | undefined>;
986
provideDebugConfigurations?(folderUri: uri | undefined, token: CancellationToken): Promise<IConfig[]>;
987
}
988
989
export interface IDebugAdapterDescriptorFactory {
990
readonly type: string;
991
createDebugAdapterDescriptor(session: IDebugSession): Promise<IAdapterDescriptor>;
992
}
993
994
interface ITerminalLauncher {
995
runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments, sessionId: string): Promise<number | undefined>;
996
}
997
998
export interface IConfigurationManager {
999
1000
/**
1001
* Returns an object containing the selected launch configuration and the selected configuration name. Both these fields can be null (no folder workspace).
1002
*/
1003
readonly selectedConfiguration: {
1004
launch: ILaunch | undefined;
1005
// Potentially activates extensions
1006
getConfig: () => Promise<IConfig | undefined>;
1007
name: string | undefined;
1008
// Type is used when matching dynamic configurations to their corresponding provider
1009
type: string | undefined;
1010
};
1011
1012
selectConfiguration(launch: ILaunch | undefined, name?: string, config?: IConfig, dynamicConfigOptions?: { type?: string }): Promise<void>;
1013
1014
getLaunches(): ReadonlyArray<ILaunch>;
1015
getLaunch(workspaceUri: uri | undefined): ILaunch | undefined;
1016
getAllConfigurations(): { launch: ILaunch; name: string; presentation?: IConfigPresentation }[];
1017
removeRecentDynamicConfigurations(name: string, type: string): void;
1018
getRecentDynamicConfigurations(): { name: string; type: string }[];
1019
1020
/**
1021
* Allows to register on change of selected debug configuration.
1022
*/
1023
onDidSelectConfiguration: Event<void>;
1024
1025
/**
1026
* Allows to register on change of selected debug configuration.
1027
*/
1028
onDidChangeConfigurationProviders: Event<void>;
1029
1030
hasDebugConfigurationProvider(debugType: string, triggerKind?: DebugConfigurationProviderTriggerKind): boolean;
1031
getDynamicProviders(): Promise<{ label: string; type: string; pick: () => Promise<{ launch: ILaunch; config: IConfig; label: string } | undefined> }[]>;
1032
getDynamicConfigurationsByType(type: string, token?: CancellationToken): Promise<{ launch: ILaunch; config: IConfig; label: string }[]>;
1033
1034
registerDebugConfigurationProvider(debugConfigurationProvider: IDebugConfigurationProvider): IDisposable;
1035
unregisterDebugConfigurationProvider(debugConfigurationProvider: IDebugConfigurationProvider): void;
1036
1037
resolveConfigurationByProviders(folderUri: uri | undefined, type: string | undefined, debugConfiguration: any, token: CancellationToken): Promise<any>;
1038
}
1039
1040
export enum DebuggerString {
1041
UnverifiedBreakpoints = 'unverifiedBreakpoints'
1042
}
1043
1044
export interface IAdapterManager {
1045
1046
onDidRegisterDebugger: Event<void>;
1047
1048
hasEnabledDebuggers(): boolean;
1049
getDebugAdapterDescriptor(session: IDebugSession): Promise<IAdapterDescriptor | undefined>;
1050
getDebuggerLabel(type: string): string | undefined;
1051
someDebuggerInterestedInLanguage(language: string): boolean;
1052
getDebugger(type: string): IDebuggerMetadata | undefined;
1053
1054
activateDebuggers(activationEvent: string, debugType?: string): Promise<void>;
1055
registerDebugAdapterFactory(debugTypes: string[], debugAdapterFactory: IDebugAdapterFactory): IDisposable;
1056
createDebugAdapter(session: IDebugSession): IDebugAdapter | undefined;
1057
registerDebugAdapterDescriptorFactory(debugAdapterDescriptorFactory: IDebugAdapterDescriptorFactory): IDisposable;
1058
unregisterDebugAdapterDescriptorFactory(debugAdapterDescriptorFactory: IDebugAdapterDescriptorFactory): void;
1059
1060
substituteVariables(debugType: string, folder: IWorkspaceFolder | undefined, config: IConfig): Promise<IConfig>;
1061
runInTerminal(debugType: string, args: DebugProtocol.RunInTerminalRequestArguments, sessionId: string): Promise<number | undefined>;
1062
getEnabledDebugger(type: string): (IDebugger & IDebuggerMetadata) | undefined;
1063
guessDebugger(gettingConfigurations: boolean): Promise<IGuessedDebugger | undefined>;
1064
1065
get onDidDebuggersExtPointRead(): Event<void>;
1066
}
1067
1068
export interface IGuessedDebugger {
1069
debugger: IDebugger;
1070
withConfig?: {
1071
label: string;
1072
launch: ILaunch;
1073
config: IConfig;
1074
};
1075
}
1076
1077
export interface ILaunch {
1078
1079
/**
1080
* Resource pointing to the launch.json this object is wrapping.
1081
*/
1082
readonly uri: uri;
1083
1084
/**
1085
* Name of the launch.
1086
*/
1087
readonly name: string;
1088
1089
/**
1090
* Workspace of the launch. Can be undefined.
1091
*/
1092
readonly workspace: IWorkspaceFolder | undefined;
1093
1094
/**
1095
* Should this launch be shown in the debug dropdown.
1096
*/
1097
readonly hidden: boolean;
1098
1099
/**
1100
* Returns a configuration with the specified name.
1101
* Returns undefined if there is no configuration with the specified name.
1102
*/
1103
getConfiguration(name: string): IConfig | undefined;
1104
1105
/**
1106
* Returns a compound with the specified name.
1107
* Returns undefined if there is no compound with the specified name.
1108
*/
1109
getCompound(name: string): ICompound | undefined;
1110
1111
/**
1112
* Returns the names of all configurations and compounds.
1113
* Ignores configurations which are invalid.
1114
*/
1115
getConfigurationNames(ignoreCompoundsAndPresentation?: boolean): string[];
1116
1117
/**
1118
* Opens the launch.json file. Creates if it does not exist.
1119
*/
1120
openConfigFile(options: { preserveFocus: boolean; type?: string; suppressInitialConfigs?: boolean }, token?: CancellationToken): Promise<{ editor: IEditorPane | null; created: boolean }>;
1121
}
1122
1123
// Debug service interfaces
1124
1125
export const IDebugService = createDecorator<IDebugService>('debugService');
1126
1127
export interface IDebugService {
1128
readonly _serviceBrand: undefined;
1129
1130
/**
1131
* Gets the current debug state.
1132
*/
1133
readonly state: State;
1134
1135
readonly initializingOptions?: IDebugSessionOptions | undefined;
1136
1137
/**
1138
* Allows to register on debug state changes.
1139
*/
1140
onDidChangeState: Event<State>;
1141
1142
/**
1143
* Allows to register on sessions about to be created (not yet fully initialised).
1144
* This is fired exactly one time for any given session.
1145
*/
1146
onWillNewSession: Event<IDebugSession>;
1147
1148
/**
1149
* Fired when a new debug session is started. This may fire multiple times
1150
* for a single session due to restarts.
1151
*/
1152
onDidNewSession: Event<IDebugSession>;
1153
1154
/**
1155
* Allows to register on end session events.
1156
*
1157
* Contains a boolean indicating whether the session will restart. If restart
1158
* is true, the session should not considered to be dead yet.
1159
*/
1160
onDidEndSession: Event<{ session: IDebugSession; restart: boolean }>;
1161
1162
/**
1163
* Gets the configuration manager.
1164
*/
1165
getConfigurationManager(): IConfigurationManager;
1166
1167
/**
1168
* Gets the adapter manager.
1169
*/
1170
getAdapterManager(): IAdapterManager;
1171
1172
/**
1173
* Sets the focused stack frame and evaluates all expressions against the newly focused stack frame,
1174
*/
1175
focusStackFrame(focusedStackFrame: IStackFrame | undefined, thread?: IThread, session?: IDebugSession, options?: { explicit?: boolean; preserveFocus?: boolean; sideBySide?: boolean; pinned?: boolean }): Promise<void>;
1176
1177
/**
1178
* Returns true if breakpoints can be set for a given editor model. Depends on mode.
1179
*/
1180
canSetBreakpointsIn(model: EditorIModel): boolean;
1181
1182
/**
1183
* Adds new breakpoints to the model for the file specified with the uri. Notifies debug adapter of breakpoint changes.
1184
*/
1185
addBreakpoints(uri: uri, rawBreakpoints: IBreakpointData[], ariaAnnounce?: boolean): Promise<IBreakpoint[]>;
1186
1187
/**
1188
* Updates the breakpoints.
1189
*/
1190
updateBreakpoints(originalUri: uri, data: Map<string, IBreakpointUpdateData>, sendOnResourceSaved: boolean): Promise<void>;
1191
1192
/**
1193
* Enables or disables all breakpoints. If breakpoint is passed only enables or disables the passed breakpoint.
1194
* Notifies debug adapter of breakpoint changes.
1195
*/
1196
enableOrDisableBreakpoints(enable: boolean, breakpoint?: IEnablement): Promise<void>;
1197
1198
/**
1199
* Sets the global activated property for all breakpoints.
1200
* Notifies debug adapter of breakpoint changes.
1201
*/
1202
setBreakpointsActivated(activated: boolean): Promise<void>;
1203
1204
/**
1205
* Removes all breakpoints. If id is passed only removes the breakpoint associated with that id.
1206
* Notifies debug adapter of breakpoint changes.
1207
*/
1208
removeBreakpoints(id?: string): Promise<any>;
1209
1210
/**
1211
* Adds a new function breakpoint for the given name.
1212
*/
1213
addFunctionBreakpoint(opts?: IFunctionBreakpointOptions, id?: string): void;
1214
1215
/**
1216
* Updates an already existing function breakpoint.
1217
* Notifies debug adapter of breakpoint changes.
1218
*/
1219
updateFunctionBreakpoint(id: string, update: { name?: string; hitCondition?: string; condition?: string }): Promise<void>;
1220
1221
/**
1222
* Removes all function breakpoints. If id is passed only removes the function breakpoint with the passed id.
1223
* Notifies debug adapter of breakpoint changes.
1224
*/
1225
removeFunctionBreakpoints(id?: string): Promise<void>;
1226
1227
/**
1228
* Adds a new data breakpoint.
1229
*/
1230
addDataBreakpoint(opts: IDataBreakpointOptions): Promise<void>;
1231
1232
/**
1233
* Updates an already existing data breakpoint.
1234
* Notifies debug adapter of breakpoint changes.
1235
*/
1236
updateDataBreakpoint(id: string, update: { hitCondition?: string; condition?: string }): Promise<void>;
1237
1238
/**
1239
* Removes all data breakpoints. If id is passed only removes the data breakpoint with the passed id.
1240
* Notifies debug adapter of breakpoint changes.
1241
*/
1242
removeDataBreakpoints(id?: string): Promise<void>;
1243
1244
/**
1245
* Adds a new instruction breakpoint.
1246
*/
1247
addInstructionBreakpoint(opts: IInstructionBreakpointOptions): Promise<void>;
1248
1249
/**
1250
* Removes all instruction breakpoints. If address is passed only removes the instruction breakpoint with the passed address.
1251
* The address should be the address string supplied by the debugger from the "Disassemble" request.
1252
* Notifies debug adapter of breakpoint changes.
1253
*/
1254
removeInstructionBreakpoints(instructionReference?: string, offset?: number): Promise<void>;
1255
1256
setExceptionBreakpointCondition(breakpoint: IExceptionBreakpoint, condition: string | undefined): Promise<void>;
1257
1258
/**
1259
* Creates breakpoints based on the sesison filter options. This will create
1260
* disabled breakpoints (or enabled, if the filter indicates it's a default)
1261
* for each filter provided in the session.
1262
*/
1263
setExceptionBreakpointsForSession(session: IDebugSession, filters: DebugProtocol.ExceptionBreakpointsFilter[]): void;
1264
1265
/**
1266
* Sends all breakpoints to the passed session.
1267
* If session is not passed, sends all breakpoints to each session.
1268
*/
1269
sendAllBreakpoints(session?: IDebugSession): Promise<any>;
1270
1271
/**
1272
* Sends breakpoints of the given source to the passed session.
1273
*/
1274
sendBreakpoints(modelUri: uri, sourceModified?: boolean, session?: IDebugSession): Promise<any>;
1275
1276
/**
1277
* Adds a new watch expression and evaluates it against the debug adapter.
1278
*/
1279
addWatchExpression(name?: string): void;
1280
1281
/**
1282
* Renames a watch expression and evaluates it against the debug adapter.
1283
*/
1284
renameWatchExpression(id: string, newName: string): void;
1285
1286
/**
1287
* Moves a watch expression to a new possition. Used for reordering watch expressions.
1288
*/
1289
moveWatchExpression(id: string, position: number): void;
1290
1291
/**
1292
* Removes all watch expressions. If id is passed only removes the watch expression with the passed id.
1293
*/
1294
removeWatchExpressions(id?: string): void;
1295
1296
/**
1297
* Starts debugging. If the configOrName is not passed uses the selected configuration in the debug dropdown.
1298
* Also saves all files, manages if compounds are present in the configuration
1299
* and resolveds configurations via DebugConfigurationProviders.
1300
*
1301
* Returns true if the start debugging was successful. For compound launches, all configurations have to start successfully for it to return success.
1302
* On errors the startDebugging will throw an error, however some error and cancelations are handled and in that case will simply return false.
1303
*/
1304
startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions, saveBeforeStart?: boolean): Promise<boolean>;
1305
1306
/**
1307
* Restarts a session or creates a new one if there is no active session.
1308
*/
1309
restartSession(session: IDebugSession, restartData?: any): Promise<any>;
1310
1311
/**
1312
* Stops the session. If no session is specified then all sessions are stopped.
1313
*/
1314
stopSession(session: IDebugSession | undefined, disconnect?: boolean, suspend?: boolean): Promise<any>;
1315
1316
/**
1317
* Makes unavailable all sources with the passed uri. Source will appear as grayed out in callstack view.
1318
*/
1319
sourceIsNotAvailable(uri: uri): void;
1320
1321
/**
1322
* Gets the current debug model.
1323
*/
1324
getModel(): IDebugModel;
1325
1326
/**
1327
* Gets the current view model.
1328
*/
1329
getViewModel(): IViewModel;
1330
1331
/**
1332
* Resumes execution and pauses until the given position is reached.
1333
*/
1334
runTo(uri: uri, lineNumber: number, column?: number): Promise<void>;
1335
}
1336
1337
// Editor interfaces
1338
export const enum BreakpointWidgetContext {
1339
CONDITION = 0,
1340
HIT_COUNT = 1,
1341
LOG_MESSAGE = 2,
1342
TRIGGER_POINT = 3
1343
}
1344
1345
export interface IDebugEditorContribution extends editorCommon.IEditorContribution {
1346
showHover(range: Position, focus: boolean): Promise<void>;
1347
addLaunchConfiguration(): Promise<any>;
1348
closeExceptionWidget(): void;
1349
}
1350
1351
export interface IBreakpointEditorContribution extends editorCommon.IEditorContribution {
1352
showBreakpointWidget(lineNumber: number, column: number | undefined, context?: BreakpointWidgetContext): void;
1353
closeBreakpointWidget(): void;
1354
getContextMenuActionsAtPosition(lineNumber: number, model: EditorIModel): IAction[];
1355
}
1356
1357
export interface IReplConfiguration {
1358
readonly fontSize: number;
1359
readonly fontFamily: string;
1360
readonly lineHeight: number;
1361
readonly cssLineHeight: string;
1362
readonly backgroundColor: Color | undefined;
1363
readonly fontSizeForTwistie: number;
1364
}
1365
1366
export interface IReplOptions {
1367
readonly replConfiguration: IReplConfiguration;
1368
}
1369
1370
export interface IDebugVisualizationContext {
1371
variable: DebugProtocol.Variable;
1372
containerId?: number;
1373
frameId?: number;
1374
threadId: number;
1375
sessionId: string;
1376
}
1377
1378
export const enum DebugVisualizationType {
1379
Command,
1380
Tree,
1381
}
1382
1383
export type MainThreadDebugVisualization =
1384
| { type: DebugVisualizationType.Command }
1385
| { type: DebugVisualizationType.Tree; id: string };
1386
1387
1388
export const enum DebugTreeItemCollapsibleState {
1389
None = 0,
1390
Collapsed = 1,
1391
Expanded = 2
1392
}
1393
1394
export interface IDebugVisualizationTreeItem {
1395
id: number;
1396
label: string;
1397
description?: string;
1398
collapsibleState: DebugTreeItemCollapsibleState;
1399
contextValue?: string;
1400
canEdit?: boolean;
1401
}
1402
1403
export namespace IDebugVisualizationTreeItem {
1404
export type Serialized = IDebugVisualizationTreeItem;
1405
export const deserialize = (v: Serialized): IDebugVisualizationTreeItem => v;
1406
export const serialize = (item: IDebugVisualizationTreeItem): Serialized => item;
1407
}
1408
1409
export interface IDebugVisualization {
1410
id: number;
1411
name: string;
1412
iconPath: { light?: URI; dark: URI } | undefined;
1413
iconClass: string | undefined;
1414
visualization: MainThreadDebugVisualization | undefined;
1415
}
1416
1417
export namespace IDebugVisualization {
1418
export interface Serialized {
1419
id: number;
1420
name: string;
1421
iconPath?: { light?: UriComponents; dark: UriComponents };
1422
iconClass?: string;
1423
visualization?: MainThreadDebugVisualization;
1424
}
1425
1426
export const deserialize = (v: Serialized): IDebugVisualization => ({
1427
id: v.id,
1428
name: v.name,
1429
iconPath: v.iconPath && { light: URI.revive(v.iconPath.light), dark: URI.revive(v.iconPath.dark) },
1430
iconClass: v.iconClass,
1431
visualization: v.visualization,
1432
});
1433
1434
export const serialize = (visualizer: IDebugVisualization): Serialized => visualizer;
1435
}
1436
1437