1. 当前环境
(1) windows 下安装了vscode
(2) c/c++代码放在linux上、在linux上运行程序
2.配置步骤
(1) 在vscode上安装 c/c++插件
(2) 点击 运行-启动调试,选择 Node.js
(3) 再次点击 运行-启动调试,选择合适的编译器
(4) 将工作目录下 .vscode/task.json进行配置修改
# cat .vscode/tasks.json
{
"tasks": [
{
"type": "cppbuild", // 任务类型
"label": "quince_build", // 该任务的名字
"command": "./quince_build.sh", // 该任务具体执行的命令
"args": [
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "quince"
},
],
"version": "2.0.0"
}
(5) 在./vscode目录下创建launch.json
# cat .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "quince debug....",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/x86_dbg.elf", //要运行的程序名字(填编译完成后生成的可执行文件名)
"targetArchitecture": "x86",
"externalConsole": false,
"MIMode": "gdb",
"cwd": "${workspaceRoot}",
"preLaunchTask": "quince_build" //任务的名字(要和tasks.json中匹配)
},
]
}
(6) 配置完成后,运行-启动调试,就能正常调试啦,可以进行打断点、单步运行、查看调用堆栈.....