Skip to content

Commit a803dc3

Browse files
authored
Update DAP dts and implement new 'startDebugging' request (#164530)
1 parent 586f252 commit a803dc3

File tree

6 files changed

+281
-239
lines changed

6 files changed

+281
-239
lines changed

src/vs/workbench/contrib/debug/browser/debugSession.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ export class DebugSession implements IDebugSession {
288288

289289
try {
290290
const debugAdapter = await dbgr.createDebugAdapter(this);
291-
this.raw = this.instantiationService.createInstance(RawDebugSession, debugAdapter, dbgr, this.id);
291+
this.raw = this.instantiationService.createInstance(RawDebugSession, debugAdapter, dbgr, this.id, this.configuration.name);
292292

293293
await this.raw.start();
294294
this.registerListeners();

src/vs/workbench/contrib/debug/browser/rawDebugSession.ts

+26-3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export class RawDebugSession implements IDisposable {
8383
debugAdapter: IDebugAdapter,
8484
public readonly dbgr: IDebugger,
8585
private readonly sessionId: string,
86+
private readonly name: string,
8687
@IExtensionHostDebugService private readonly extensionHostDebugService: IExtensionHostDebugService,
8788
@IOpenerService private readonly openerService: IOpenerService,
8889
@INotificationService private readonly notificationService: INotificationService,
@@ -168,7 +169,7 @@ export class RawDebugSession implements IDisposable {
168169
this._onDidEvent.fire(event);
169170
});
170171

171-
this.debugAdapter.onRequest(request => this.dispatchRequest(request, dbgr));
172+
this.debugAdapter.onRequest(request => this.dispatchRequest(request));
172173
}
173174

174175
get onDidExitAdapter(): Event<AdapterEndEvent> {
@@ -608,7 +609,7 @@ export class RawDebugSession implements IDisposable {
608609
}
609610
}
610611

611-
private async dispatchRequest(request: DebugProtocol.Request, dbgr: IDebugger): Promise<void> {
612+
private async dispatchRequest(request: DebugProtocol.Request): Promise<void> {
612613

613614
const response: DebugProtocol.Response = {
614615
type: 'response',
@@ -647,7 +648,7 @@ export class RawDebugSession implements IDisposable {
647648
break;
648649
case 'runInTerminal':
649650
try {
650-
const shellProcessId = await dbgr.runInTerminal(request.arguments as DebugProtocol.RunInTerminalRequestArguments, this.sessionId);
651+
const shellProcessId = await this.dbgr.runInTerminal(request.arguments as DebugProtocol.RunInTerminalRequestArguments, this.sessionId);
651652
const resp = response as DebugProtocol.RunInTerminalResponse;
652653
resp.body = {};
653654
if (typeof shellProcessId === 'number') {
@@ -660,6 +661,28 @@ export class RawDebugSession implements IDisposable {
660661
safeSendResponse(response);
661662
}
662663
break;
664+
case 'startDebugging':
665+
try {
666+
const args = (request.arguments as DebugProtocol.StartDebuggingRequestArguments);
667+
const config: IConfig = {
668+
...args.configuration,
669+
...{
670+
request: args.request,
671+
type: this.dbgr.type,
672+
name: this.name
673+
}
674+
};
675+
const success = await this.dbgr.startDebugging(config, this.sessionId);
676+
if (!success) {
677+
response.success = false;
678+
response.message = 'Failed to start debugging';
679+
safeSendResponse(response);
680+
}
681+
} catch (err) {
682+
response.success = false;
683+
response.message = err.message;
684+
safeSendResponse(response);
685+
}
663686
default:
664687
response.success = false;
665688
response.message = `unknown request '${request.command}'`;

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

+2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ export interface IExpression extends IExpressionContainer {
155155
}
156156

157157
export interface IDebugger {
158+
readonly type: string;
158159
createDebugAdapter(session: IDebugSession): Promise<IDebugAdapter>;
159160
runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments, sessionId: string): Promise<number | undefined>;
161+
startDebugging(args: IConfig, parentSessionId: string): Promise<boolean>;
160162
getCustomTelemetryEndpoint(): ITelemetryEndpoint | undefined;
161163
}
162164

0 commit comments

Comments
 (0)