需要提前安装好gdb
cmake版本低于3.7.2,不能自动支持debug,vscode的现象就是断点不会停住。
需要指定cmake的版本>3.7.2
sudo apt-get install build-essential gdb
task配置
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "task1",
"command": "bash ./build.sh",
"args": [],
"options": {
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
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": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/server", //只改这里
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "task1" //可以新增一条
}
]
}