【问题标题】:My VSCode debugger dosen't show any variable value (image attached)(c++)我的 VSCode 调试器不显示任何变量值(附图片)(c++)
【发布时间】:2020-06-23 08:29:04
【问题描述】:

我最近开始使用 VSCode,但似乎不知道如何使用调试器。c++ 调试器不显示任何可读的值。

p.s 我已经安装了 microsoft 的 c++ intellisense 扩展。

编辑:screenshot after stepping over

Variable not showing their values during debugging

我的launch.json:

{
"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": "${workspaceFolder}",
    "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": "g++.exe build active file"
  }
]

}

我的任务.json:

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

【问题讨论】:

  • 在截图中;此时(在第 9 行调试),msg 尚未初始化,因此它没有可显示的值...尝试跨步,as in the tutorial describes I suppose you are using
  • 我在跨步后添加了一张图片,解决方案无法解决我的问题。
  • 我也有同样的问题。检查我最近的问题。你找到解决办法了吗?
  • 只需删除现有的 MinGW 并从这里安装 MinGW-W64 sourceforge.net/projects/mingw-w64 它对我有用。
  • 是的,非常感谢@StupidMan,我必须按照您的指示卸载我的 MinGW-w32 并且必须安装 MinGW-W64调试器现在可以工作了

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


【解决方案1】:

按照@StupidMan 的指示卸载 MinGW-w32 并安装 MinGW-W64

【讨论】:

    猜你喜欢
    • 2023-02-06
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 2018-07-09
    • 2011-03-14
    • 2015-09-14
    • 1970-01-01
    • 2011-06-05
    相关资源
    最近更新 更多