Aquabet

Talk is cheap. Show me the code.

0%

Visual Studio Code C++ gdb 断点调试 配置指南

在Workspace下的.vscode目录下新建两个文件,分别为launch.json,task.json。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{//launch.json
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "x86"
"program": "${workspaceRoot}\\${fileBasenameNoExtension}.exe"
"miDebuggerPath":"C:\\mingw\\bin\\gdb.exe", //此处修改为自己的目录
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"externalConsole": true,
"preLaunchTask": "g++"
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{//task.json
"version":"2.0.0",
"command": "g++",
"args": ["-g","-std=c++11","${file}","-o","${workspaceRoot}\\${fileBasenameNoExtension}.exe"],
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}