vscode debug C++ 时无法打开控制台(或者说运行不了 gdb.exe)?

我在使用 vscode 配置 C++ 环境时

c_cpp_properties.json , tasks.json 都配置好了,

编译项目和自动识别头文件,自动补全代码等都没有问题。

但是我的 launch.json 不知道是不是出了问题

无论怎么按 F5 都没有弹出控制台窗口 !!??

不管内部还是外部控制台都没有弹出

一直停留在下面这个界面

图片说明

*** 没有报错!! ***

*** 编译也一切正常 ***

** 我的 c_cpp_properties.json , tasks.json 和 launch.json 如下 **

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}\\**",
                "${workspaceFolder}\\**\\**",
                "D:\\Program Files\\mingw64\\include",
                "D:\\Program Files\\mingw64\\opt\\include",
                "D:\\Program Files\\mingw64\\opt\\lib\\libffi-3.2.1\\include",
                "D:\\Program Files\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include",
                "D:\\Program Files\\mingw64\\x86_64-w64-mingw32\\include",
                "D:\\Program Files\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++",
                "D:\\Program Files\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++\\bits",
                "D:\\Program Files\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++\\x86_64-w64-mingw32\\bits",
                "D:\\Program Files\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++\\x86_64-w64-mingw32"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "cStandard": "c11",
            "intelliSenseMode": "msvc-x64",
            "configurationProvider": "vector-of-bool.cmake-tools"
        }
    ],

    "version": 4
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared"
            },
            "windows": {
                "command": "D:\\MyData\\Programming\\C++Workspace\\.vscode\\make.sh",
                "args": [
                    "${fileDirname}",
                    "${fileBasenameNoExtension}"
                ]
            },
            "linux": {
                "command": "bash"
            },
            "args": []
        },
    ]
}

launch.json


{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\Program Files\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        },
    ]
}

我的c_cpp_properties.json 和 tasks.json 应该是没有出错的

因为并没有报头文件包含错误和编译错误

我在命令行下用 mingw32-make 编译是完全没有问题的

在命令行下用 gdb 调试也完全没有问题

所以不要考虑我出现的错误是环境变量什么的。

我的 git-bash 也运行正常,所以我的sh 文件也是能正常运行的

但是我在调试的时候没法打开控制台窗口 !!!

** 是我的 vscode 无法运行 gdb ?!! **

还是我的 vscode 无法运行cmd?!!

如下launch.json可以正常工作,仅供参考:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch (GDB)",                 // 配置名称,将会在启动配置的下拉菜单中显示
            "type": "cppdbg",                           // 配置类型,这里只能为cppdbg
            "request": "launch",                        // 请求配置类型,可以为launch(启动)或attach(附加)
            "launchOptionType": "Local",                // 调试器启动类型,这里只能为Local
            "targetArchitecture": "x86",                // 生成目标架构,一般为x86或x64,可以为x86, arm, arm64, mips, x64, amd64, x86_64
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",                   // 将要进行调试的程序的路径
            "miDebuggerPath":"D:\\Program Files\\mingw64\\bin\\gdb.exe", // miDebugger的路径,注意这里要与MinGw的路径对应
            "args": [],     // 程序调试时传递给程序的命令行参数,一般设为空即可
            "stopAtEntry": false,                       // 设为true时程序将暂停在程序入口处,一般设置为false
            "cwd": "${workspaceRoot}",                  // 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
            "externalConsole": true,                    // 调试时是否显示控制台窗口,一般设置为true显示控制台
            "preLaunchTask": "g++"                    // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc
        }
    ]
}

c_cpp_properties.json
的截图可以麻烦截一下吗 因为之前配置msys2 改动了一下 之后 打不开撞断的窗口了。。。
The terminal process terminated with exit code: 4294770688

我去兄弟你最后解决了吗?我这边也是这个样子和你完全一样,困扰好多天了!!!!!!!!!!