我正在尝试在 Visual Studio 代码中进行调试还没有成功

问题描述

我用msys64下载gdb, 我的 launch.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":true,"cwd":"C:\\msys64\\mingw64\\bin","environment": [],"externalConsole": false,"MIMode": "gdb","miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe","setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true,}
            ]
        },]
}

我错过了什么吗? 我认为问题出在程序路径上:

"program": "${fileDirname}\${fileBasenameNoExtension}.exe",

当我启动调试时,它不会在断点处停止。 当我按 f5 时,它会打开一个包含不同目录的新文件夹。

这是我的 task.json:

{
    "version": "2.0.0","tasks": [
        {
            "type": "cppbuild","label": "C/C++: cpp.exe build active file","command": "C:\\msys64\\mingw64\\bin\\g++.exe","args": [
                "-g3","-Wall","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],"options": {
                "cwd": "${workspaceFolder}"
            },"problemmatcher": [
                "$gcc"
            ],"group": {
                "kind": "build","isDefault": true
            },"detail": "compiler: C:\\msys64\\mingw64\\bin\\cpp.exe"
        },{
            "type": "shell","label": "Run C++ Program: g++.exe","command": "C:\\msys64\\mingw64\\bin\\cpp.exe -g3 -Wall \"${file} -o  \"${fileDirname}\\${fileBasenameNoExtension}.exe\" &&$\"{fileDirname}\\${fileBasenameNoExtension}.exe\"","options": {
                "cwd": "C:\\msys64\\mingw64\\bin"
            },"detail": "compiler: C:\\msys64\\mingw64\\bin\\cpp.exe"
        }
    ]
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)