【问题标题】:Not able to debug my c++ code in visual studio code无法在 Visual Studio 代码中调试我的 C++ 代码
【发布时间】:2021-10-18 19:47:53
【问题描述】:

我不知道我的 vscode 突然发生了什么我无法调试文件虽然我要运行我的 CPP 程序但无法调试请帮助我我花了 2-3 个小时连续尝试修复我的调试器

我的程序运行良好,编译器正在创建一个 exe 文件,如下所示

当我点击调试按钮时,此图像出现

然后卡在这个屏幕上

当我按下任何类型的键时,它会退出并出现正常的终端窗口

这就像它试图打开外部终端但无法打开它,这就是我认为花了一整天解决这个问题的原因

Lauch.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": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

任务.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\MinGW\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: C:\\MinGW\\bin\\g++.exe"
        }
    ]
}

【问题讨论】:

  • 看起来你有 Visual Studio Code,而不是 Visual Studio。如果这是您的意图,请继续提问。如果你想使用 Visual Studio,恐怕你下载错了。 Here's the right one
  • 到底是什么问题?当您尝试调试时会发生什么?
  • 您必须向我们提供更多信息,说明发生了什么以及您采取了哪些步骤来找出原因。您的配置文件看起来不错。
  • 可能你无意中激活了程序结束时自动关闭执行窗口的选项?尝试在代码中的某处设置断点,看看是否可以到达它,这将缩小潜在问题的范围。顺便说一句,你在“弹出”上有一个amusing typo ;)
  • @kuroineko no bro that doesn't work 我不知道前天突然发生了什么,它工作得非常好,昨天当我试图调试一个简单的程序时,它只是没有'根本不运行

标签: c++ debugging visual-studio-code terminal


【解决方案1】:

删除

  1. %USERPROFILE%.vscode\extensions\ms-vscode.cpptools-1.6.0-insiders\install.lock
  2. %USERPROFILE%.vscode\extensions\ms-vscode.cpptools-1.6.0-insiders\debugAdapters

为我工作。视窗 10

更多信息请见:https://github.com/microsoft/vscode-cpptools/issues/7971

【讨论】:

    猜你喜欢
    • 2018-09-26
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2017-05-17
    • 2020-06-01
    • 2015-08-04
    • 1970-01-01
    • 2013-12-19
    相关资源
    最近更新 更多