【问题标题】:VSCode debug adapter not calling launchRequestVSCode 调试适配器未调用 launchRequest
【发布时间】:2020-03-21 20:19:53
【问题描述】:

我正在尝试学习调试器 API,并决定尝试为 SBCL 调试器编写一个调试器扩展作为练习。我不确定为什么我的所有代码都是调用 initializeRequest 和 disconnectRequest。

这是我的 package.json 中的内容

        "debuggers": [
            {
                "type": "common-lisp",
                "label": "Common Lisp REPL",
                "initialConfigurations": [
                    {
                        "type": "common-lisp",
                        "name": "Common Lisp REPL",
                        "request": "launch"
                    }
                ]
            }
        ],

我的工厂类是在它自己的模块中定义的,

const { DebugAdapterInlineImplementation } = require('vscode');

module.exports.Factory = class {
    createDebugAdapterDescriptor(session) {
        return new DebugAdapterInlineImplementation(new Session());
    }
};

我的 Session 类在它自己的模块中,

const { LoggingDebugSession } = require('vscode-debugadapter');

module.exports.Session = class extends LoggingDebugSession {
    constructor() {
        super('common-lisp-debug.txt');
    }

    initializeRequest(response, args) {
        console.log('initializeRequest');

        response.body = {
            supportsConfigurationDoneRequest: true,
        };

        this.sendResponse(response);
    }

    disconnectRequest(response, args) {
        console.log('disconnectRequest');
    }

    configurationDoneRequest(response, args) {
        console.log('configurationDoneRequest');
        super.configurationDoneRequest(response, args);
    }

    launchRequest(response, args) {
        console.log('launchRequest');
        this.sendResponse(response);
    }
};

我的 extension.js 在激活调用中有这段代码,

    const factory = new Factory();
    ctx.subscriptions.push(vscode.debug.registerDebugAdapterDescriptorFactory('common-lisp', factory));
    if ('dispose' in factory) {
        ctx.subscriptions.push(factory);
    }

我开始调试我的扩展程序,这会打开 EDH 窗口。我创建了一个调试配置,它完成了它应该做的事情并创建了这个 launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "common-lisp",
            "name": "Common Lisp REPL",
            "request": "launch"
        }
    ]
}

当我从那里启动调试器时,我看到 initializeRequest 被打印出来,但没有别的。调试窗口的蓝点进度无限循环。当我单击停止调试时,我看到 disconnectRequest 被打印出来。

为什么没有调用 configurationDoneRequest 和 launchRequest?还有,LoggingDebugSession 把日志文件放在哪里?

更新:当我启动调试器时,CPU 使用率跃升至 35%,所以它正在做某事。当我点击暂停时,几乎每次它都在 timers.js 中停止

  function processTimers(now) {
    debug('process timer lists %d', now); // Debugger pauses on this line
    nextExpiry = Infinity;

【问题讨论】:

    标签: visual-studio-code vscode-extensions vscode-debugger


    【解决方案1】:

    我遇到了同样的问题,尽管我的调试适配器服务器是用 Java 编写的。原来我在initialize 请求期间/之后没有发送initialized 事件,请参阅DAP 文档中关于initialized event 的部分。

    编辑:规范规定initialized 事件必须在initialize 请求之后发送。从 attach 请求发送它对于 VSCode 是可以接受的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-23
      • 2022-11-24
      • 1970-01-01
      • 2021-05-02
      • 1970-01-01
      • 1970-01-01
      • 2020-09-01
      • 1970-01-01
      相关资源
      最近更新 更多