无法在 visual studio 代码中调试我的 C++ 代码
Not able to debug my c++ code in visual studio code
我不知道我的 vscode 突然发生了什么我无法调试文件虽然我正在 运行 我的 CPP 程序但无法调试请帮助我我连续花 2-3 个小时尝试修复我的调试器
我的程序 运行 运行良好,编译器正在创建一个 exe 文件,如下所示
当我按下调试按钮时,会出现此图像
然后卡在了这个画面
当我按下任何一种键时它退出并出现普通终端 window
就像它试图打开外部终端但打不开它是怎么回事我想花了一整天解决这个问题
Lauch.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": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\MinGW\bin\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
Task.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\MinGW\bin\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: C:\MinGW\bin\g++.exe"
}
]
}
正在删除
- %USERPROFILE%.vscode\extensions\ms-vscode.cpptools-1.6.0-insiders\install.lock
- %USERPROFILE%.vscode\extensions\ms-vscode.cpptools-1.6.0-insiders\debugAdapters
对我有用。 Windows10
更多信息请参阅:https://github.com/microsoft/vscode-cpptools/issues/7971
尝试将 -g
添加到标记中。 -g 是启用调试的标志。
我不知道我的 vscode 突然发生了什么我无法调试文件虽然我正在 运行 我的 CPP 程序但无法调试请帮助我我连续花 2-3 个小时尝试修复我的调试器
我的程序 运行 运行良好,编译器正在创建一个 exe 文件,如下所示
当我按下调试按钮时,会出现此图像
然后卡在了这个画面
当我按下任何一种键时它退出并出现普通终端 window
就像它试图打开外部终端但打不开它是怎么回事我想花了一整天解决这个问题
Lauch.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": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\MinGW\bin\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
Task.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\MinGW\bin\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: C:\MinGW\bin\g++.exe"
}
]
}
正在删除
- %USERPROFILE%.vscode\extensions\ms-vscode.cpptools-1.6.0-insiders\install.lock
- %USERPROFILE%.vscode\extensions\ms-vscode.cpptools-1.6.0-insiders\debugAdapters
对我有用。 Windows10
更多信息请参阅:https://github.com/microsoft/vscode-cpptools/issues/7971
尝试将 -g
添加到标记中。 -g 是启用调试的标志。