1. 安装插件
设置界面 右键最左边tab栏:
主体: vscode
插件: Remote SSH
Linux主体: vscode-server
插件: C/C++, CMake, CMake Tools, CodeLLDB, Rainbow Brackets, vscode-proto3, SVN
虚拟化主体: multipass + linux发行版(比如ubuntu)
补充: multipass实例本地端口转发代理Proxy(自己写)
launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Server-Remote-9101",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/testHello_gdb",
"args": [],
"cwd": "${workspaceFolder}/build/",
"MIMode": "gdb",
"miDebuggerServerAddress": "192.168.157.133:9101",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"type": "lldb",
"request": "attach",
"name": "Attach-Srv",
"pid": "${command:pickMyProcess}"
},
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/testHello",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
json文件一般要改的就下面这些
"name": "g++ - 生成和调试活动文件", // 配置名称,显示在启动配置下拉菜单中
"type": "cppdbg", //配置类型
"request": "launch", //请求配置类型
"program": "${workspaceFolder}/build/main", //代表的可执行文件的绝对路径
"args": [], //传递给程序的命令行参数
"stopAtEntry": false, //可选参数。如果为true,则调试程序应在目标的入口点处停止。如果床底了processId,则不起任何作用
"cwd": "${workspaceFolder}", //cd到工程的顶层目录
"environment": [], //要添加到程序中的环境变量{"name":"config","value":"Debug"}
"externalConsole": false, //true:启动控制台;false:在vscode的集成的控制台显示
"MIMode": "gdb", //调试方式