0

我正在成功运行一个电子应用程序(在 Windows 10 上,编译器是 msvc),并且我也能够正确调试主进程和渲染器进程。

我刚刚添加了一个自定义节点本机插件(使用node-addon-api),它在主进程中导入并且运行良好。

节点本机插件是用 C++ 编写的,并使用标志构建cmake-js--debug它可以正确生成调试二进制文件。

现在我想从 VSCode 调试 C++ 插件。

以下是我当前(失败)的launch.js文件尝试。

    "version": "0.2.0",
    "configurations": [
        // {
        //     "name": "Attach C++", //Not working
        //     "type": "cppvsdbg",
        //     "request": "attach",
        //     "cwd": "${workspaceFolder}/app/node_modules/addtest", //path to the native addon source
        //     "processId": "${command:pickProcess}"
        // },
        {
            "name": "Renderer", //working
            "type": "chrome",
            "request": "attach",
            "port": 9876,
            "url": "http://localhost:4200",
            "sourceMaps": true,
            "timeout": 10000,
            "trace": "verbose",
            "sourceMapPathOverrides": {
                "webpack:///./*": "${workspaceFolder}/*"
            },
            "preLaunchTask": "Build.Renderer"
        },
        {
            "name": "Main", //working
            "type": "node",
            "request": "launch",
            "protocol": "inspector",
            "cwd": "${workspaceFolder}",
            "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
            "trace": "verbose",
            "runtimeArgs": [
                "--serve",
                ".",
                "--remote-debugging-port=9876",
                "--preserve-symlinks"
            ],
            "windows": {
                "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
            },
            "preLaunchTask": "Build.Main"
        },
    ],
    "compounds": [
        {
            "name": "Application Debug",
            "configurations": [
                "Renderer",
                "Main"
            ]
        }
    ]
}
  1. 调试 Electron 运行的本机插件的常见工作流程是什么?启动主进程调试然后附加 C++ 调试?

  2. 我应该如何编写我的 C++ 调试配置?

4

0 回答 0