1.launch.json
{
"version": "2.0.0",
"configurations": [
{
"name": "gdb调试",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\DevC++\\Dev-Cpp\\MinGW64\\bin\\gdb.exe",//这里要改为自己电脑gdb所在位置!
"preLaunchTask": "debug gdb"
},
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "c:/Users/86151/Desktop/VSCode/CodeC/byyl",//这里要改为当前文件夹所在位置!
"program": "c:/Users/86151/Desktop/VSCode/CodeC/byyl/build/Debug/outDebug",//这里要改为当前文件夹所在位置+“/build/Debug/outDebug”
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
2.tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "debug gdb",
"command": "D:\\DevC++\\Dev-Cpp\\MinGW64\\bin\\g++.exe",//这里要改为自己电脑g++所在位置!
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "D:\\DevC++\\Dev-Cpp\\MinGW64\\bin"//这里要改为自己电脑bin所在位置!
},
"problemMatcher": [
"$gcc"
],
"group": "build"
},
{
"type": "cppbuild",
"label": "debug gdb",
"command": "D:\\DevC++\\Dev-Cpp\\MinGW64\\bin\\g++.exe",//这里要改为自己电脑g++所在位置!
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
]
}
3.settings.json
{ "C_Cpp_Runner.msvcBatchPath": "", "C_Cpp_Runner.cCompilerPath": "gcc", "C_Cpp_Runner.cppCompilerPath": "g++", "C_Cpp_Runner.debuggerPath": "gdb", "C_Cpp_Runner.cStandard": "", "C_Cpp_Runner.cppStandard": "", "C_Cpp_Runner.useMsvc": false, "C_Cpp_Runner.warnings": [ "-Wall", "-Wextra", "-Wpedantic" ], "C_Cpp_Runner.enableWarnings": true, "C_Cpp_Runner.warningsAsError": false, "C_Cpp_Runner.compilerArgs": [], "C_Cpp_Runner.linkerArgs": [], "C_Cpp_Runner.includePaths": [], "C_Cpp_Runner.includeSearch": [ "*", "**/*" ], "C_Cpp_Runner.excludeSearch": [ "**/build", "**/build/**", "**/.*", "**/.*/**", "**/.vscode", "**/.vscode/**" ], "files.associations": { "iostream": "cpp", "ostream": "cpp", "fstream": "cpp", "sstream": "cpp", "regex": "cpp", "iosfwd": "cpp", "*.tcc": "cpp", "future": "cpp" }, "C_Cpp_Runner.useAddressSanitizer": false }