在调试vscode中的C文件时遇到问题

时间:2019-12-18 15:55:10

标签: debugging visual-studio-code

我有一个C文件,我正在尝试调试但失败。 我在Windows 10上使用vscode。 该文件很大,因此我不想在这里复制它。

这是我的launch.json文件在我正在使用的文件夹中的.vscode文件夹中的外观:

{
    // 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": "gcc.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc.exe build active file"
        }
    ]
}

这是我的task.json在同一.vscode文件夹中的样子:

{
    "tasks": [
        {
            "type": "shell",
            "label": "gcc.exe build active file",
            "command": "C:\\MinGW\\bin\\gcc.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\MinGW\\bin"
            }
        }
    ],
    "version": "2.0.0"
}

当我按下“开始调试”按钮时,屏幕冻结,程序停止运行,然后vscode崩溃

1 个答案:

答案 0 :(得分:0)

我设法找到一个解决方案,我删除了旧文件,单击“调试”,它要我创建新配置,选择了gcc启动,然后有一个选项“ gcc.exe构建并调试活动文件”,单击了它,现在一切正常。 如果将来有人遇到相同的问题,我已经将上面文件的内容更新为现在的样子。