@theia/debug 1.53.0-next.4 → 1.53.0-next.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -62
- package/lib/browser/debug-configuration-manager.js +6 -6
- package/lib/browser/debug-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/debug-frontend-application-contribution.js.map +1 -1
- package/lib/common/inline-debug-adapter.d.ts +1 -0
- package/lib/common/inline-debug-adapter.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/browser/breakpoint/breakpoint-manager.ts +369 -369
- package/src/browser/breakpoint/breakpoint-marker.ts +104 -104
- package/src/browser/console/debug-console-contribution.tsx +240 -240
- package/src/browser/console/debug-console-items.tsx +384 -384
- package/src/browser/console/debug-console-session.ts +205 -205
- package/src/browser/debug-call-stack-item-type-key.ts +20 -20
- package/src/browser/debug-configuration-manager.ts +591 -591
- package/src/browser/debug-configuration-model.ts +100 -100
- package/src/browser/debug-contribution.ts +43 -43
- package/src/browser/debug-frontend-application-contribution.ts +1551 -1551
- package/src/browser/debug-frontend-module.ts +133 -133
- package/src/browser/debug-package.spec.ts +20 -20
- package/src/browser/debug-preferences.ts +98 -98
- package/src/browser/debug-prefix-configuration.ts +195 -195
- package/src/browser/debug-resource.ts +59 -59
- package/src/browser/debug-schema-updater.ts +149 -149
- package/src/browser/debug-session-connection.ts +357 -357
- package/src/browser/debug-session-contribution.ts +157 -157
- package/src/browser/debug-session-manager.ts +683 -683
- package/src/browser/debug-session-options.ts +120 -120
- package/src/browser/debug-session.tsx +974 -974
- package/src/browser/debug-tab-bar-decorator.ts +57 -57
- package/src/browser/debug-watch-manager.ts +93 -93
- package/src/browser/disassembly-view/disassembly-view-accessibility-provider.ts +43 -43
- package/src/browser/disassembly-view/disassembly-view-breakpoint-renderer.ts +119 -119
- package/src/browser/disassembly-view/disassembly-view-contribution.ts +109 -109
- package/src/browser/disassembly-view/disassembly-view-instruction-renderer.ts +245 -245
- package/src/browser/disassembly-view/disassembly-view-table-delegate.ts +39 -39
- package/src/browser/disassembly-view/disassembly-view-utilities.ts +55 -55
- package/src/browser/disassembly-view/disassembly-view-widget.ts +463 -463
- package/src/browser/editor/debug-breakpoint-widget.tsx +293 -293
- package/src/browser/editor/debug-editor-model.ts +529 -529
- package/src/browser/editor/debug-editor-service.ts +192 -192
- package/src/browser/editor/debug-editor.ts +20 -20
- package/src/browser/editor/debug-exception-widget.tsx +122 -122
- package/src/browser/editor/debug-expression-provider.ts +78 -78
- package/src/browser/editor/debug-hover-source.tsx +105 -105
- package/src/browser/editor/debug-hover-widget.ts +298 -298
- package/src/browser/editor/debug-inline-value-decorator.ts +373 -373
- package/src/browser/model/debug-breakpoint.tsx +151 -151
- package/src/browser/model/debug-function-breakpoint.tsx +101 -101
- package/src/browser/model/debug-instruction-breakpoint.tsx +68 -68
- package/src/browser/model/debug-source-breakpoint.tsx +237 -237
- package/src/browser/model/debug-source.ts +93 -93
- package/src/browser/model/debug-stack-frame.tsx +177 -177
- package/src/browser/model/debug-thread.tsx +292 -292
- package/src/browser/preferences/launch-preferences.ts +38 -38
- package/src/browser/style/index.css +453 -453
- package/src/browser/view/debug-action.tsx +57 -57
- package/src/browser/view/debug-breakpoints-source.tsx +53 -53
- package/src/browser/view/debug-breakpoints-widget.ts +71 -71
- package/src/browser/view/debug-configuration-select.tsx +269 -269
- package/src/browser/view/debug-configuration-widget.tsx +121 -121
- package/src/browser/view/debug-exception-breakpoint.tsx +68 -68
- package/src/browser/view/debug-session-widget.ts +124 -124
- package/src/browser/view/debug-stack-frames-source.tsx +75 -75
- package/src/browser/view/debug-stack-frames-widget.ts +135 -135
- package/src/browser/view/debug-threads-source.tsx +48 -48
- package/src/browser/view/debug-threads-widget.ts +126 -126
- package/src/browser/view/debug-toolbar-widget.tsx +145 -145
- package/src/browser/view/debug-variables-source.ts +43 -43
- package/src/browser/view/debug-variables-widget.ts +61 -61
- package/src/browser/view/debug-view-model.ts +230 -230
- package/src/browser/view/debug-watch-expression.tsx +88 -88
- package/src/browser/view/debug-watch-source.ts +41 -41
- package/src/browser/view/debug-watch-widget.ts +61 -61
- package/src/browser/view/debug-widget.ts +97 -97
- package/src/common/debug-adapter-contribution-registry.ts +206 -206
- package/src/common/debug-adapter-session.ts +102 -102
- package/src/common/debug-common.ts +19 -19
- package/src/common/debug-compound.ts +33 -33
- package/src/common/debug-configuration.ts +112 -112
- package/src/common/debug-model.ts +200 -200
- package/src/common/debug-service.ts +184 -184
- package/src/common/debug-uri-utils.ts +24 -24
- package/src/common/inline-debug-adapter.ts +47 -47
- package/src/node/debug-adapter-factory.ts +107 -107
- package/src/node/debug-adapter-session-manager.ts +106 -106
- package/src/node/debug-backend-module.ts +57 -57
- package/src/node/debug-service-impl.ts +119 -119
- package/src/node/stream-debug-adapter.ts +126 -126
|
@@ -1,357 +1,357 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
|
-
|
|
19
|
-
import { DebugProtocol } from '@vscode/debugprotocol';
|
|
20
|
-
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
21
|
-
import { Event, Emitter, DisposableCollection, Disposable, MaybePromise } from '@theia/core';
|
|
22
|
-
import { OutputChannel } from '@theia/output/lib/browser/output-channel';
|
|
23
|
-
|
|
24
|
-
import { DebugChannel } from '../common/debug-service';
|
|
25
|
-
|
|
26
|
-
export type DebugRequestHandler = (request: DebugProtocol.Request) => MaybePromise<any>;
|
|
27
|
-
|
|
28
|
-
export interface DebugRequestTypes {
|
|
29
|
-
'attach': [DebugProtocol.AttachRequestArguments, DebugProtocol.AttachResponse]
|
|
30
|
-
'breakpointLocations': [DebugProtocol.BreakpointLocationsArguments, DebugProtocol.BreakpointLocationsResponse]
|
|
31
|
-
'cancel': [DebugProtocol.CancelArguments, DebugProtocol.CancelResponse]
|
|
32
|
-
'completions': [DebugProtocol.CompletionsArguments, DebugProtocol.CompletionsResponse]
|
|
33
|
-
'configurationDone': [DebugProtocol.ConfigurationDoneArguments, DebugProtocol.ConfigurationDoneResponse]
|
|
34
|
-
'continue': [DebugProtocol.ContinueArguments, DebugProtocol.ContinueResponse]
|
|
35
|
-
'dataBreakpointInfo': [DebugProtocol.DataBreakpointInfoArguments, DebugProtocol.DataBreakpointInfoResponse]
|
|
36
|
-
'disassemble': [DebugProtocol.DisassembleArguments, DebugProtocol.DisassembleResponse]
|
|
37
|
-
'disconnect': [DebugProtocol.DisconnectArguments, DebugProtocol.DisconnectResponse]
|
|
38
|
-
'evaluate': [DebugProtocol.EvaluateArguments, DebugProtocol.EvaluateResponse]
|
|
39
|
-
'exceptionInfo': [DebugProtocol.ExceptionInfoArguments, DebugProtocol.ExceptionInfoResponse]
|
|
40
|
-
'goto': [DebugProtocol.GotoArguments, DebugProtocol.GotoResponse]
|
|
41
|
-
'gotoTargets': [DebugProtocol.GotoTargetsArguments, DebugProtocol.GotoTargetsResponse]
|
|
42
|
-
'initialize': [DebugProtocol.InitializeRequestArguments, DebugProtocol.InitializeResponse]
|
|
43
|
-
'launch': [DebugProtocol.LaunchRequestArguments, DebugProtocol.LaunchResponse]
|
|
44
|
-
'loadedSources': [DebugProtocol.LoadedSourcesArguments, DebugProtocol.LoadedSourcesResponse]
|
|
45
|
-
'modules': [DebugProtocol.ModulesArguments, DebugProtocol.ModulesResponse]
|
|
46
|
-
'next': [DebugProtocol.NextArguments, DebugProtocol.NextResponse]
|
|
47
|
-
'pause': [DebugProtocol.PauseArguments, DebugProtocol.PauseResponse]
|
|
48
|
-
'readMemory': [DebugProtocol.ReadMemoryArguments, DebugProtocol.ReadMemoryResponse]
|
|
49
|
-
'restart': [DebugProtocol.RestartArguments, DebugProtocol.RestartResponse]
|
|
50
|
-
'restartFrame': [DebugProtocol.RestartFrameArguments, DebugProtocol.RestartFrameResponse]
|
|
51
|
-
'reverseContinue': [DebugProtocol.ReverseContinueArguments, DebugProtocol.ReverseContinueResponse]
|
|
52
|
-
'scopes': [DebugProtocol.ScopesArguments, DebugProtocol.ScopesResponse]
|
|
53
|
-
'setBreakpoints': [DebugProtocol.SetBreakpointsArguments, DebugProtocol.SetBreakpointsResponse]
|
|
54
|
-
'setDataBreakpoints': [DebugProtocol.SetDataBreakpointsArguments, DebugProtocol.SetDataBreakpointsResponse]
|
|
55
|
-
'setExceptionBreakpoints': [DebugProtocol.SetExceptionBreakpointsArguments, DebugProtocol.SetExceptionBreakpointsResponse]
|
|
56
|
-
'setExpression': [DebugProtocol.SetExpressionArguments, DebugProtocol.SetExpressionResponse]
|
|
57
|
-
'setFunctionBreakpoints': [DebugProtocol.SetFunctionBreakpointsArguments, DebugProtocol.SetFunctionBreakpointsResponse]
|
|
58
|
-
'setInstructionBreakpoints': [DebugProtocol.SetInstructionBreakpointsArguments, DebugProtocol.SetInstructionBreakpointsResponse]
|
|
59
|
-
'setVariable': [DebugProtocol.SetVariableArguments, DebugProtocol.SetVariableResponse]
|
|
60
|
-
'source': [DebugProtocol.SourceArguments, DebugProtocol.SourceResponse]
|
|
61
|
-
'stackTrace': [DebugProtocol.StackTraceArguments, DebugProtocol.StackTraceResponse]
|
|
62
|
-
'stepBack': [DebugProtocol.StepBackArguments, DebugProtocol.StepBackResponse]
|
|
63
|
-
'stepIn': [DebugProtocol.StepInArguments, DebugProtocol.StepInResponse]
|
|
64
|
-
'stepInTargets': [DebugProtocol.StepInTargetsArguments, DebugProtocol.StepInTargetsResponse]
|
|
65
|
-
'stepOut': [DebugProtocol.StepOutArguments, DebugProtocol.StepOutResponse]
|
|
66
|
-
'terminate': [DebugProtocol.TerminateArguments, DebugProtocol.TerminateResponse]
|
|
67
|
-
'terminateThreads': [DebugProtocol.TerminateThreadsArguments, DebugProtocol.TerminateThreadsResponse]
|
|
68
|
-
'threads': [{}, DebugProtocol.ThreadsResponse]
|
|
69
|
-
'variables': [DebugProtocol.VariablesArguments, DebugProtocol.VariablesResponse]
|
|
70
|
-
'writeMemory': [DebugProtocol.WriteMemoryArguments, DebugProtocol.WriteMemoryResponse]
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface DebugEventTypes {
|
|
74
|
-
'breakpoint': DebugProtocol.BreakpointEvent
|
|
75
|
-
'capabilities': DebugProtocol.CapabilitiesEvent
|
|
76
|
-
'continued': DebugProtocol.ContinuedEvent
|
|
77
|
-
'exited': DebugProtocol.ExitedEvent,
|
|
78
|
-
'initialized': DebugProtocol.InitializedEvent
|
|
79
|
-
'invalidated': DebugProtocol.InvalidatedEvent
|
|
80
|
-
'loadedSource': DebugProtocol.LoadedSourceEvent
|
|
81
|
-
'module': DebugProtocol.ModuleEvent
|
|
82
|
-
'output': DebugProtocol.OutputEvent
|
|
83
|
-
'process': DebugProtocol.ProcessEvent
|
|
84
|
-
'progressEnd': DebugProtocol.ProgressEndEvent
|
|
85
|
-
'progressStart': DebugProtocol.ProgressStartEvent
|
|
86
|
-
'progressUpdate': DebugProtocol.ProgressUpdateEvent
|
|
87
|
-
'stopped': DebugProtocol.StoppedEvent
|
|
88
|
-
'terminated': DebugProtocol.TerminatedEvent
|
|
89
|
-
'thread': DebugProtocol.ThreadEvent
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export type DebugEventNames = keyof DebugEventTypes;
|
|
93
|
-
|
|
94
|
-
export namespace DebugEventTypes {
|
|
95
|
-
export function isStandardEvent(event: string): event is DebugEventNames {
|
|
96
|
-
return standardDebugEvents.has(event);
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const standardDebugEvents = new Set<string>([
|
|
101
|
-
'breakpoint',
|
|
102
|
-
'capabilities',
|
|
103
|
-
'continued',
|
|
104
|
-
'exited',
|
|
105
|
-
'initialized',
|
|
106
|
-
'invalidated',
|
|
107
|
-
'loadedSource',
|
|
108
|
-
'module',
|
|
109
|
-
'output',
|
|
110
|
-
'process',
|
|
111
|
-
'progressEnd',
|
|
112
|
-
'progressStart',
|
|
113
|
-
'progressUpdate',
|
|
114
|
-
'stopped',
|
|
115
|
-
'terminated',
|
|
116
|
-
'thread'
|
|
117
|
-
]);
|
|
118
|
-
|
|
119
|
-
export class DebugSessionConnection implements Disposable {
|
|
120
|
-
|
|
121
|
-
private sequence = 1;
|
|
122
|
-
|
|
123
|
-
protected readonly pendingRequests = new Map<number, Deferred<DebugProtocol.Response>>();
|
|
124
|
-
protected readonly connectionPromise: Promise<DebugChannel>;
|
|
125
|
-
|
|
126
|
-
protected readonly requestHandlers = new Map<string, DebugRequestHandler>();
|
|
127
|
-
|
|
128
|
-
protected readonly onDidCustomEventEmitter = new Emitter<DebugProtocol.Event>();
|
|
129
|
-
readonly onDidCustomEvent: Event<DebugProtocol.Event> = this.onDidCustomEventEmitter.event;
|
|
130
|
-
|
|
131
|
-
protected readonly onDidCloseEmitter = new Emitter<void>();
|
|
132
|
-
readonly onDidClose: Event<void> = this.onDidCloseEmitter.event;
|
|
133
|
-
|
|
134
|
-
protected isClosed = false;
|
|
135
|
-
|
|
136
|
-
protected readonly toDispose = new DisposableCollection(
|
|
137
|
-
this.onDidCustomEventEmitter,
|
|
138
|
-
Disposable.create(() => this.pendingRequests.clear()),
|
|
139
|
-
Disposable.create(() => this.emitters.clear())
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
constructor(
|
|
143
|
-
readonly sessionId: string,
|
|
144
|
-
connectionFactory: (sessionId: string) => Promise<DebugChannel>,
|
|
145
|
-
protected readonly traceOutputChannel: OutputChannel | undefined
|
|
146
|
-
) {
|
|
147
|
-
this.connectionPromise = this.createConnection(connectionFactory);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
get disposed(): boolean {
|
|
151
|
-
return this.toDispose.disposed;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
protected checkDisposed(): void {
|
|
155
|
-
if (this.disposed) {
|
|
156
|
-
throw new Error('the debug session connection is disposed, id: ' + this.sessionId);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
dispose(): void {
|
|
161
|
-
this.toDispose.dispose();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
protected async createConnection(connectionFactory: (sessionId: string) => Promise<DebugChannel>): Promise<DebugChannel> {
|
|
165
|
-
const connection = await connectionFactory(this.sessionId);
|
|
166
|
-
connection.onClose(() => {
|
|
167
|
-
this.isClosed = true;
|
|
168
|
-
this.cancelPendingRequests();
|
|
169
|
-
this.onDidCloseEmitter.fire();
|
|
170
|
-
});
|
|
171
|
-
connection.onMessage(data => this.handleMessage(data));
|
|
172
|
-
return connection;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
protected allThreadsContinued = true;
|
|
176
|
-
async sendRequest<K extends keyof DebugRequestTypes>(command: K, args: DebugRequestTypes[K][0], timeout?: number): Promise<DebugRequestTypes[K][1]> {
|
|
177
|
-
const result = await this.doSendRequest(command, args, timeout);
|
|
178
|
-
if (command === 'next' || command === 'stepIn' ||
|
|
179
|
-
command === 'stepOut' || command === 'stepBack' ||
|
|
180
|
-
command === 'reverseContinue' || command === 'restartFrame') {
|
|
181
|
-
this.fireContinuedEvent((args as any).threadId);
|
|
182
|
-
}
|
|
183
|
-
if (command === 'continue') {
|
|
184
|
-
const response = result as DebugProtocol.ContinueResponse;
|
|
185
|
-
const allThreadsContinued = response && response.body && response.body.allThreadsContinued;
|
|
186
|
-
if (allThreadsContinued !== undefined) {
|
|
187
|
-
this.allThreadsContinued = result.body.allThreadsContinued;
|
|
188
|
-
}
|
|
189
|
-
this.fireContinuedEvent((args as any).threadId, this.allThreadsContinued);
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
|
-
return result;
|
|
193
|
-
}
|
|
194
|
-
sendCustomRequest<T extends DebugProtocol.Response>(command: string, args?: any): Promise<T> {
|
|
195
|
-
return this.doSendRequest<T>(command, args);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
protected cancelPendingRequests(): void {
|
|
199
|
-
this.pendingRequests.forEach((deferred, requestId) => {
|
|
200
|
-
deferred.reject(new Error(`Request ${requestId} cancelled on connection close`));
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
protected doSendRequest<K extends DebugProtocol.Response>(command: string, args?: any, timeout?: number): Promise<K> {
|
|
205
|
-
const result = new Deferred<K>();
|
|
206
|
-
|
|
207
|
-
if (this.isClosed) {
|
|
208
|
-
result.reject(new Error('Connection is closed'));
|
|
209
|
-
} else {
|
|
210
|
-
const request: DebugProtocol.Request = {
|
|
211
|
-
seq: this.sequence++,
|
|
212
|
-
type: 'request',
|
|
213
|
-
command: command,
|
|
214
|
-
arguments: args
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
this.pendingRequests.set(request.seq, result);
|
|
218
|
-
if (timeout) {
|
|
219
|
-
const handle = setTimeout(() => {
|
|
220
|
-
const pendingRequest = this.pendingRequests.get(request.seq);
|
|
221
|
-
if (pendingRequest) {
|
|
222
|
-
// request has not been handled
|
|
223
|
-
this.pendingRequests.delete(request.seq);
|
|
224
|
-
const error: DebugProtocol.Response = {
|
|
225
|
-
type: 'response',
|
|
226
|
-
seq: 0,
|
|
227
|
-
request_seq: request.seq,
|
|
228
|
-
success: false,
|
|
229
|
-
command,
|
|
230
|
-
message: `Request #${request.seq}: ${request.command} timed out`
|
|
231
|
-
};
|
|
232
|
-
pendingRequest.reject(error);
|
|
233
|
-
}
|
|
234
|
-
}, timeout);
|
|
235
|
-
result.promise.finally(() => clearTimeout(handle));
|
|
236
|
-
}
|
|
237
|
-
this.send(request);
|
|
238
|
-
}
|
|
239
|
-
return result.promise;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
protected async send(message: DebugProtocol.ProtocolMessage): Promise<void> {
|
|
243
|
-
const connection = await this.connectionPromise;
|
|
244
|
-
const messageStr = JSON.stringify(message);
|
|
245
|
-
if (this.traceOutputChannel) {
|
|
246
|
-
const now = new Date();
|
|
247
|
-
const dateStr = `${now.toLocaleString(undefined, { hour12: false })}.${now.getMilliseconds()}`;
|
|
248
|
-
this.traceOutputChannel.appendLine(`${this.sessionId.substring(0, 8)} ${dateStr} theia -> adapter: ${JSON.stringify(message, undefined, 4)}`);
|
|
249
|
-
}
|
|
250
|
-
connection.send(messageStr);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
protected handleMessage(data: string): void {
|
|
254
|
-
const message: DebugProtocol.ProtocolMessage = JSON.parse(data);
|
|
255
|
-
if (this.traceOutputChannel) {
|
|
256
|
-
const now = new Date();
|
|
257
|
-
const dateStr = `${now.toLocaleString(undefined, { hour12: false })}.${now.getMilliseconds()}`;
|
|
258
|
-
this.traceOutputChannel.appendLine(`${this.sessionId.substring(0, 8)} ${dateStr} theia <- adapter: ${JSON.stringify(message, undefined, 4)}`);
|
|
259
|
-
}
|
|
260
|
-
if (message.type === 'request') {
|
|
261
|
-
this.handleRequest(message as DebugProtocol.Request);
|
|
262
|
-
} else if (message.type === 'response') {
|
|
263
|
-
this.handleResponse(message as DebugProtocol.Response);
|
|
264
|
-
} else if (message.type === 'event') {
|
|
265
|
-
this.handleEvent(message as DebugProtocol.Event);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
protected handleResponse(response: DebugProtocol.Response): void {
|
|
270
|
-
const pendingRequest = this.pendingRequests.get(response.request_seq);
|
|
271
|
-
if (pendingRequest) {
|
|
272
|
-
this.pendingRequests.delete(response.request_seq);
|
|
273
|
-
if (!response.success) {
|
|
274
|
-
pendingRequest.reject(response);
|
|
275
|
-
} else {
|
|
276
|
-
pendingRequest.resolve(response);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
onRequest(command: string, handler: DebugRequestHandler): void {
|
|
282
|
-
this.requestHandlers.set(command, handler);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
protected async handleRequest(request: DebugProtocol.Request): Promise<void> {
|
|
286
|
-
const response: DebugProtocol.Response = {
|
|
287
|
-
type: 'response',
|
|
288
|
-
seq: 0,
|
|
289
|
-
command: request.command,
|
|
290
|
-
request_seq: request.seq,
|
|
291
|
-
success: true,
|
|
292
|
-
};
|
|
293
|
-
const handler = this.requestHandlers.get(request.command);
|
|
294
|
-
if (handler) {
|
|
295
|
-
try {
|
|
296
|
-
response.body = await handler(request);
|
|
297
|
-
} catch (error) {
|
|
298
|
-
response.success = false;
|
|
299
|
-
response.message = error.message;
|
|
300
|
-
}
|
|
301
|
-
} else {
|
|
302
|
-
console.error('Unhandled request', request);
|
|
303
|
-
}
|
|
304
|
-
await this.send(response);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
protected handleEvent(event: DebugProtocol.Event): void {
|
|
308
|
-
if (event.event === 'continued') {
|
|
309
|
-
this.allThreadsContinued = (<DebugProtocol.ContinuedEvent>event).body.allThreadsContinued === false ? false : true;
|
|
310
|
-
}
|
|
311
|
-
if (DebugEventTypes.isStandardEvent(event.event)) {
|
|
312
|
-
this.doFire(event.event, event);
|
|
313
|
-
} else {
|
|
314
|
-
this.onDidCustomEventEmitter.fire(event);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
protected readonly emitters = new Map<string, Emitter<DebugProtocol.Event>>();
|
|
319
|
-
on<K extends keyof DebugEventTypes>(kind: K, listener: (e: DebugEventTypes[K]) => any): Disposable {
|
|
320
|
-
return this.getEmitter(kind).event(listener);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
onEvent<K extends keyof DebugEventTypes>(kind: K): Event<DebugEventTypes[K]> {
|
|
324
|
-
return this.getEmitter(kind).event;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
protected fire<K extends keyof DebugEventTypes>(kind: K, e: DebugEventTypes[K]): void {
|
|
328
|
-
this.doFire(kind, e);
|
|
329
|
-
}
|
|
330
|
-
protected doFire<K extends keyof DebugEventTypes>(kind: K, e: DebugEventTypes[K]): void {
|
|
331
|
-
this.getEmitter(kind).fire(e);
|
|
332
|
-
}
|
|
333
|
-
protected getEmitter<K extends keyof DebugEventTypes>(kind: K): Emitter<DebugEventTypes[K]> {
|
|
334
|
-
const emitter = this.emitters.get(kind) || this.newEmitter();
|
|
335
|
-
this.emitters.set(kind, emitter);
|
|
336
|
-
return <Emitter<DebugEventTypes[K]>>emitter;
|
|
337
|
-
}
|
|
338
|
-
protected newEmitter(): Emitter<DebugProtocol.Event> {
|
|
339
|
-
const emitter = new Emitter();
|
|
340
|
-
this.checkDisposed();
|
|
341
|
-
this.toDispose.push(emitter);
|
|
342
|
-
return emitter;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
protected fireContinuedEvent(threadId: number, allThreadsContinued = false): void {
|
|
346
|
-
this.fire('continued', {
|
|
347
|
-
type: 'event',
|
|
348
|
-
event: 'continued',
|
|
349
|
-
body: {
|
|
350
|
-
threadId,
|
|
351
|
-
allThreadsContinued
|
|
352
|
-
},
|
|
353
|
-
seq: -1
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
|
+
|
|
19
|
+
import { DebugProtocol } from '@vscode/debugprotocol';
|
|
20
|
+
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
21
|
+
import { Event, Emitter, DisposableCollection, Disposable, MaybePromise } from '@theia/core';
|
|
22
|
+
import { OutputChannel } from '@theia/output/lib/browser/output-channel';
|
|
23
|
+
|
|
24
|
+
import { DebugChannel } from '../common/debug-service';
|
|
25
|
+
|
|
26
|
+
export type DebugRequestHandler = (request: DebugProtocol.Request) => MaybePromise<any>;
|
|
27
|
+
|
|
28
|
+
export interface DebugRequestTypes {
|
|
29
|
+
'attach': [DebugProtocol.AttachRequestArguments, DebugProtocol.AttachResponse]
|
|
30
|
+
'breakpointLocations': [DebugProtocol.BreakpointLocationsArguments, DebugProtocol.BreakpointLocationsResponse]
|
|
31
|
+
'cancel': [DebugProtocol.CancelArguments, DebugProtocol.CancelResponse]
|
|
32
|
+
'completions': [DebugProtocol.CompletionsArguments, DebugProtocol.CompletionsResponse]
|
|
33
|
+
'configurationDone': [DebugProtocol.ConfigurationDoneArguments, DebugProtocol.ConfigurationDoneResponse]
|
|
34
|
+
'continue': [DebugProtocol.ContinueArguments, DebugProtocol.ContinueResponse]
|
|
35
|
+
'dataBreakpointInfo': [DebugProtocol.DataBreakpointInfoArguments, DebugProtocol.DataBreakpointInfoResponse]
|
|
36
|
+
'disassemble': [DebugProtocol.DisassembleArguments, DebugProtocol.DisassembleResponse]
|
|
37
|
+
'disconnect': [DebugProtocol.DisconnectArguments, DebugProtocol.DisconnectResponse]
|
|
38
|
+
'evaluate': [DebugProtocol.EvaluateArguments, DebugProtocol.EvaluateResponse]
|
|
39
|
+
'exceptionInfo': [DebugProtocol.ExceptionInfoArguments, DebugProtocol.ExceptionInfoResponse]
|
|
40
|
+
'goto': [DebugProtocol.GotoArguments, DebugProtocol.GotoResponse]
|
|
41
|
+
'gotoTargets': [DebugProtocol.GotoTargetsArguments, DebugProtocol.GotoTargetsResponse]
|
|
42
|
+
'initialize': [DebugProtocol.InitializeRequestArguments, DebugProtocol.InitializeResponse]
|
|
43
|
+
'launch': [DebugProtocol.LaunchRequestArguments, DebugProtocol.LaunchResponse]
|
|
44
|
+
'loadedSources': [DebugProtocol.LoadedSourcesArguments, DebugProtocol.LoadedSourcesResponse]
|
|
45
|
+
'modules': [DebugProtocol.ModulesArguments, DebugProtocol.ModulesResponse]
|
|
46
|
+
'next': [DebugProtocol.NextArguments, DebugProtocol.NextResponse]
|
|
47
|
+
'pause': [DebugProtocol.PauseArguments, DebugProtocol.PauseResponse]
|
|
48
|
+
'readMemory': [DebugProtocol.ReadMemoryArguments, DebugProtocol.ReadMemoryResponse]
|
|
49
|
+
'restart': [DebugProtocol.RestartArguments, DebugProtocol.RestartResponse]
|
|
50
|
+
'restartFrame': [DebugProtocol.RestartFrameArguments, DebugProtocol.RestartFrameResponse]
|
|
51
|
+
'reverseContinue': [DebugProtocol.ReverseContinueArguments, DebugProtocol.ReverseContinueResponse]
|
|
52
|
+
'scopes': [DebugProtocol.ScopesArguments, DebugProtocol.ScopesResponse]
|
|
53
|
+
'setBreakpoints': [DebugProtocol.SetBreakpointsArguments, DebugProtocol.SetBreakpointsResponse]
|
|
54
|
+
'setDataBreakpoints': [DebugProtocol.SetDataBreakpointsArguments, DebugProtocol.SetDataBreakpointsResponse]
|
|
55
|
+
'setExceptionBreakpoints': [DebugProtocol.SetExceptionBreakpointsArguments, DebugProtocol.SetExceptionBreakpointsResponse]
|
|
56
|
+
'setExpression': [DebugProtocol.SetExpressionArguments, DebugProtocol.SetExpressionResponse]
|
|
57
|
+
'setFunctionBreakpoints': [DebugProtocol.SetFunctionBreakpointsArguments, DebugProtocol.SetFunctionBreakpointsResponse]
|
|
58
|
+
'setInstructionBreakpoints': [DebugProtocol.SetInstructionBreakpointsArguments, DebugProtocol.SetInstructionBreakpointsResponse]
|
|
59
|
+
'setVariable': [DebugProtocol.SetVariableArguments, DebugProtocol.SetVariableResponse]
|
|
60
|
+
'source': [DebugProtocol.SourceArguments, DebugProtocol.SourceResponse]
|
|
61
|
+
'stackTrace': [DebugProtocol.StackTraceArguments, DebugProtocol.StackTraceResponse]
|
|
62
|
+
'stepBack': [DebugProtocol.StepBackArguments, DebugProtocol.StepBackResponse]
|
|
63
|
+
'stepIn': [DebugProtocol.StepInArguments, DebugProtocol.StepInResponse]
|
|
64
|
+
'stepInTargets': [DebugProtocol.StepInTargetsArguments, DebugProtocol.StepInTargetsResponse]
|
|
65
|
+
'stepOut': [DebugProtocol.StepOutArguments, DebugProtocol.StepOutResponse]
|
|
66
|
+
'terminate': [DebugProtocol.TerminateArguments, DebugProtocol.TerminateResponse]
|
|
67
|
+
'terminateThreads': [DebugProtocol.TerminateThreadsArguments, DebugProtocol.TerminateThreadsResponse]
|
|
68
|
+
'threads': [{}, DebugProtocol.ThreadsResponse]
|
|
69
|
+
'variables': [DebugProtocol.VariablesArguments, DebugProtocol.VariablesResponse]
|
|
70
|
+
'writeMemory': [DebugProtocol.WriteMemoryArguments, DebugProtocol.WriteMemoryResponse]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface DebugEventTypes {
|
|
74
|
+
'breakpoint': DebugProtocol.BreakpointEvent
|
|
75
|
+
'capabilities': DebugProtocol.CapabilitiesEvent
|
|
76
|
+
'continued': DebugProtocol.ContinuedEvent
|
|
77
|
+
'exited': DebugProtocol.ExitedEvent,
|
|
78
|
+
'initialized': DebugProtocol.InitializedEvent
|
|
79
|
+
'invalidated': DebugProtocol.InvalidatedEvent
|
|
80
|
+
'loadedSource': DebugProtocol.LoadedSourceEvent
|
|
81
|
+
'module': DebugProtocol.ModuleEvent
|
|
82
|
+
'output': DebugProtocol.OutputEvent
|
|
83
|
+
'process': DebugProtocol.ProcessEvent
|
|
84
|
+
'progressEnd': DebugProtocol.ProgressEndEvent
|
|
85
|
+
'progressStart': DebugProtocol.ProgressStartEvent
|
|
86
|
+
'progressUpdate': DebugProtocol.ProgressUpdateEvent
|
|
87
|
+
'stopped': DebugProtocol.StoppedEvent
|
|
88
|
+
'terminated': DebugProtocol.TerminatedEvent
|
|
89
|
+
'thread': DebugProtocol.ThreadEvent
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type DebugEventNames = keyof DebugEventTypes;
|
|
93
|
+
|
|
94
|
+
export namespace DebugEventTypes {
|
|
95
|
+
export function isStandardEvent(event: string): event is DebugEventNames {
|
|
96
|
+
return standardDebugEvents.has(event);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const standardDebugEvents = new Set<string>([
|
|
101
|
+
'breakpoint',
|
|
102
|
+
'capabilities',
|
|
103
|
+
'continued',
|
|
104
|
+
'exited',
|
|
105
|
+
'initialized',
|
|
106
|
+
'invalidated',
|
|
107
|
+
'loadedSource',
|
|
108
|
+
'module',
|
|
109
|
+
'output',
|
|
110
|
+
'process',
|
|
111
|
+
'progressEnd',
|
|
112
|
+
'progressStart',
|
|
113
|
+
'progressUpdate',
|
|
114
|
+
'stopped',
|
|
115
|
+
'terminated',
|
|
116
|
+
'thread'
|
|
117
|
+
]);
|
|
118
|
+
|
|
119
|
+
export class DebugSessionConnection implements Disposable {
|
|
120
|
+
|
|
121
|
+
private sequence = 1;
|
|
122
|
+
|
|
123
|
+
protected readonly pendingRequests = new Map<number, Deferred<DebugProtocol.Response>>();
|
|
124
|
+
protected readonly connectionPromise: Promise<DebugChannel>;
|
|
125
|
+
|
|
126
|
+
protected readonly requestHandlers = new Map<string, DebugRequestHandler>();
|
|
127
|
+
|
|
128
|
+
protected readonly onDidCustomEventEmitter = new Emitter<DebugProtocol.Event>();
|
|
129
|
+
readonly onDidCustomEvent: Event<DebugProtocol.Event> = this.onDidCustomEventEmitter.event;
|
|
130
|
+
|
|
131
|
+
protected readonly onDidCloseEmitter = new Emitter<void>();
|
|
132
|
+
readonly onDidClose: Event<void> = this.onDidCloseEmitter.event;
|
|
133
|
+
|
|
134
|
+
protected isClosed = false;
|
|
135
|
+
|
|
136
|
+
protected readonly toDispose = new DisposableCollection(
|
|
137
|
+
this.onDidCustomEventEmitter,
|
|
138
|
+
Disposable.create(() => this.pendingRequests.clear()),
|
|
139
|
+
Disposable.create(() => this.emitters.clear())
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
constructor(
|
|
143
|
+
readonly sessionId: string,
|
|
144
|
+
connectionFactory: (sessionId: string) => Promise<DebugChannel>,
|
|
145
|
+
protected readonly traceOutputChannel: OutputChannel | undefined
|
|
146
|
+
) {
|
|
147
|
+
this.connectionPromise = this.createConnection(connectionFactory);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
get disposed(): boolean {
|
|
151
|
+
return this.toDispose.disposed;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
protected checkDisposed(): void {
|
|
155
|
+
if (this.disposed) {
|
|
156
|
+
throw new Error('the debug session connection is disposed, id: ' + this.sessionId);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
dispose(): void {
|
|
161
|
+
this.toDispose.dispose();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
protected async createConnection(connectionFactory: (sessionId: string) => Promise<DebugChannel>): Promise<DebugChannel> {
|
|
165
|
+
const connection = await connectionFactory(this.sessionId);
|
|
166
|
+
connection.onClose(() => {
|
|
167
|
+
this.isClosed = true;
|
|
168
|
+
this.cancelPendingRequests();
|
|
169
|
+
this.onDidCloseEmitter.fire();
|
|
170
|
+
});
|
|
171
|
+
connection.onMessage(data => this.handleMessage(data));
|
|
172
|
+
return connection;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
protected allThreadsContinued = true;
|
|
176
|
+
async sendRequest<K extends keyof DebugRequestTypes>(command: K, args: DebugRequestTypes[K][0], timeout?: number): Promise<DebugRequestTypes[K][1]> {
|
|
177
|
+
const result = await this.doSendRequest(command, args, timeout);
|
|
178
|
+
if (command === 'next' || command === 'stepIn' ||
|
|
179
|
+
command === 'stepOut' || command === 'stepBack' ||
|
|
180
|
+
command === 'reverseContinue' || command === 'restartFrame') {
|
|
181
|
+
this.fireContinuedEvent((args as any).threadId);
|
|
182
|
+
}
|
|
183
|
+
if (command === 'continue') {
|
|
184
|
+
const response = result as DebugProtocol.ContinueResponse;
|
|
185
|
+
const allThreadsContinued = response && response.body && response.body.allThreadsContinued;
|
|
186
|
+
if (allThreadsContinued !== undefined) {
|
|
187
|
+
this.allThreadsContinued = result.body.allThreadsContinued;
|
|
188
|
+
}
|
|
189
|
+
this.fireContinuedEvent((args as any).threadId, this.allThreadsContinued);
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
sendCustomRequest<T extends DebugProtocol.Response>(command: string, args?: any): Promise<T> {
|
|
195
|
+
return this.doSendRequest<T>(command, args);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
protected cancelPendingRequests(): void {
|
|
199
|
+
this.pendingRequests.forEach((deferred, requestId) => {
|
|
200
|
+
deferred.reject(new Error(`Request ${requestId} cancelled on connection close`));
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
protected doSendRequest<K extends DebugProtocol.Response>(command: string, args?: any, timeout?: number): Promise<K> {
|
|
205
|
+
const result = new Deferred<K>();
|
|
206
|
+
|
|
207
|
+
if (this.isClosed) {
|
|
208
|
+
result.reject(new Error('Connection is closed'));
|
|
209
|
+
} else {
|
|
210
|
+
const request: DebugProtocol.Request = {
|
|
211
|
+
seq: this.sequence++,
|
|
212
|
+
type: 'request',
|
|
213
|
+
command: command,
|
|
214
|
+
arguments: args
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
this.pendingRequests.set(request.seq, result);
|
|
218
|
+
if (timeout) {
|
|
219
|
+
const handle = setTimeout(() => {
|
|
220
|
+
const pendingRequest = this.pendingRequests.get(request.seq);
|
|
221
|
+
if (pendingRequest) {
|
|
222
|
+
// request has not been handled
|
|
223
|
+
this.pendingRequests.delete(request.seq);
|
|
224
|
+
const error: DebugProtocol.Response = {
|
|
225
|
+
type: 'response',
|
|
226
|
+
seq: 0,
|
|
227
|
+
request_seq: request.seq,
|
|
228
|
+
success: false,
|
|
229
|
+
command,
|
|
230
|
+
message: `Request #${request.seq}: ${request.command} timed out`
|
|
231
|
+
};
|
|
232
|
+
pendingRequest.reject(error);
|
|
233
|
+
}
|
|
234
|
+
}, timeout);
|
|
235
|
+
result.promise.finally(() => clearTimeout(handle));
|
|
236
|
+
}
|
|
237
|
+
this.send(request);
|
|
238
|
+
}
|
|
239
|
+
return result.promise;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
protected async send(message: DebugProtocol.ProtocolMessage): Promise<void> {
|
|
243
|
+
const connection = await this.connectionPromise;
|
|
244
|
+
const messageStr = JSON.stringify(message);
|
|
245
|
+
if (this.traceOutputChannel) {
|
|
246
|
+
const now = new Date();
|
|
247
|
+
const dateStr = `${now.toLocaleString(undefined, { hour12: false })}.${now.getMilliseconds()}`;
|
|
248
|
+
this.traceOutputChannel.appendLine(`${this.sessionId.substring(0, 8)} ${dateStr} theia -> adapter: ${JSON.stringify(message, undefined, 4)}`);
|
|
249
|
+
}
|
|
250
|
+
connection.send(messageStr);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
protected handleMessage(data: string): void {
|
|
254
|
+
const message: DebugProtocol.ProtocolMessage = JSON.parse(data);
|
|
255
|
+
if (this.traceOutputChannel) {
|
|
256
|
+
const now = new Date();
|
|
257
|
+
const dateStr = `${now.toLocaleString(undefined, { hour12: false })}.${now.getMilliseconds()}`;
|
|
258
|
+
this.traceOutputChannel.appendLine(`${this.sessionId.substring(0, 8)} ${dateStr} theia <- adapter: ${JSON.stringify(message, undefined, 4)}`);
|
|
259
|
+
}
|
|
260
|
+
if (message.type === 'request') {
|
|
261
|
+
this.handleRequest(message as DebugProtocol.Request);
|
|
262
|
+
} else if (message.type === 'response') {
|
|
263
|
+
this.handleResponse(message as DebugProtocol.Response);
|
|
264
|
+
} else if (message.type === 'event') {
|
|
265
|
+
this.handleEvent(message as DebugProtocol.Event);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
protected handleResponse(response: DebugProtocol.Response): void {
|
|
270
|
+
const pendingRequest = this.pendingRequests.get(response.request_seq);
|
|
271
|
+
if (pendingRequest) {
|
|
272
|
+
this.pendingRequests.delete(response.request_seq);
|
|
273
|
+
if (!response.success) {
|
|
274
|
+
pendingRequest.reject(response);
|
|
275
|
+
} else {
|
|
276
|
+
pendingRequest.resolve(response);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
onRequest(command: string, handler: DebugRequestHandler): void {
|
|
282
|
+
this.requestHandlers.set(command, handler);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
protected async handleRequest(request: DebugProtocol.Request): Promise<void> {
|
|
286
|
+
const response: DebugProtocol.Response = {
|
|
287
|
+
type: 'response',
|
|
288
|
+
seq: 0,
|
|
289
|
+
command: request.command,
|
|
290
|
+
request_seq: request.seq,
|
|
291
|
+
success: true,
|
|
292
|
+
};
|
|
293
|
+
const handler = this.requestHandlers.get(request.command);
|
|
294
|
+
if (handler) {
|
|
295
|
+
try {
|
|
296
|
+
response.body = await handler(request);
|
|
297
|
+
} catch (error) {
|
|
298
|
+
response.success = false;
|
|
299
|
+
response.message = error.message;
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
console.error('Unhandled request', request);
|
|
303
|
+
}
|
|
304
|
+
await this.send(response);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
protected handleEvent(event: DebugProtocol.Event): void {
|
|
308
|
+
if (event.event === 'continued') {
|
|
309
|
+
this.allThreadsContinued = (<DebugProtocol.ContinuedEvent>event).body.allThreadsContinued === false ? false : true;
|
|
310
|
+
}
|
|
311
|
+
if (DebugEventTypes.isStandardEvent(event.event)) {
|
|
312
|
+
this.doFire(event.event, event);
|
|
313
|
+
} else {
|
|
314
|
+
this.onDidCustomEventEmitter.fire(event);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
protected readonly emitters = new Map<string, Emitter<DebugProtocol.Event>>();
|
|
319
|
+
on<K extends keyof DebugEventTypes>(kind: K, listener: (e: DebugEventTypes[K]) => any): Disposable {
|
|
320
|
+
return this.getEmitter(kind).event(listener);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
onEvent<K extends keyof DebugEventTypes>(kind: K): Event<DebugEventTypes[K]> {
|
|
324
|
+
return this.getEmitter(kind).event;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
protected fire<K extends keyof DebugEventTypes>(kind: K, e: DebugEventTypes[K]): void {
|
|
328
|
+
this.doFire(kind, e);
|
|
329
|
+
}
|
|
330
|
+
protected doFire<K extends keyof DebugEventTypes>(kind: K, e: DebugEventTypes[K]): void {
|
|
331
|
+
this.getEmitter(kind).fire(e);
|
|
332
|
+
}
|
|
333
|
+
protected getEmitter<K extends keyof DebugEventTypes>(kind: K): Emitter<DebugEventTypes[K]> {
|
|
334
|
+
const emitter = this.emitters.get(kind) || this.newEmitter();
|
|
335
|
+
this.emitters.set(kind, emitter);
|
|
336
|
+
return <Emitter<DebugEventTypes[K]>>emitter;
|
|
337
|
+
}
|
|
338
|
+
protected newEmitter(): Emitter<DebugProtocol.Event> {
|
|
339
|
+
const emitter = new Emitter();
|
|
340
|
+
this.checkDisposed();
|
|
341
|
+
this.toDispose.push(emitter);
|
|
342
|
+
return emitter;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
protected fireContinuedEvent(threadId: number, allThreadsContinued = false): void {
|
|
346
|
+
this.fire('continued', {
|
|
347
|
+
type: 'event',
|
|
348
|
+
event: 'continued',
|
|
349
|
+
body: {
|
|
350
|
+
threadId,
|
|
351
|
+
allThreadsContinued
|
|
352
|
+
},
|
|
353
|
+
seq: -1
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
}
|