如何使用vscode附加到远程gdb? [英] How to attach to remote gdb with vscode?

查看:170
本文介绍了如何使用vscode附加到远程gdb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用vscode进行远程C/C ++ gdb调试.我在配置时使用本地调试"扩展名.这是我的 launch.json 配置

I want to do remote C/C++ gdb debug with vscode. I use "Native Debug" extension where I do configuration. Here is my launch.json configuration

{
        "type": "gdb",
        "request": "launch",
        "name": "Launch Program (SSH)",
        "target": "./hello",
        "cwd": "/home/root/test1/",
        "ssh": {
            "host": "192.168.15.130",
            "cwd": "/home/root/test1/",
            "password": "",
            "user": "root"
} 

目标运行

gdbserver localhost:2000 ./hello

很遗憾,我无法与远程设备连接进行调试.有没有配置此方面的经验?

Unfortunately after I can't sill connect with remote device to debug. Is there someone with experience on configuring of this?

推荐答案

我在这里找到了这个问题的答案:可以连接到远程服务器吗gdb目标与vscode?

I found the answer of this question here: Is it possible to attach to a remote gdb target with vscode?

摘要:

首先,您需要为VS Code安装本机调试扩展.

First you need to install the Native Debug extension for VS Code.

然后编辑launch.json文件并添加:

Then edit launch.json file and add:

{
    "type": "gdb",
    "request": "attach",
    "name": "Attach to gdbserver",
    "executable": "<path to the elf/exe file relative to workspace root in order to load the symbols>",
    "target": "X.X.X.X:9999",
    "remote": true,
    "cwd": "${workspaceRoot}", 
    "gdbpath": "path/to/your/gdb",
    "autorun": [
            "any gdb commands to initiate your environment, if it is needed"
        ]
}

然后,您可以重新启动VS Code并开始调试.确保没有其他客户端连接到gdb服务器,否则您将收到超时错误.

Then you can restart the VS Code and start debugging. Make sure there is no other client is connected to the gdb-server otherwise you will get time-out error.

这篇关于如何使用vscode附加到远程gdb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆