vscode调试报错

程序能够运行,但不是我想要的结果,所以想通过调试找到问题

但调试显示如下

img

然后我的launch.json文件内代码如下

{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

    {
        "name": "(gdb) Windows 上的 Bash 启动",
        "type": "cppdbg",
        "request": "launch",
        "program": "输入程序名称,例如 ${workspaceFolder}/a.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": false,
        "pipeTransport": {
            "debuggerPath": "/usr/bin/gdb",
            "pipeProgram": "${env:windir}\\system32\\bash.exe",
            "pipeArgs": ["-c"],
            "pipeCwd": ""
        },
        "setupCommands": [
            {
                "description": "为 gdb 启用整齐打印",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            },
            {
                "description":  "将反汇编风格设置为 Intel",
                "text": "-gdb-set disassembly-flavor intel",
                "ignoreFailures": true
            }
        ]
        
    },
    {
        "name": "(gdb) Windows 上的 Bash 启动",
        "type": "cppdbg",
        "request": "launch",
        "program": "输入程序名称,例如 ${workspaceFolder}/a.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": false,
        "pipeTransport": {
            "debuggerPath": "/usr/bin/gdb",
            "pipeProgram": "${env:windir}\\system32\\bash.exe",
            "pipeArgs": ["-c"],
            "pipeCwd": ""
        },
        "setupCommands": [
            {
                "description": "为 gdb 启用整齐打印",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            },
            {
                "description":  "将反汇编风格设置为 Intel",
                "text": "-gdb-set disassembly-flavor intel",
                "ignoreFailures": true
            }
        ]
    },
    {
        "name": "Debug(C++)",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "F:\\mingw64\\bin\\gdb.exe",
        "setupCommands": [
            {
                "description": "为 gdb 启用整齐打印",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "g++"
    }
]

}

运行结果及报错内容
我的解答思路和尝试过的方法

我找了好多答案,说是因为不在当前文件夹?然后添加一个 "cwd":"" , 但是我的这个文件和他们的长得不一样,我也不知道添加到哪里,然后我看到我文件中有这个代码,但他是这样的 "cwd": "${fileDirname}", 我把后面的删掉了,也不行,报错变成了这样

img

求指点要怎么弄,我已经反反复复下载安装很多次vscode了

img


这个拉下来,选择Debug(C++),然后再f5,根据你的launch.json来看,只有Debug(C++)可以,其他的program名字都是错的

你再检查一下是不是对应的依赖插件没有装好或者环境没有配好,如果你实在找不到原因可以先下载dev-c++,专门用来编写c系列语言的软件,操作简单,无需配置其他的东西,下载安装好就可以使用,深受广大用户喜爱

报错内容说了找不到bash.exe,你是不是gdb 没装好,或者路径不对,这不是vscode的问题

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632