首页 > 解决方案 > 我无法从 mingw 开始使用 gdb 进行调试

问题描述

我正在按照本指南在 VSCode 中使用 mingw 和 c++,但我陷入了让我开始调试的步骤。VSCode 控制台给了我这个错误:

错误:无法开始调试。GDB 意外退出。程序 'G:\ccompiler\projects\helloworld\helloworld.exe' 以代码 0 (0x00000000) 退出。

错误:在启动过程中程序以代码 0xc0000139 退出。

有人可以帮我解决这个问题吗?我的代码和 JSON 文件与指南中的完全相同,除了我的 mingw 文件夹的编译器和调试器路径。

我的launch.json

{
    "version": "0.2.0",
     "configurations": [

         {
             "name": "(gdb) Launch",
             "type": "cppdbg",
             "request": "launch",
             "program": "${workspaceFolder}/helloworld.exe",
             "args": [],
             "stopAtEntry": true,
             "cwd": "${workspaceFolder}",
             "environment": [],
             "externalConsole": false,
             "MIMode": "gdb",
             "miDebuggerPath": "G:/ccompiler/mingw32/bin/gdb.exe",
             "setupCommands": [
                 {
                     "description": "Enable pretty-printing for gdb",
                     "text": "-enable-pretty-printing",
                     "ignoreFailures": true
                 }
             ]
         }
     ]
 }

我的源代码:

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{

    vector<string> msg {"Hello", "C++", "World", "from", "VS Code!"};

    for (const string& word : msg)
    {
        cout << word << " ";
    }
    cout << endl;
}

标签: c++jsonvisual-studio-codemingw

解决方案


推荐阅读