use*_*154 20 debugging visual-studio-code
我想用 vscode 做远程 C/C++ gdb 调试。我在进行配置时使用“本机调试”扩展。这是我的launch.json配置
{
"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"
}
Run Code Online (Sandbox Code Playgroud)
在目标我跑
gdbserver localhost:2000 ./hello
Run Code Online (Sandbox Code Playgroud)
不幸的是,在我无法连接远程设备进行调试之后。有没有人有这方面的配置经验?
HmT*_*HmT 16
我在这里找到了这个问题的答案: Is it possible to attach to a remote gdb target with vscode?
概括:
首先,您需要为 VS Code 安装 Native Debug 扩展。
然后编辑launch.json文件并添加:
{
"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"
]
}
Run Code Online (Sandbox Code Playgroud)
然后你可以重新启动 VS Code 并开始调试。确保没有其他客户端连接到 gdb-server 否则你会得到超时错误。
Mar*_*rdy 11
您必须在远程计算机上安装 gdbserver。例如
apt-get install gdbserver
Run Code Online (Sandbox Code Playgroud)
在远程计算机上启动 gdbserver
gdbserver :1234 ./mybinary
Run Code Online (Sandbox Code Playgroud)
选择您喜欢的任何端口 - 在这里1234
通过键入以下内容来测试从本地计算机到 gdbserver 的连接
gdb
(gdb) target remote myremotehostname:1234
Run Code Online (Sandbox Code Playgroud)
触发任何 gdb 命令来检查它是否工作 - 例如c
(或continue
)继续运行mybinary
。
将以下内容放入您的.vscode/launch.json
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/mybinary",
"miDebuggerServerAddress": "myremotehostname:1234",
"cwd": "${workspaceRoot}",
"externalConsole": true,
"linux": {
"MIMode": "gdb"
}
}
Run Code Online (Sandbox Code Playgroud)
或者使用"type": "gdb"
其他答案中给出的启动配置。
为了使代码浏览和工作正常运行,使本地和远程端的源目录同步非常重要。使用网络文件系统、手动复制、git 触发器或类似的东西来设置它。
归档时间: |
|
查看次数: |
29468 次 |
最近记录: |