Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt DAP's 'startDebugging' request #160169

Closed
weinand opened this issue Sep 6, 2022 · 0 comments · Fixed by #164530
Closed

Adopt DAP's 'startDebugging' request #160169

weinand opened this issue Sep 6, 2022 · 0 comments · Fixed by #164530
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan
Milestone

Comments

@weinand
Copy link
Contributor

weinand commented Sep 6, 2022

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');
    }
    }
@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Sep 6, 2022
@roblourens roblourens added this to the October 2022 milestone Sep 6, 2022
@roblourens roblourens added the feature-request Request for new features or functionality label Oct 10, 2022
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Oct 25, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants