VScode中C/C++调试文件配置
//launch.json
{
"version": "2.0.0",
"configurations": [
{
"name": "C/C++: gcc.exe build and debug active file", // 调试配置名称
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe", // 要调试的程序的路径
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false, // 调试时是否显示控制台窗口
"MIMode": "gdb",
"miDebuggerPath": "D:\\Software\\MinGW\\mingw64\\bin\\gdb.exe", // gdb路径,根据自己的安装路径修改
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file" // 调试前执行的任务,与tasks.json中的label对应
}
]
}
//tasks.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file", // 任务名称
"command": "D:\\Software\\MinGW\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}