mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Update DAP dts and implement new 'startDebugging' request (#164530)
This commit is contained in:
parent
586f252740
commit
a803dc359a
|
@ -288,7 +288,7 @@ export class DebugSession implements IDebugSession {
|
|||
|
||||
try {
|
||||
const debugAdapter = await dbgr.createDebugAdapter(this);
|
||||
this.raw = this.instantiationService.createInstance(RawDebugSession, debugAdapter, dbgr, this.id);
|
||||
this.raw = this.instantiationService.createInstance(RawDebugSession, debugAdapter, dbgr, this.id, this.configuration.name);
|
||||
|
||||
await this.raw.start();
|
||||
this.registerListeners();
|
||||
|
|
|
@ -83,6 +83,7 @@ export class RawDebugSession implements IDisposable {
|
|||
debugAdapter: IDebugAdapter,
|
||||
public readonly dbgr: IDebugger,
|
||||
private readonly sessionId: string,
|
||||
private readonly name: string,
|
||||
@IExtensionHostDebugService private readonly extensionHostDebugService: IExtensionHostDebugService,
|
||||
@IOpenerService private readonly openerService: IOpenerService,
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
|
@ -168,7 +169,7 @@ export class RawDebugSession implements IDisposable {
|
|||
this._onDidEvent.fire(event);
|
||||
});
|
||||
|
||||
this.debugAdapter.onRequest(request => this.dispatchRequest(request, dbgr));
|
||||
this.debugAdapter.onRequest(request => this.dispatchRequest(request));
|
||||
}
|
||||
|
||||
get onDidExitAdapter(): Event<AdapterEndEvent> {
|
||||
|
@ -608,7 +609,7 @@ export class RawDebugSession implements IDisposable {
|
|||
}
|
||||
}
|
||||
|
||||
private async dispatchRequest(request: DebugProtocol.Request, dbgr: IDebugger): Promise<void> {
|
||||
private async dispatchRequest(request: DebugProtocol.Request): Promise<void> {
|
||||
|
||||
const response: DebugProtocol.Response = {
|
||||
type: 'response',
|
||||
|
@ -647,7 +648,7 @@ export class RawDebugSession implements IDisposable {
|
|||
break;
|
||||
case 'runInTerminal':
|
||||
try {
|
||||
const shellProcessId = await dbgr.runInTerminal(request.arguments as DebugProtocol.RunInTerminalRequestArguments, this.sessionId);
|
||||
const shellProcessId = await this.dbgr.runInTerminal(request.arguments as DebugProtocol.RunInTerminalRequestArguments, this.sessionId);
|
||||
const resp = response as DebugProtocol.RunInTerminalResponse;
|
||||
resp.body = {};
|
||||
if (typeof shellProcessId === 'number') {
|
||||
|
@ -660,6 +661,28 @@ export class RawDebugSession implements IDisposable {
|
|||
safeSendResponse(response);
|
||||
}
|
||||
break;
|
||||
case 'startDebugging':
|
||||
try {
|
||||
const args = (request.arguments as DebugProtocol.StartDebuggingRequestArguments);
|
||||
const config: IConfig = {
|
||||
...args.configuration,
|
||||
...{
|
||||
request: args.request,
|
||||
type: this.dbgr.type,
|
||||
name: this.name
|
||||
}
|
||||
};
|
||||
const success = await this.dbgr.startDebugging(config, this.sessionId);
|
||||
if (!success) {
|
||||
response.success = false;
|
||||
response.message = 'Failed to start debugging';
|
||||
safeSendResponse(response);
|
||||
}
|
||||
} catch (err) {
|
||||
response.success = false;
|
||||
response.message = err.message;
|
||||
safeSendResponse(response);
|
||||
}
|
||||
default:
|
||||
response.success = false;
|
||||
response.message = `unknown request '${request.command}'`;
|
||||
|
|
|
@ -155,8 +155,10 @@ export interface IExpression extends IExpressionContainer {
|
|||
}
|
||||
|
||||
export interface IDebugger {
|
||||
readonly type: string;
|
||||
createDebugAdapter(session: IDebugSession): Promise<IDebugAdapter>;
|
||||
runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments, sessionId: string): Promise<number | undefined>;
|
||||
startDebugging(args: IConfig, parentSessionId: string): Promise<boolean>;
|
||||
getCustomTelemetryEndpoint(): ITelemetryEndpoint | undefined;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -99,20 +99,23 @@ export class Debugger implements IDebugger, IDebuggerMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
createDebugAdapter(session: IDebugSession): Promise<IDebugAdapter> {
|
||||
return this.adapterManager.activateDebuggers('onDebugAdapterProtocolTracker', this.type).then(_ => {
|
||||
const da = this.adapterManager.createDebugAdapter(session);
|
||||
if (da) {
|
||||
return Promise.resolve(da);
|
||||
}
|
||||
throw new Error(nls.localize('cannot.find.da', "Cannot find debug adapter for type '{0}'.", this.type));
|
||||
});
|
||||
async startDebugging(configuration: IConfig, parentSessionId: string): Promise<boolean> {
|
||||
const parentSession = this.debugService.getModel().getSession(parentSessionId);
|
||||
return await this.debugService.startDebugging(undefined, configuration, { parentSession }, undefined);
|
||||
}
|
||||
|
||||
substituteVariables(folder: IWorkspaceFolder | undefined, config: IConfig): Promise<IConfig> {
|
||||
return this.adapterManager.substituteVariables(this.type, folder, config).then(config => {
|
||||
return this.configurationResolverService.resolveWithInteractionReplace(folder, config, 'launch', this.variables, config.__configurationTarget);
|
||||
});
|
||||
async createDebugAdapter(session: IDebugSession): Promise<IDebugAdapter> {
|
||||
await this.adapterManager.activateDebuggers('onDebugAdapterProtocolTracker', this.type);
|
||||
const da = this.adapterManager.createDebugAdapter(session);
|
||||
if (da) {
|
||||
return Promise.resolve(da);
|
||||
}
|
||||
throw new Error(nls.localize('cannot.find.da', "Cannot find debug adapter for type '{0}'.", this.type));
|
||||
}
|
||||
|
||||
async substituteVariables(folder: IWorkspaceFolder | undefined, config: IConfig): Promise<IConfig> {
|
||||
const substitutedConfig = await this.adapterManager.substituteVariables(this.type, folder, config);
|
||||
return await this.configurationResolverService.resolveWithInteractionReplace(folder, substitutedConfig, 'launch', this.variables, substitutedConfig.__configurationTarget);
|
||||
}
|
||||
|
||||
runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments, sessionId: string): Promise<number | undefined> {
|
||||
|
|
|
@ -176,7 +176,7 @@ suite('Debug - REPL', () => {
|
|||
model.addSession(session);
|
||||
|
||||
const adapter = new MockDebugAdapter();
|
||||
const raw = new RawDebugSession(adapter, undefined!, '', undefined!, undefined!, undefined!, undefined!);
|
||||
const raw = new RawDebugSession(adapter, undefined!, '', '', undefined!, undefined!, undefined!, undefined!,);
|
||||
session.initializeForTest(raw);
|
||||
|
||||
await session.addReplExpression(undefined, 'before.1');
|
||||
|
|
Loading…
Reference in a new issue