Cygwin GDB 和 VSCode

问题描述

尝试在 VS Code 中通过 Cygwin 的 GDB 版本 (9.2) 调试可执行文件

可执行文件来自 Free Pascal,Win32-x86。它具有 GDB 兼容的 DWARF 调试符号。 Cygwin下的独立GDB可以打开exe运行,没问题。我可以通过 GDB 使用 Cygwin/DDD 来处理它,尽管 DDD 有很多问题。

我正在尝试从 Visual Studio Code 中做同样的事情。 launch.json 如下:

{
        "name": "(gdb) Launch","type": "cppdbg","request": "launch","program": "E:\\Path\\MyProgram.exe","args": ["-x"],"stopAtEntry": false,"cwd": "E:\\Path","environment": [],"MIMode": "gdb","miDebuggerPath": "c:\\cygwin64\\bin\\gdb.exe","setupCommands": [
            {
                "description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true
            }
        ]
    }

当我尝试启动时,终端窗口中的命令行显示

c:\Users\Seva\.vscode\extensions\ms-vscode.cpptools-1.2.1\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-w2bqan2m.tt2' '--stdout=Microsoft-MIEngine-Out-nagviahg.1gf' '--stderr=Microsoft-MIEngine-Error-udor1kbz.iot' '--pid=Microsoft-MIEngine-Pid-lhapkzkd.orq' '--dbgExe=c:\cygwin64\bin\gdb.exe' '--interpreter=mi'

但是左窗格上的进度条会一直显示,就好像调试服务器无法启动或无法正确连接一样。程序本身应该运行和终止相当快;这显然不会发生。

我错过了什么?

后期编辑:PATH 技巧有所帮助,但看起来调试符号加载和解析是在 VSCode 中完成的,而不是由 GDB 完成。 PDB 符号已加载,DWARF 符号未加载。哦,值得一试。

解决方法

Cygwin GDB 的最新版本要求 bin 目录位于 PATH 中

(通常是 c:\cygwin64\bin )

https://sourceware.org/pipermail/cygwin/2021-February/247749.html
https://sourceware.org/pipermail/cygwin/2021-February/247711.html