【问题标题】:VSCODE gdb on windows show empty file on debugWindows上的VSCODE gdb在调试时显示空文件
【发布时间】:2019-11-18 23:25:41
【问题描述】:

我尝试使用 vscode 和 gdb 为 cpp 设置 helloworld 项目。

我使用 msys2。

一切正常,项目编译并运行,但调试时遇到问题。

这是我的 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": "(gdb) Launch",
    "type": "cppdbg",
    "request": "launch",
    "program": "${workspaceFolder}/helloworld.exe",
    "args": [],
    "stopAtEntry": true,
    "cwd": "${workspaceFolder}",
    "environment": [],
    "externalConsole": true,
    "MIMode": "gdb",
    "miDebuggerPath": "C:/msys64/usr/bin/gdb.exe",
    "setupCommands": [
      {
        "description": "Enable pretty-printing for gdb",
        "text": "-enable-pretty-printing",
        "ignoreFailures": true
      }
    ]
  }
]

}

还有我的演示项目

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char** argv)
{

    vector<string> msg {"Hello", "C++", "World", "from", "VS Code!"};

    for (const string& word : msg)
    {
        cout << word << " ";
    }
    cout << endl;

}

但是当我运行调试时,它显示的只是空文件,而不是源文件,我发现在

中创建了新文件

C:\c\Users\user\projects\helloworld\

所以那里的路径有问题。

如何解决?

【问题讨论】:

    标签: c++ visual-studio-code gdb msys2 win64


    【解决方案1】:

    我使用了错误的 gdb。

    你需要安装其他版本的gdb:

     pacman -S mingw-w64-x86_64-gdb
    

    并使用它

    "miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe",
    

    【讨论】:

      猜你喜欢
      • 2020-09-25
      • 1970-01-01
      • 2022-09-28
      • 1970-01-01
      • 2020-10-28
      • 1970-01-01
      • 1970-01-01
      • 2019-12-06
      • 1970-01-01
      相关资源
      最近更新 更多