Skip to content

Adopt DAP's 'startDebugging' request #160169

Closed
@weinand

Description

@weinand

for details see microsoft/debug-adapter-protocol#79

Implementation pointers:

  • Client capabilities are set here:
    await this.raw!.initialize({
    clientID: 'vscode',
    clientName: this.productService.nameLong,
    adapterID: this.configuration.type,
    pathFormat: 'path',
    linesStartAt1: true,
    columnsStartAt1: true,
    supportsVariableType: true, // #8858
    supportsVariablePaging: true, // #9537
    supportsRunInTerminalRequest: true, // #10574
    locale: platform.locale,
    supportsProgressReporting: true, // #92253
    supportsInvalidatedEvent: true, // #106745
    supportsMemoryReferences: true, //#129684
    supportsArgsCanBeInterpretedByShell: true // #149910
  • DAP's reverse requests are dispatched here:
    private async dispatchRequest(request: DebugProtocol.Request, dbgr: IDebugger): Promise<void> {
    const response: DebugProtocol.Response = {
    type: 'response',
    seq: 0,
    command: request.command,
    request_seq: request.seq,
    success: true
    };
    const safeSendResponse = (response: DebugProtocol.Response) => this.debugAdapter && this.debugAdapter.sendResponse(response);
    switch (request.command) {
    case 'launchVSCode':
    try {
    let result = await this.launchVsCode(<ILaunchVSCodeArguments>request.arguments);
    if (!result.success) {
    const showResult = await this.dialogSerivce.show(Severity.Warning, nls.localize('canNotStart', "The debugger needs to open a new tab or window for the debuggee but the browser prevented this. You must give permission to continue."),
    [nls.localize('continue', "Continue"), nls.localize('cancel', "Cancel")], { cancelId: 1 });
    if (showResult.choice === 0) {
    result = await this.launchVsCode(<ILaunchVSCodeArguments>request.arguments);
    } else {
    response.success = false;
    safeSendResponse(response);
    await this.shutdown();
    }
    }
    response.body = {
    rendererDebugPort: result.rendererDebugPort,
    };
    safeSendResponse(response);
    } catch (err) {
    response.success = false;
    response.message = err.message;
    safeSendResponse(response);
    }
    break;
    case 'runInTerminal':
    try {
    const shellProcessId = await dbgr.runInTerminal(request.arguments as DebugProtocol.RunInTerminalRequestArguments, this.sessionId);
    const resp = response as DebugProtocol.RunInTerminalResponse;
    resp.body = {};
    if (typeof shellProcessId === 'number') {
    resp.body.shellProcessId = shellProcessId;
    }
    safeSendResponse(resp);
    } catch (err) {
    response.success = false;
    response.message = err.message;
    safeSendResponse(response);
    }
    break;
    default:
    response.success = false;
    response.message = `unknown request '${request.command}'`;
    safeSendResponse(response);
    break;
    }
    }
  • The implementation should use the same code path as VS Code's extension API debug.startDebugging. See
    public async $startDebugging(folder: UriComponents | undefined, nameOrConfig: string | IDebugConfiguration, options: IStartDebuggingOptions): Promise<boolean> {
    const folderUri = folder ? uri.revive(folder) : undefined;
    const launch = this.debugService.getConfigurationManager().getLaunch(folderUri);
    const parentSession = this.getSession(options.parentSessionID);
    const saveBeforeStart = typeof options.suppressSaveBeforeStart === 'boolean' ? !options.suppressSaveBeforeStart : undefined;
    const debugOptions: IDebugSessionOptions = {
    noDebug: options.noDebug,
    parentSession,
    lifecycleManagedByParent: options.lifecycleManagedByParent,
    repl: options.repl,
    compact: options.compact,
    debugUI: options.debugUI,
    compoundRoot: parentSession?.compoundRoot,
    saveBeforeRestart: saveBeforeStart
    };
    try {
    return this.debugService.startDebugging(launch, nameOrConfig, debugOptions, saveBeforeStart);
    } catch (err) {
    throw new ErrorNoTelemetry(err && err.message ? err.message : 'cannot start debugging');
    }
    }

Metadata

Metadata

Assignees

Labels

debugDebug viewlet, configurations, breakpoints, adapter issuesfeature-requestRequest for new features or functionalityinsiders-releasedPatch has been released in VS Code Insiderson-testplan

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions