微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决我正在尝试在 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 举报,一经查实,本站将立刻删除。