前提条件:
本次搭建的环境:
首先安装 Remote Development 插件,安装完成之后:
如上图所示,输入:Remote-SSH:Connect to Host->Configure SSH Hosts->选择一个config,配置信息:
# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
Host Server
HostName 10.10.1.111
User name
其中:
输入完毕后保存,左侧会出现配置好的信息,右键登陆,可能需要密码:
连接到 server 后会发现,安装的插件分为两栏,可以在远程服务器安装需要的插件:
Ctrl + ~ 打开终端窗口,VS Code 连接到远程主机后,就可以直接使用终端窗口在远程主机上执行终端命令。
配置 gdb 的配置文件 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": "cppdbg",
"request": "launch",
"name": "Debug for test",
"skipFiles": [
"<node_internals>/**"
],
"args": [],
"program": "${workspaceFolder}/build/bin/test.debug",
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath":"/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/aarch64-himix100-linux-gdb",
"miDebuggerServerAddress": "192.168.172.110:1234"
}
]
}
./gdbserver :1234 test.debug
VSCode 按 F5 开始调试:
断点设置,变量、栈查看:
原文:https://www.cnblogs.com/xiaojianliu/p/12614408.html