Path: blob/main/src/vs/workbench/contrib/debug/common/debug.ts
5227 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { IAction } from '../../../../base/common/actions.js';6import { VSBuffer } from '../../../../base/common/buffer.js';7import { CancellationToken } from '../../../../base/common/cancellation.js';8import { Color } from '../../../../base/common/color.js';9import { Event } from '../../../../base/common/event.js';10import { IJSONSchema, IJSONSchemaSnippet } from '../../../../base/common/jsonSchema.js';11import { IDisposable } from '../../../../base/common/lifecycle.js';12import severity from '../../../../base/common/severity.js';13import { URI, UriComponents, URI as uri } from '../../../../base/common/uri.js';14import { IPosition, Position } from '../../../../editor/common/core/position.js';15import { IRange } from '../../../../editor/common/core/range.js';16import * as editorCommon from '../../../../editor/common/editorCommon.js';17import { ITextModel as EditorIModel } from '../../../../editor/common/model.js';18import * as nls from '../../../../nls.js';19import { ConfigurationTarget } from '../../../../platform/configuration/common/configuration.js';20import { RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';21import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';22import { ITelemetryEndpoint } from '../../../../platform/telemetry/common/telemetry.js';23import { IWorkspaceFolder } from '../../../../platform/workspace/common/workspace.js';24import { IEditorPane } from '../../../common/editor.js';25import { DebugCompoundRoot } from './debugCompoundRoot.js';26import { IDataBreakpointOptions, IFunctionBreakpointOptions, IInstructionBreakpointOptions } from './debugModel.js';27import { Source } from './debugSource.js';28import { ITaskIdentifier } from '../../tasks/common/tasks.js';29import { LiveTestResult } from '../../testing/common/testResult.js';30import { IEditorService } from '../../../services/editor/common/editorService.js';31import { IView } from '../../../common/views.js';3233export const VIEWLET_ID = 'workbench.view.debug';3435export const VARIABLES_VIEW_ID = 'workbench.debug.variablesView';36export const WATCH_VIEW_ID = 'workbench.debug.watchExpressionsView';37export const CALLSTACK_VIEW_ID = 'workbench.debug.callStackView';38export const LOADED_SCRIPTS_VIEW_ID = 'workbench.debug.loadedScriptsView';39export const BREAKPOINTS_VIEW_ID = 'workbench.debug.breakPointsView';40export const DISASSEMBLY_VIEW_ID = 'workbench.debug.disassemblyView';41export const DEBUG_PANEL_ID = 'workbench.panel.repl';42export const REPL_VIEW_ID = 'workbench.panel.repl.view';43export 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'.") });44export 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'.") });45export 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'.") });46export const CONTEXT_DEBUG_UX_KEY = 'debugUx';47export 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.") });48export 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.") });49export const CONTEXT_IN_DEBUG_MODE = new RawContextKey<boolean>('inDebugMode', false, { type: 'boolean', description: nls.localize('inDebugMode', "True when debugging, false otherwise.") });50export 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.") });51export 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.") });52export 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.") });53export const CONTEXT_BREAKPOINTS_FOCUSED = new RawContextKey<boolean>('breakpointsFocused', true, { type: 'boolean', description: nls.localize('breakpointsFocused', "True when the BREAKPOINTS view is focused, false otherwise.") });54export 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.") });55export 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.") });56export const CONTEXT_VARIABLES_FOCUSED = new RawContextKey<boolean>('variablesFocused', true, { type: 'boolean', description: nls.localize('variablesFocused', "True when the VARIABLES views is focused, false otherwise") });57export 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.") });58export 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.") });59export 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'") });60export 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.") });61export 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.") });62export 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.") });63export const CONTEXT_CALLSTACK_FOCUSED = new RawContextKey<boolean>('callStackFocused', true, { type: 'boolean', description: nls.localize('callStackFocused', "True when the CALLSTACK view is focused, false otherwise.") });64export 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'") });65export 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.") });66export 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'") });67export 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.") });68export 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.") });69export const CONTEXT_BREAKPOINT_SUPPORTS_CONDITION = new RawContextKey<boolean>('breakpointSupportsCondition', false, { type: 'boolean', description: nls.localize('breakpointSupportsCondition', "True when the focused breakpoint supports conditions.") });70export 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") });71export 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.") });72export const CONTEXT_FOCUSED_SESSION_IS_ATTACH = new RawContextKey<boolean>('focusedSessionIsAttach', false, { type: 'boolean', description: nls.localize('focusedSessionIsAttach', "True when the focused session is 'attach'.") });73export 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.") });74export const CONTEXT_STEP_BACK_SUPPORTED = new RawContextKey<boolean>('stepBackSupported', false, { type: 'boolean', description: nls.localize('stepBackSupported', "True when the focused session supports 'stepBack' requests.") });75export const CONTEXT_RESTART_FRAME_SUPPORTED = new RawContextKey<boolean>('restartFrameSupported', false, { type: 'boolean', description: nls.localize('restartFrameSupported', "True when the focused session supports 'restartFrame' requests.") });76export 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'.") });77export 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.") });78export 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.") });79export const CONTEXT_BREAKPOINTS_EXIST = new RawContextKey<boolean>('breakpointsExist', false, { type: 'boolean', description: nls.localize('breakpointsExist', "True when at least one breakpoint exists.") });80export 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.") });81export 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.") });82export 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.") });83export const CONTEXT_SET_VARIABLE_SUPPORTED = new RawContextKey<boolean>('debugSetVariableSupported', false, { type: 'boolean', description: nls.localize('debugSetVariableSupported', "True when the focused session supports 'setVariable' request.") });84export 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.") });85export const CONTEXT_SET_EXPRESSION_SUPPORTED = new RawContextKey<boolean>('debugSetExpressionSupported', false, { type: 'boolean', description: nls.localize('debugSetExpressionSupported', "True when the focused session supports 'setExpression' request.") });86export 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.") });87export 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.") });88export 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.") });89export 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.") });90export 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.") });91export 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.") });92export 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.") });93export const CONTEXT_VARIABLE_IS_READONLY = new RawContextKey<boolean>('variableIsReadonly', false, { type: 'boolean', description: nls.localize('variableIsReadonly', "True when the focused variable is read-only.") });94export const CONTEXT_VARIABLE_VALUE = new RawContextKey<boolean>('variableValue', false, { type: 'string', description: nls.localize('variableValue', "Value of the variable, present for debug visualization clauses.") });95export const CONTEXT_VARIABLE_TYPE = new RawContextKey<boolean>('variableType', false, { type: 'string', description: nls.localize('variableType', "Type of the variable, present for debug visualization clauses.") });96export 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.") });97export const CONTEXT_VARIABLE_NAME = new RawContextKey<boolean>('variableName', false, { type: 'string', description: nls.localize('variableName', "Name of the variable, present for debug visualization clauses.") });98export 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.") });99export 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.") });100export const CONTEXT_EXCEPTION_WIDGET_VISIBLE = new RawContextKey<boolean>('exceptionWidgetVisible', false, { type: 'boolean', description: nls.localize('exceptionWidgetVisible', "True when the exception widget is visible.") });101export 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.") });102export 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.") });103export const CONTEXT_DISASSEMBLE_REQUEST_SUPPORTED = new RawContextKey<boolean>('disassembleRequestSupported', false, { type: 'boolean', description: nls.localize('disassembleRequestSupported', "True when the focused sessions supports disassemble request.") });104export const CONTEXT_DISASSEMBLY_VIEW_FOCUS = new RawContextKey<boolean>('disassemblyViewFocus', false, { type: 'boolean', description: nls.localize('disassemblyViewFocus', "True when the Disassembly View is focused.") });105export 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.") });106export 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.") });107108export const debuggerDisabledMessage = (debugType: string) => nls.localize('debuggerDisabled', "Configured debug type '{0}' is installed but not supported in this environment.", debugType);109110export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug';111export const BREAKPOINT_EDITOR_CONTRIBUTION_ID = 'editor.contrib.breakpoint';112export const DEBUG_SCHEME = 'debug';113export const INTERNAL_CONSOLE_OPTIONS_SCHEMA = {114enum: ['neverOpen', 'openOnSessionStart', 'openOnFirstSessionStart'],115default: 'openOnFirstSessionStart',116description: nls.localize('internalConsoleOptions', "Controls when the internal Debug Console should open.")117};118119export interface IDebugViewWithVariables extends IView {120readonly treeSelection: IExpression[];121}122123// raw124125export interface IRawModelUpdate {126sessionId: string;127threads: DebugProtocol.Thread[];128stoppedDetails?: IRawStoppedDetails;129}130131export interface IRawStoppedDetails {132reason?: string;133description?: string;134threadId?: number;135text?: string;136totalFrames?: number;137allThreadsStopped?: boolean;138preserveFocusHint?: boolean;139framesErrorMessage?: string;140hitBreakpointIds?: number[];141}142143// model144145export interface ITreeElement {146getId(): string;147}148149export interface IReplElement extends ITreeElement {150toString(includeSource?: boolean): string;151readonly sourceData?: IReplElementSource;152}153154export interface INestingReplElement extends IReplElement {155readonly hasChildren: boolean;156getChildren(): Promise<IReplElement[]> | IReplElement[];157}158159export interface IReplElementSource {160readonly source: Source;161readonly lineNumber: number;162readonly column: number;163}164165export interface IExpressionValue {166readonly value: string;167readonly type?: string;168valueChanged?: boolean;169}170171export interface IExpressionContainer extends ITreeElement, IExpressionValue {172readonly hasChildren: boolean;173getSession(): IDebugSession | undefined;174evaluateLazy(): Promise<void>;175getChildren(): Promise<IExpression[]>;176readonly reference?: number;177readonly memoryReference?: string;178readonly presentationHint?: DebugProtocol.VariablePresentationHint | undefined;179readonly valueLocationReference?: number;180}181182export interface IExpression extends IExpressionContainer {183name: string;184}185186export interface IDebugger {187readonly type: string;188createDebugAdapter(session: IDebugSession): Promise<IDebugAdapter>;189runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments, sessionId: string): Promise<number | undefined>;190startDebugging(args: IConfig, parentSessionId: string): Promise<boolean>;191getCustomTelemetryEndpoint(): ITelemetryEndpoint | undefined;192getInitialConfigurationContent(initialConfigs?: IConfig[]): Promise<string>;193}194195export interface IDebuggerMetadata {196label: string;197type: string;198strings?: { [key in DebuggerString]: string };199interestedInLanguage(languageId: string): boolean;200}201202export const enum State {203Inactive,204Initializing,205Stopped,206Running207}208209export function getStateLabel(state: State): string {210switch (state) {211case State.Initializing: return 'initializing';212case State.Stopped: return 'stopped';213case State.Running: return 'running';214default: return 'inactive';215}216}217218export interface AdapterEndEvent {219error?: Error;220sessionLengthInSeconds: number;221emittedStopped: boolean;222}223224export interface LoadedSourceEvent {225reason: 'new' | 'changed' | 'removed';226source: Source;227}228229export type IDebugSessionReplMode = 'separate' | 'mergeWithParent';230231export interface IDebugTestRunReference {232runId: string;233taskId: string;234}235236export interface IDebugSessionOptions {237noDebug?: boolean;238parentSession?: IDebugSession;239lifecycleManagedByParent?: boolean;240repl?: IDebugSessionReplMode;241compoundRoot?: DebugCompoundRoot;242compact?: boolean;243startedByUser?: boolean;244saveBeforeRestart?: boolean;245suppressDebugToolbar?: boolean;246suppressDebugStatusbar?: boolean;247suppressDebugView?: boolean;248/**249* Set if the debug session is correlated with a test run. Stopping/restarting250* the session will instead stop/restart the test run.251*/252testRun?: IDebugTestRunReference;253}254255export interface IDataBreakpointInfoResponse {256dataId: string | null;257description: string;258canPersist?: boolean;259accessTypes?: DebugProtocol.DataBreakpointAccessType[];260}261262export interface IMemoryInvalidationEvent {263fromOffset: number;264toOffset: number;265}266267export const enum MemoryRangeType {268Valid,269Unreadable,270Error,271}272273export interface IMemoryRange {274type: MemoryRangeType;275offset: number;276length: number;277}278279export interface IValidMemoryRange extends IMemoryRange {280type: MemoryRangeType.Valid;281offset: number;282length: number;283data: VSBuffer;284}285286export interface IUnreadableMemoryRange extends IMemoryRange {287type: MemoryRangeType.Unreadable;288}289290export interface IErrorMemoryRange extends IMemoryRange {291type: MemoryRangeType.Error;292error: string;293}294295/**296* Union type of memory that can be returned from read(). Since a read request297* could encompass multiple previously-read ranges, multiple of these types298* are possible to return.299*/300export type MemoryRange = IValidMemoryRange | IUnreadableMemoryRange | IErrorMemoryRange;301302export const DEBUG_MEMORY_SCHEME = 'vscode-debug-memory';303304/**305* An IMemoryRegion corresponds to a contiguous range of memory referred to306* by a DAP `memoryReference`.307*/308export interface IMemoryRegion extends IDisposable {309/**310* Event that fires when memory changes. Can be a result of memory events or311* `write` requests.312*/313readonly onDidInvalidate: Event<IMemoryInvalidationEvent>;314315/**316* Whether writes are supported on this memory region.317*/318readonly writable: boolean;319320/**321* Requests memory ranges from the debug adapter. It returns a list of memory322* ranges that overlap (but may exceed!) the given offset. Use the `offset`323* and `length` of each range for display.324*/325read(fromOffset: number, toOffset: number): Promise<MemoryRange[]>;326327/**328* Writes memory to the debug adapter at the given offset.329*/330write(offset: number, data: VSBuffer): Promise<number>;331}332333/** Data that can be inserted in {@link IDebugSession.appendToRepl} */334export interface INewReplElementData {335/**336* Output string to display337*/338output: string;339340/**341* Expression data to display. Will result in the item being expandable in342* the REPL. Its value will be used if {@link output} is not provided.343*/344expression?: IExpression;345346/**347* Output severity.348*/349sev: severity;350351/**352* Originating location.353*/354source?: IReplElementSource;355}356357export interface IDebugEvaluatePosition {358line: number;359column: number;360source: DebugProtocol.Source;361}362363export interface IDebugLocationReferenced {364line: number;365column: number;366endLine?: number;367endColumn?: number;368source: Source;369}370371export interface IDebugSession extends ITreeElement, IDisposable {372373readonly configuration: IConfig;374readonly unresolvedConfiguration: IConfig | undefined;375readonly state: State;376readonly root: IWorkspaceFolder | undefined;377readonly parentSession: IDebugSession | undefined;378readonly subId: string | undefined;379readonly compact: boolean;380readonly compoundRoot: DebugCompoundRoot | undefined;381readonly saveBeforeRestart: boolean;382readonly name: string;383readonly autoExpandLazyVariables: boolean;384readonly suppressDebugToolbar: boolean;385readonly suppressDebugStatusbar: boolean;386readonly suppressDebugView: boolean;387readonly lifecycleManagedByParent: boolean;388/** Test run this debug session was spawned by */389readonly correlatedTestRun?: LiveTestResult;390391setSubId(subId: string | undefined): void;392393getMemory(memoryReference: string): IMemoryRegion;394395setName(name: string): void;396readonly onDidChangeName: Event<string>;397getLabel(): string;398399getSourceForUri(modelUri: uri): Source | undefined;400getSource(raw?: DebugProtocol.Source): Source;401402setConfiguration(configuration: { resolved: IConfig; unresolved: IConfig | undefined }): void;403rawUpdate(data: IRawModelUpdate): void;404405getThread(threadId: number): IThread | undefined;406getAllThreads(): IThread[];407clearThreads(removeThreads: boolean, reference?: number): void;408getStoppedDetails(): IRawStoppedDetails | undefined;409410getReplElements(): IReplElement[];411hasSeparateRepl(): boolean;412removeReplExpressions(): void;413addReplExpression(stackFrame: IStackFrame | undefined, name: string): Promise<void>;414appendToRepl(data: INewReplElementData): void;415/** Cancel any associated test run set through the DebugSessionOptions */416cancelCorrelatedTestRun(): void;417418// session events419readonly onDidEndAdapter: Event<AdapterEndEvent | undefined>;420readonly onDidChangeState: Event<void>;421readonly onDidChangeReplElements: Event<IReplElement | undefined>;422423/** DA capabilities. Set only when there is a running session available. */424readonly capabilities: DebugProtocol.Capabilities;425/** DA capabilities. These are retained on the session even after is implementation ends. */426readonly rememberedCapabilities?: DebugProtocol.Capabilities;427428// DAP events429430readonly onDidLoadedSource: Event<LoadedSourceEvent>;431readonly onDidCustomEvent: Event<DebugProtocol.Event>;432readonly onDidProgressStart: Event<DebugProtocol.ProgressStartEvent>;433readonly onDidProgressUpdate: Event<DebugProtocol.ProgressUpdateEvent>;434readonly onDidProgressEnd: Event<DebugProtocol.ProgressEndEvent>;435readonly onDidInvalidateMemory: Event<DebugProtocol.MemoryEvent>;436437// DAP request438439initialize(dbgr: IDebugger): Promise<void>;440launchOrAttach(config: IConfig): Promise<void>;441restart(): Promise<void>;442terminate(restart?: boolean /* false */): Promise<void>;443disconnect(restart?: boolean /* false */, suspend?: boolean): Promise<void>;444445sendBreakpoints(modelUri: uri, bpts: IBreakpoint[], sourceModified: boolean): Promise<void>;446sendFunctionBreakpoints(fbps: IFunctionBreakpoint[]): Promise<void>;447dataBreakpointInfo(name: string, variablesReference?: number, frameId?: number): Promise<IDataBreakpointInfoResponse | undefined>;448dataBytesBreakpointInfo(address: string, bytes: number): Promise<IDataBreakpointInfoResponse | undefined>;449sendDataBreakpoints(dbps: IDataBreakpoint[]): Promise<void>;450sendInstructionBreakpoints(dbps: IInstructionBreakpoint[]): Promise<void>;451sendExceptionBreakpoints(exbpts: IExceptionBreakpoint[]): Promise<void>;452breakpointsLocations(uri: uri, lineNumber: number): Promise<IPosition[]>;453getDebugProtocolBreakpoint(breakpointId: string): DebugProtocol.Breakpoint | undefined;454resolveLocationReference(locationReference: number): Promise<IDebugLocationReferenced>;455456stackTrace(threadId: number, startFrame: number, levels: number, token: CancellationToken): Promise<DebugProtocol.StackTraceResponse | undefined>;457exceptionInfo(threadId: number): Promise<IExceptionInfo | undefined>;458scopes(frameId: number, threadId: number): Promise<DebugProtocol.ScopesResponse | undefined>;459variables(variablesReference: number, threadId: number | undefined, filter: 'indexed' | 'named' | undefined, start: number | undefined, count: number | undefined): Promise<DebugProtocol.VariablesResponse | undefined>;460evaluate(expression: string, frameId?: number, context?: string, location?: IDebugEvaluatePosition): Promise<DebugProtocol.EvaluateResponse | undefined>;461customRequest(request: string, args: unknown): Promise<DebugProtocol.Response | undefined>;462cancel(progressId: string): Promise<DebugProtocol.CancelResponse | undefined>;463disassemble(memoryReference: string, offset: number, instructionOffset: number, instructionCount: number): Promise<DebugProtocol.DisassembledInstruction[] | undefined>;464readMemory(memoryReference: string, offset: number, count: number): Promise<DebugProtocol.ReadMemoryResponse | undefined>;465writeMemory(memoryReference: string, offset: number, data: string, allowPartial?: boolean): Promise<DebugProtocol.WriteMemoryResponse | undefined>;466467restartFrame(frameId: number, threadId: number): Promise<void>;468next(threadId: number, granularity?: DebugProtocol.SteppingGranularity): Promise<void>;469stepIn(threadId: number, targetId?: number, granularity?: DebugProtocol.SteppingGranularity): Promise<void>;470stepInTargets(frameId: number): Promise<DebugProtocol.StepInTarget[] | undefined>;471stepOut(threadId: number, granularity?: DebugProtocol.SteppingGranularity): Promise<void>;472stepBack(threadId: number, granularity?: DebugProtocol.SteppingGranularity): Promise<void>;473continue(threadId: number): Promise<void>;474reverseContinue(threadId: number): Promise<void>;475pause(threadId: number): Promise<void>;476terminateThreads(threadIds: number[]): Promise<void>;477478completions(frameId: number | undefined, threadId: number, text: string, position: Position, token: CancellationToken): Promise<DebugProtocol.CompletionsResponse | undefined>;479setVariable(variablesReference: number | undefined, name: string, value: string): Promise<DebugProtocol.SetVariableResponse | undefined>;480setExpression(frameId: number, expression: string, value: string): Promise<DebugProtocol.SetExpressionResponse | undefined>;481loadSource(resource: uri): Promise<DebugProtocol.SourceResponse | undefined>;482getLoadedSources(): Promise<Source[]>;483484gotoTargets(source: DebugProtocol.Source, line: number, column?: number): Promise<DebugProtocol.GotoTargetsResponse | undefined>;485goto(threadId: number, targetId: number): Promise<DebugProtocol.GotoResponse | undefined>;486}487488export interface IThread extends ITreeElement {489490/**491* Process the thread belongs to492*/493readonly session: IDebugSession;494495/**496* Id of the thread generated by the debug adapter backend.497*/498readonly threadId: number;499500/**501* Name of the thread.502*/503readonly name: string;504505/**506* Information about the current thread stop event. Undefined if thread is not stopped.507*/508readonly stoppedDetails: IRawStoppedDetails | undefined;509510/**511* Information about the exception if an 'exception' stopped event raised and DA supports the 'exceptionInfo' request, otherwise undefined.512*/513readonly exceptionInfo: Promise<IExceptionInfo | undefined>;514515readonly stateLabel: string;516517/**518* Gets the callstack if it has already been received from the debug519* adapter.520*/521getCallStack(): ReadonlyArray<IStackFrame>;522523524/**525* Gets the top stack frame that is not hidden if the callstack has already been received from the debug adapter526*/527getTopStackFrame(): IStackFrame | undefined;528529/**530* Invalidates the callstack cache531*/532clearCallStack(): void;533534/**535* Indicates whether this thread is stopped. The callstack for stopped536* threads can be retrieved from the debug adapter.537*/538readonly stopped: boolean;539540next(granularity?: DebugProtocol.SteppingGranularity): Promise<void>;541stepIn(granularity?: DebugProtocol.SteppingGranularity): Promise<void>;542stepOut(granularity?: DebugProtocol.SteppingGranularity): Promise<void>;543stepBack(granularity?: DebugProtocol.SteppingGranularity): Promise<void>;544continue(): Promise<void>;545pause(): Promise<void>;546terminate(): Promise<void>;547reverseContinue(): Promise<void>;548}549550export interface IScope extends IExpressionContainer {551readonly name: string;552readonly expensive: boolean;553readonly range?: IRange;554readonly hasChildren: boolean;555readonly childrenHaveBeenLoaded: boolean;556}557558export interface IStackFrame extends ITreeElement {559readonly thread: IThread;560readonly name: string;561readonly presentationHint: string | undefined;562readonly frameId: number;563readonly range: IRange;564readonly source: Source;565readonly canRestart: boolean;566readonly instructionPointerReference?: string;567getScopes(): Promise<IScope[]>;568getMostSpecificScopes(range: IRange): Promise<ReadonlyArray<IScope>>;569forgetScopes(): void;570restart(): Promise<void>;571toString(): string;572openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<IEditorPane | undefined>;573equals(other: IStackFrame): boolean;574}575576export function isFrameDeemphasized(frame: IStackFrame): boolean {577const hint = frame.presentationHint ?? frame.source.presentationHint;578return hint === 'deemphasize' || hint === 'subtle';579}580581export interface IEnablement extends ITreeElement {582readonly enabled: boolean;583}584585export interface IBreakpointData {586readonly id?: string;587readonly lineNumber: number;588readonly column?: number;589readonly enabled?: boolean;590readonly condition?: string;591readonly logMessage?: string;592readonly hitCondition?: string;593readonly triggeredBy?: string;594readonly mode?: string;595readonly modeLabel?: string;596}597598export interface IBreakpointUpdateData {599readonly condition?: string;600readonly hitCondition?: string;601readonly logMessage?: string;602readonly lineNumber?: number;603readonly column?: number;604readonly triggeredBy?: string;605readonly mode?: string;606readonly modeLabel?: string;607}608609export interface IBaseBreakpoint extends IEnablement {610readonly condition?: string;611readonly hitCondition?: string;612readonly logMessage?: string;613readonly verified: boolean;614readonly supported: boolean;615readonly message?: string;616/** The preferred mode of the breakpoint from {@link DebugProtocol.BreakpointMode} */617readonly mode?: string;618/** The preferred mode label of the breakpoint from {@link DebugProtocol.BreakpointMode} */619readonly modeLabel?: string;620readonly sessionsThatVerified: string[];621getIdFromAdapter(sessionId: string): number | undefined;622}623624export interface IBreakpoint extends IBaseBreakpoint {625/** URI where the breakpoint was first set by the user. */626readonly originalUri: uri;627/** URI where the breakpoint is currently shown; may be moved by debugger */628readonly uri: uri;629readonly lineNumber: number;630readonly endLineNumber?: number;631readonly column?: number;632readonly endColumn?: number;633readonly adapterData: unknown;634readonly sessionAgnosticData: { lineNumber: number; column: number | undefined };635/** An ID of the breakpoint that triggers this breakpoint. */636readonly triggeredBy?: string;637/** Pending on the trigger breakpoint, which means this breakpoint is not yet sent to DA */638readonly pending: boolean;639640/** Marks that a session did trigger the breakpoint. */641setSessionDidTrigger(sessionId: string, didTrigger?: boolean): void;642/** Gets whether the `triggeredBy` condition has been met in the given sesison ID. */643getSessionDidTrigger(sessionId: string): boolean;644645toDAP(): DebugProtocol.SourceBreakpoint;646}647648export interface IFunctionBreakpoint extends IBaseBreakpoint {649readonly name: string;650toDAP(): DebugProtocol.FunctionBreakpoint;651}652653export interface IExceptionBreakpoint extends IBaseBreakpoint {654readonly filter: string;655readonly label: string;656readonly description: string | undefined;657}658659export const enum DataBreakpointSetType {660Variable,661Address,662}663664/**665* Source for a data breakpoint. A data breakpoint on a variable always has a666* `dataId` because it cannot reference that variable globally, but addresses667* can request info repeated and use session-specific data.668*/669export type DataBreakpointSource =670| { type: DataBreakpointSetType.Variable; dataId: string }671| { type: DataBreakpointSetType.Address; address: string; bytes: number };672673export interface IDataBreakpoint extends IBaseBreakpoint {674readonly description: string;675readonly canPersist: boolean;676readonly src: DataBreakpointSource;677readonly accessType: DebugProtocol.DataBreakpointAccessType;678toDAP(session: IDebugSession): Promise<DebugProtocol.DataBreakpoint | undefined>;679}680681export interface IInstructionBreakpoint extends IBaseBreakpoint {682readonly instructionReference: string;683readonly offset?: number;684/** Original instruction memory address; display purposes only */685readonly address: bigint;686toDAP(): DebugProtocol.InstructionBreakpoint;687}688689export interface IExceptionInfo {690readonly id?: string;691readonly description?: string;692readonly breakMode: string | null;693readonly details?: DebugProtocol.ExceptionDetails;694}695696// model interfaces697698export interface IViewModel extends ITreeElement {699/**700* Returns the focused debug session or undefined if no session is stopped.701*/702readonly focusedSession: IDebugSession | undefined;703704/**705* Returns the focused thread or undefined if no thread is stopped.706*/707readonly focusedThread: IThread | undefined;708709/**710* Returns the focused stack frame or undefined if there are no stack frames.711*/712readonly focusedStackFrame: IStackFrame | undefined;713714setVisualizedExpression(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 */716getVisualizedExpression(expression: IExpression): IExpression | string | undefined;717getSelectedExpression(): { expression: IExpression; settingWatch: boolean } | undefined;718setSelectedExpression(expression: IExpression | undefined, settingWatch: boolean): void;719updateViews(): void;720721isMultiSessionView(): boolean;722723readonly onDidFocusSession: Event<IDebugSession | undefined>;724readonly onDidFocusThread: Event<{ thread: IThread | undefined; explicit: boolean; session: IDebugSession | undefined }>;725readonly onDidFocusStackFrame: Event<{ stackFrame: IStackFrame | undefined; explicit: boolean; session: IDebugSession | undefined }>;726readonly onDidSelectExpression: Event<{ expression: IExpression; settingWatch: boolean } | undefined>;727readonly onDidEvaluateLazyExpression: Event<IExpressionContainer>;728/**729* Fired when `setVisualizedExpression`, to migrate elements currently730* rendered as `original` to the `replacement`.731*/732readonly onDidChangeVisualization: Event<{ original: IExpression; replacement: IExpression }>;733readonly onWillUpdateViews: Event<void>;734735evaluateLazyExpression(expression: IExpressionContainer): void;736}737738export interface IEvaluate {739evaluate(session: IDebugSession, stackFrame: IStackFrame, context: string): Promise<void>;740}741742export interface IDebugModel extends ITreeElement {743getSession(sessionId: string | undefined, includeInactive?: boolean): IDebugSession | undefined;744getSessions(includeInactive?: boolean): IDebugSession[];745getBreakpoints(filter?: { uri?: uri; originalUri?: uri; lineNumber?: number; column?: number; enabledOnly?: boolean; triggeredOnly?: boolean }): ReadonlyArray<IBreakpoint>;746areBreakpointsActivated(): boolean;747getFunctionBreakpoints(): ReadonlyArray<IFunctionBreakpoint>;748getDataBreakpoints(): ReadonlyArray<IDataBreakpoint>;749750/**751* Returns list of all exception breakpoints.752*/753getExceptionBreakpoints(): ReadonlyArray<IExceptionBreakpoint>;754755/**756* Returns list of exception breakpoints for the given session757* @param sessionId Session id. If falsy, returns the breakpoints from the last set fallback session.758*/759getExceptionBreakpointsForSession(sessionId?: string): ReadonlyArray<IExceptionBreakpoint>;760761getInstructionBreakpoints(): ReadonlyArray<IInstructionBreakpoint>;762getWatchExpressions(): ReadonlyArray<IExpression & IEvaluate>;763registerBreakpointModes(debugType: string, modes: DebugProtocol.BreakpointMode[]): void;764getBreakpointModes(forBreakpointType: 'source' | 'exception' | 'data' | 'instruction'): DebugProtocol.BreakpointMode[];765readonly onDidChangeBreakpoints: Event<IBreakpointsChangeEvent | undefined>;766readonly onDidChangeCallStack: Event<void>;767/**768* The expression has been added, removed, or repositioned.769*/770readonly onDidChangeWatchExpressions: Event<IExpression | undefined>;771/**772* The expression's value has changed.773*/774readonly onDidChangeWatchExpressionValue: Event<IExpression | undefined>;775776fetchCallstack(thread: IThread, levels?: number): Promise<void>;777}778779/**780* An event describing a change to the set of [breakpoints](#debug.Breakpoint).781*/782export interface IBreakpointsChangeEvent {783added?: Array<IBreakpoint | IFunctionBreakpoint | IDataBreakpoint | IInstructionBreakpoint>;784removed?: Array<IBreakpoint | IFunctionBreakpoint | IDataBreakpoint | IInstructionBreakpoint>;785changed?: Array<IBreakpoint | IFunctionBreakpoint | IDataBreakpoint | IInstructionBreakpoint>;786sessionOnly: boolean;787}788789// Debug configuration interfaces790791export interface IDebugConfiguration {792allowBreakpointsEverywhere: boolean;793gutterMiddleClickAction: 'logpoint' | 'conditionalBreakpoint' | 'triggeredBreakpoint' | 'none';794openDebug: 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart' | 'openOnDebugBreak';795openExplorerOnEnd: boolean;796inlineValues: boolean | 'auto' | 'on' | 'off'; // boolean for back-compat797toolBarLocation: 'floating' | 'docked' | 'commandCenter' | 'hidden';798showInStatusBar: 'never' | 'always' | 'onFirstSessionStart';799internalConsoleOptions: 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart';800extensionHostDebugAdapter: boolean;801enableAllHovers: boolean;802showSubSessionsInToolBar: boolean;803closeReadonlyTabsOnEnd: boolean;804console: {805fontSize: number;806fontFamily: string;807lineHeight: number;808wordWrap: boolean;809closeOnEnd: boolean;810collapseIdenticalLines: boolean;811historySuggestions: boolean;812acceptSuggestionOnEnter: 'off' | 'on';813maximumLines: number;814};815focusWindowOnBreak: boolean;816focusEditorOnBreak: boolean;817onTaskErrors: 'debugAnyway' | 'showErrors' | 'prompt' | 'abort';818showBreakpointsInOverviewRuler: boolean;819showInlineBreakpointCandidates: boolean;820confirmOnExit: 'always' | 'never';821disassemblyView: {822showSourceCode: boolean;823};824autoExpandLazyVariables: 'auto' | 'off' | 'on';825enableStatusBarColor: boolean;826showVariableTypes: boolean;827hideSlowPreLaunchWarning: boolean;828}829830export interface IGlobalConfig {831version: string;832compounds: ICompound[];833configurations: IConfig[];834}835836interface IEnvConfig {837internalConsoleOptions?: 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart';838preRestartTask?: string | ITaskIdentifier;839postRestartTask?: string | ITaskIdentifier;840preLaunchTask?: string | ITaskIdentifier;841postDebugTask?: string | ITaskIdentifier;842debugServer?: number;843noDebug?: boolean;844suppressMultipleSessionWarning?: boolean;845}846847export interface IConfigPresentation {848hidden?: boolean;849group?: string;850order?: number;851}852853export interface IConfig extends IEnvConfig {854855// fundamental attributes856type: string;857request: string;858name: string;859presentation?: IConfigPresentation;860// platform specifics861windows?: IEnvConfig;862osx?: IEnvConfig;863linux?: IEnvConfig;864865// internals866__configurationTarget?: ConfigurationTarget;867__sessionId?: string;868__restart?: unknown;869__autoAttach?: boolean;870port?: number; // TODO871}872873export interface ICompound {874name: string;875stopAll?: boolean;876preLaunchTask?: string | ITaskIdentifier;877configurations: (string | { name: string; folder: string })[];878presentation?: IConfigPresentation;879}880881export interface IDebugAdapter extends IDisposable {882readonly onError: Event<Error>;883readonly onExit: Event<number | null>;884onRequest(callback: (request: DebugProtocol.Request) => void): void;885onEvent(callback: (event: DebugProtocol.Event) => void): void;886startSession(): Promise<void>;887sendMessage(message: DebugProtocol.ProtocolMessage): void;888sendResponse(response: DebugProtocol.Response): void;889sendRequest(command: string, args: unknown, clb: (result: DebugProtocol.Response) => void, timeout?: number): number;890stopSession(): Promise<void>;891}892893export interface IDebugAdapterFactory extends ITerminalLauncher {894createDebugAdapter(session: IDebugSession): IDebugAdapter;895substituteVariables(folder: IWorkspaceFolder | undefined, config: IConfig): Promise<IConfig>;896}897898export interface IDebugAdapterExecutableOptions {899cwd?: string;900env?: { [key: string]: string };901}902903export interface IDebugAdapterExecutable {904readonly type: 'executable';905readonly command: string;906readonly args: string[];907readonly options?: IDebugAdapterExecutableOptions;908}909910export interface IDebugAdapterServer {911readonly type: 'server';912readonly port: number;913readonly host?: string;914}915916export interface IDebugAdapterNamedPipeServer {917readonly type: 'pipeServer';918readonly path: string;919}920921export interface IDebugAdapterInlineImpl extends IDisposable {922readonly onDidSendMessage: Event<DebugProtocol.Message>;923handleMessage(message: DebugProtocol.Message): void;924}925926export interface IDebugAdapterImpl {927readonly type: 'implementation';928}929930export type IAdapterDescriptor = IDebugAdapterExecutable | IDebugAdapterServer | IDebugAdapterNamedPipeServer | IDebugAdapterImpl;931932export interface IPlatformSpecificAdapterContribution {933program?: string;934args?: string[];935runtime?: string;936runtimeArgs?: string[];937}938939export interface IDebuggerContribution extends IPlatformSpecificAdapterContribution {940type: string;941label?: string;942win?: IPlatformSpecificAdapterContribution;943winx86?: IPlatformSpecificAdapterContribution;944windows?: IPlatformSpecificAdapterContribution;945osx?: IPlatformSpecificAdapterContribution;946linux?: IPlatformSpecificAdapterContribution;947948// internal949aiKey?: string;950951// supported languages952languages?: string[];953954// debug configuration support955configurationAttributes?: Record<string, IJSONSchema>;956initialConfigurations?: unknown[];957configurationSnippets?: IJSONSchemaSnippet[];958variables?: { [key: string]: string };959when?: string;960hiddenWhen?: string;961deprecated?: string;962strings?: { [key in DebuggerString]: string };963/** @deprecated */964uiMessages?: { [key in DebuggerString]: string };965}966967export interface IBreakpointContribution {968language: string;969when?: string;970}971972export enum DebugConfigurationProviderTriggerKind {973/**974* `DebugConfigurationProvider.provideDebugConfigurations` is called to provide the initial debug configurations for a newly created launch.json.975*/976Initial = 1,977/**978* `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).979*/980Dynamic = 2981}982983export interface IDebugConfigurationProvider {984readonly type: string;985readonly triggerKind: DebugConfigurationProviderTriggerKind;986resolveDebugConfiguration?(folderUri: uri | undefined, debugConfiguration: IConfig, token: CancellationToken): Promise<IConfig | null | undefined>;987resolveDebugConfigurationWithSubstitutedVariables?(folderUri: uri | undefined, debugConfiguration: IConfig, token: CancellationToken): Promise<IConfig | null | undefined>;988provideDebugConfigurations?(folderUri: uri | undefined, token: CancellationToken): Promise<IConfig[]>;989}990991export interface IDebugAdapterDescriptorFactory {992readonly type: string;993createDebugAdapterDescriptor(session: IDebugSession): Promise<IAdapterDescriptor>;994}995996interface ITerminalLauncher {997runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments, sessionId: string): Promise<number | undefined>;998}9991000export interface IConfigurationManager {10011002/**1003* Returns an object containing the selected launch configuration and the selected configuration name. Both these fields can be null (no folder workspace).1004*/1005readonly selectedConfiguration: {1006launch: ILaunch | undefined;1007// Potentially activates extensions1008getConfig: () => Promise<IConfig | undefined>;1009name: string | undefined;1010// Type is used when matching dynamic configurations to their corresponding provider1011type: string | undefined;1012};10131014selectConfiguration(launch: ILaunch | undefined, name?: string, config?: IConfig, dynamicConfigOptions?: { type?: string }): Promise<void>;10151016getLaunches(): ReadonlyArray<ILaunch>;1017getLaunch(workspaceUri: uri | undefined): ILaunch | undefined;1018getAllConfigurations(): { launch: ILaunch; name: string; presentation?: IConfigPresentation }[];1019removeRecentDynamicConfigurations(name: string, type: string): void;1020getRecentDynamicConfigurations(): { name: string; type: string }[];10211022/**1023* Allows to register on change of selected debug configuration.1024*/1025readonly onDidSelectConfiguration: Event<void>;10261027/**1028* Allows to register on change of selected debug configuration.1029*/1030readonly onDidChangeConfigurationProviders: Event<void>;10311032hasDebugConfigurationProvider(debugType: string, triggerKind?: DebugConfigurationProviderTriggerKind): boolean;1033getDynamicProviders(): Promise<{ label: string; type: string; pick: () => Promise<{ launch: ILaunch; config: IConfig; label: string } | undefined> }[]>;1034getDynamicConfigurationsByType(type: string, token?: CancellationToken): Promise<{ launch: ILaunch; config: IConfig; label: string }[]>;10351036registerDebugConfigurationProvider(debugConfigurationProvider: IDebugConfigurationProvider): IDisposable;1037unregisterDebugConfigurationProvider(debugConfigurationProvider: IDebugConfigurationProvider): void;10381039resolveConfigurationByProviders(folderUri: uri | undefined, type: string | undefined, debugConfiguration: unknown, token: CancellationToken): Promise<IConfig | null | undefined>;1040}10411042export enum DebuggerString {1043UnverifiedBreakpoints = 'unverifiedBreakpoints'1044}10451046export interface IAdapterManager {10471048readonly onDidRegisterDebugger: Event<void>;10491050hasEnabledDebuggers(): boolean;1051getDebugAdapterDescriptor(session: IDebugSession): Promise<IAdapterDescriptor | undefined>;1052getDebuggerLabel(type: string): string | undefined;1053someDebuggerInterestedInLanguage(language: string): boolean;1054getDebugger(type: string): IDebuggerMetadata | undefined;10551056activateDebuggers(activationEvent: string, debugType?: string): Promise<void>;1057registerDebugAdapterFactory(debugTypes: string[], debugAdapterFactory: IDebugAdapterFactory): IDisposable;1058createDebugAdapter(session: IDebugSession): IDebugAdapter | undefined;1059registerDebugAdapterDescriptorFactory(debugAdapterDescriptorFactory: IDebugAdapterDescriptorFactory): IDisposable;1060unregisterDebugAdapterDescriptorFactory(debugAdapterDescriptorFactory: IDebugAdapterDescriptorFactory): void;10611062substituteVariables(debugType: string, folder: IWorkspaceFolder | undefined, config: IConfig): Promise<IConfig>;1063runInTerminal(debugType: string, args: DebugProtocol.RunInTerminalRequestArguments, sessionId: string): Promise<number | undefined>;1064getEnabledDebugger(type: string): (IDebugger & IDebuggerMetadata) | undefined;1065guessDebugger(gettingConfigurations: boolean): Promise<IGuessedDebugger | undefined>;10661067get onDidDebuggersExtPointRead(): Event<void>;1068}10691070export interface IGuessedDebugger {1071debugger: IDebugger;1072withConfig?: {1073label: string;1074launch: ILaunch;1075config: IConfig;1076};1077}10781079export interface ILaunch {10801081/**1082* Resource pointing to the launch.json this object is wrapping.1083*/1084readonly uri: uri;10851086/**1087* Name of the launch.1088*/1089readonly name: string;10901091/**1092* Workspace of the launch. Can be undefined.1093*/1094readonly workspace: IWorkspaceFolder | undefined;10951096/**1097* Should this launch be shown in the debug dropdown.1098*/1099readonly hidden: boolean;11001101/**1102* Returns a configuration with the specified name.1103* Returns undefined if there is no configuration with the specified name.1104*/1105getConfiguration(name: string): IConfig | undefined;11061107/**1108* Returns a compound with the specified name.1109* Returns undefined if there is no compound with the specified name.1110*/1111getCompound(name: string): ICompound | undefined;11121113/**1114* Returns the names of all configurations and compounds.1115* Ignores configurations which are invalid.1116*/1117getConfigurationNames(ignoreCompoundsAndPresentation?: boolean): string[];11181119/**1120* Opens the launch.json file. Creates if it does not exist.1121*/1122openConfigFile(options: { preserveFocus: boolean; type?: string; suppressInitialConfigs?: boolean }, token?: CancellationToken): Promise<{ editor: IEditorPane | null; created: boolean }>;1123}11241125// Debug service interfaces11261127export const IDebugService = createDecorator<IDebugService>('debugService');11281129export interface IDebugService {1130readonly _serviceBrand: undefined;11311132/**1133* Gets the current debug state.1134*/1135readonly state: State;11361137readonly initializingOptions?: IDebugSessionOptions | undefined;11381139/**1140* Allows to register on debug state changes.1141*/1142readonly onDidChangeState: Event<State>;11431144/**1145* Allows to register on sessions about to be created (not yet fully initialised).1146* This is fired exactly one time for any given session.1147*/1148readonly onWillNewSession: Event<IDebugSession>;11491150/**1151* Fired when a new debug session is started. This may fire multiple times1152* for a single session due to restarts.1153*/1154readonly onDidNewSession: Event<IDebugSession>;11551156/**1157* Allows to register on end session events.1158*1159* Contains a boolean indicating whether the session will restart. If restart1160* is true, the session should not considered to be dead yet.1161*/1162readonly onDidEndSession: Event<{ session: IDebugSession; restart: boolean }>;11631164/**1165* Gets the configuration manager.1166*/1167getConfigurationManager(): IConfigurationManager;11681169/**1170* Gets the adapter manager.1171*/1172getAdapterManager(): IAdapterManager;11731174/**1175* Sets the focused stack frame and evaluates all expressions against the newly focused stack frame,1176*/1177focusStackFrame(focusedStackFrame: IStackFrame | undefined, thread?: IThread, session?: IDebugSession, options?: { explicit?: boolean; preserveFocus?: boolean; sideBySide?: boolean; pinned?: boolean }): Promise<void>;11781179/**1180* Returns true if breakpoints can be set for a given editor model. Depends on mode.1181*/1182canSetBreakpointsIn(model: EditorIModel): boolean;11831184/**1185* Adds new breakpoints to the model for the file specified with the uri. Notifies debug adapter of breakpoint changes.1186*/1187addBreakpoints(uri: uri, rawBreakpoints: IBreakpointData[], ariaAnnounce?: boolean): Promise<IBreakpoint[]>;11881189/**1190* Updates the breakpoints.1191*/1192updateBreakpoints(originalUri: uri, data: Map<string, IBreakpointUpdateData>, sendOnResourceSaved: boolean): Promise<void>;11931194/**1195* Enables or disables all breakpoints. If breakpoint is passed only enables or disables the passed breakpoint.1196* Notifies debug adapter of breakpoint changes.1197*/1198enableOrDisableBreakpoints(enable: boolean, breakpoint?: IEnablement): Promise<void>;11991200/**1201* Sets the global activated property for all breakpoints.1202* Notifies debug adapter of breakpoint changes.1203*/1204setBreakpointsActivated(activated: boolean): Promise<void>;12051206/**1207* Removes all breakpoints. If id is passed only removes the breakpoint associated with that id.1208* Notifies debug adapter of breakpoint changes.1209*/1210removeBreakpoints(id?: string | string[]): Promise<void>;12111212/**1213* Adds a new function breakpoint for the given name.1214*/1215addFunctionBreakpoint(opts?: IFunctionBreakpointOptions, id?: string): void;12161217/**1218* Updates an already existing function breakpoint.1219* Notifies debug adapter of breakpoint changes.1220*/1221updateFunctionBreakpoint(id: string, update: { name?: string; hitCondition?: string; condition?: string }): Promise<void>;12221223/**1224* Removes all function breakpoints. If id is passed only removes the function breakpoint with the passed id.1225* Notifies debug adapter of breakpoint changes.1226*/1227removeFunctionBreakpoints(id?: string): Promise<void>;12281229/**1230* Adds a new data breakpoint.1231*/1232addDataBreakpoint(opts: IDataBreakpointOptions): Promise<void>;12331234/**1235* Updates an already existing data breakpoint.1236* Notifies debug adapter of breakpoint changes.1237*/1238updateDataBreakpoint(id: string, update: { hitCondition?: string; condition?: string }): Promise<void>;12391240/**1241* Removes all data breakpoints. If id is passed only removes the data breakpoint with the passed id.1242* Notifies debug adapter of breakpoint changes.1243*/1244removeDataBreakpoints(id?: string): Promise<void>;12451246/**1247* Adds a new instruction breakpoint.1248*/1249addInstructionBreakpoint(opts: IInstructionBreakpointOptions): Promise<void>;12501251/**1252* Removes all instruction breakpoints. If address is passed only removes the instruction breakpoint with the passed address.1253* The address should be the address string supplied by the debugger from the "Disassemble" request.1254* Notifies debug adapter of breakpoint changes.1255*/1256removeInstructionBreakpoints(instructionReference?: string, offset?: number): Promise<void>;12571258setExceptionBreakpointCondition(breakpoint: IExceptionBreakpoint, condition: string | undefined): Promise<void>;12591260/**1261* Creates breakpoints based on the sesison filter options. This will create1262* disabled breakpoints (or enabled, if the filter indicates it's a default)1263* for each filter provided in the session.1264*/1265setExceptionBreakpointsForSession(session: IDebugSession, filters: DebugProtocol.ExceptionBreakpointsFilter[]): void;12661267/**1268* Sends all breakpoints to the passed session.1269* If session is not passed, sends all breakpoints to each session.1270*/1271sendAllBreakpoints(session?: IDebugSession): Promise<void>;12721273/**1274* Sends breakpoints of the given source to the passed session.1275*/1276sendBreakpoints(modelUri: uri, sourceModified?: boolean, session?: IDebugSession): Promise<void>;12771278/**1279* Adds a new watch expression and evaluates it against the debug adapter.1280*/1281addWatchExpression(name?: string): void;12821283/**1284* Renames a watch expression and evaluates it against the debug adapter.1285*/1286renameWatchExpression(id: string, newName: string): void;12871288/**1289* Moves a watch expression to a new possition. Used for reordering watch expressions.1290*/1291moveWatchExpression(id: string, position: number): void;12921293/**1294* Removes all watch expressions. If id is passed only removes the watch expression with the passed id.1295*/1296removeWatchExpressions(id?: string): void;12971298/**1299* Starts debugging. If the configOrName is not passed uses the selected configuration in the debug dropdown.1300* Also saves all files, manages if compounds are present in the configuration1301* and resolveds configurations via DebugConfigurationProviders.1302*1303* Returns true if the start debugging was successful. For compound launches, all configurations have to start successfully for it to return success.1304* On errors the startDebugging will throw an error, however some error and cancelations are handled and in that case will simply return false.1305*/1306startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions, saveBeforeStart?: boolean): Promise<boolean>;13071308/**1309* Restarts a session or creates a new one if there is no active session.1310*/1311restartSession(session: IDebugSession, restartData?: unknown): Promise<void>;13121313/**1314* Stops the session. If no session is specified then all sessions are stopped.1315*/1316stopSession(session: IDebugSession | undefined, disconnect?: boolean, suspend?: boolean): Promise<void>;13171318/**1319* Makes unavailable all sources with the passed uri. Source will appear as grayed out in callstack view.1320*/1321sourceIsNotAvailable(uri: uri): void;13221323/**1324* Gets the current debug model.1325*/1326getModel(): IDebugModel;13271328/**1329* Gets the current view model.1330*/1331getViewModel(): IViewModel;13321333/**1334* Resumes execution and pauses until the given position is reached.1335*/1336runTo(uri: uri, lineNumber: number, column?: number): Promise<void>;1337}13381339// Editor interfaces1340export const enum BreakpointWidgetContext {1341CONDITION = 0,1342HIT_COUNT = 1,1343LOG_MESSAGE = 2,1344TRIGGER_POINT = 31345}13461347export interface IDebugEditorContribution extends editorCommon.IEditorContribution {1348showHover(range: Position, focus: boolean): Promise<void>;1349addLaunchConfiguration(): Promise<void>;1350closeExceptionWidget(): void;1351}13521353export interface IBreakpointEditorContribution extends editorCommon.IEditorContribution {1354showBreakpointWidget(lineNumber: number, column: number | undefined, context?: BreakpointWidgetContext): void;1355closeBreakpointWidget(): void;1356getContextMenuActionsAtPosition(lineNumber: number, model: EditorIModel): IAction[];1357}13581359export interface IReplConfiguration {1360readonly fontSize: number;1361readonly fontFamily: string;1362readonly lineHeight: number;1363readonly cssLineHeight: string;1364readonly backgroundColor: Color | undefined;1365readonly fontSizeForTwistie: number;1366}13671368export interface IReplOptions {1369readonly replConfiguration: IReplConfiguration;1370}13711372export interface IDebugVisualizationContext {1373variable: DebugProtocol.Variable;1374containerId?: number;1375frameId?: number;1376threadId: number;1377sessionId: string;1378}13791380export const enum DebugVisualizationType {1381Command,1382Tree,1383}13841385export type MainThreadDebugVisualization =1386| { type: DebugVisualizationType.Command }1387| { type: DebugVisualizationType.Tree; id: string };138813891390export const enum DebugTreeItemCollapsibleState {1391None = 0,1392Collapsed = 1,1393Expanded = 21394}13951396export interface IDebugVisualizationTreeItem {1397id: number;1398label: string;1399description?: string;1400collapsibleState: DebugTreeItemCollapsibleState;1401contextValue?: string;1402canEdit?: boolean;1403}14041405export namespace IDebugVisualizationTreeItem {1406export type Serialized = IDebugVisualizationTreeItem;1407export const deserialize = (v: Serialized): IDebugVisualizationTreeItem => v;1408export const serialize = (item: IDebugVisualizationTreeItem): Serialized => item;1409}14101411export interface IDebugVisualization {1412id: number;1413name: string;1414iconPath: { light?: URI; dark: URI } | undefined;1415iconClass: string | undefined;1416visualization: MainThreadDebugVisualization | undefined;1417}14181419export namespace IDebugVisualization {1420export interface Serialized {1421id: number;1422name: string;1423iconPath?: { light?: UriComponents; dark: UriComponents };1424iconClass?: string;1425visualization?: MainThreadDebugVisualization;1426}14271428export const deserialize = (v: Serialized): IDebugVisualization => ({1429id: v.id,1430name: v.name,1431iconPath: v.iconPath && { light: URI.revive(v.iconPath.light), dark: URI.revive(v.iconPath.dark) },1432iconClass: v.iconClass,1433visualization: v.visualization,1434});14351436export const serialize = (visualizer: IDebugVisualization): Serialized => visualizer;1437}143814391440