如何在VScode中配置json文件进行远程调试?

时间:2021-03-04 17:47:56

标签: linux visual-studio-code gdb gdbserver

我想要一个远程选项来调试应用程序。为此,我从以下配置创建了“launch.json”文件:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "gdb",
            "request": "attach",
            "name": "Attach to gdbserver",
            "executable": "/home/jakub/repo/app/build/app",
            "target": "193.168.100.1:2345",
            "remote": true,
            "cwd": "/home/jakub/repo/app", 
            "gdbpath": "/home/jakub/repo/ext-toolchain/bin/arm-linux-gnueabihf-gdb",
            "autorun": [
                    "info break"
                ]
        }
    ]
}

首先我在arm板上启动GDB Server:

# gdbserver :2345 app
Process app created; pid = 173
Listening on port 2345

然后调试器在 vscode 中触发但没有任何反应,没有错误或反应。我只有暂停、重启和断开连接按钮。该程序绝对正确构建为调试,因为我能够通过 GDB 控制台进行连接

1 个答案:

答案 0 :(得分:0)

它应该适用于这个启动配置:

{
    "name": "Attach to gdbserver",
    "type": "cppdbg",
    "request": "launch",
    "program": "/home/jakub/repo/app/build/app",
    "args": [],
    "stopAtEntry": false,
    "cwd": "${workspaceRoot}",
    "environment": [],
    "externalConsole": true,
    "MIMode": "gdb",
    "setupCommands": [
        {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
        }
    ],
    "miDebuggerServerAddress": "193.168.100.1:2345",
    "miDebuggerPath": "/home/jakub/repo/ext-toolchain/bin/arm-linux-gnueabihf-gdb"
}

运行后: gdbserver localhost:2345 app

连接所有东西可能需要几秒钟的时间。