Search code examples
visual-studio-codegdbcygwin

Cygwin GDB and VSCode


Trying to debug an executable in VS Code over Cygwin's version of GDB (9.2).

The executable comes from Free Pascal, Win32-x86. It has GDB compatible DWARF debug symbols. Standalone GDB under Cygwin can open the exe and run it, no problem. I can sort of work it with Cygwin/DDD over GDB, even though DDD is rather buggy.

I'm trying to do the same from Visual Studio Code. The launch.json goes:

{
        "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
            }
        ]
    }

When I try to launch, the command line in the terminal window goes:

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'

but then the progress bar over the left pane keeps going forever, as if the debugging server won't start or won't connect properly. The program itself is supposed to run and terminate rather quickly; this is clearly not happening.

What am I missing?

LATE EDIT: The PATH trick helped, but it looks like debug symbol loading and parsing is being done in VSCode, not by GDB. PDB symbols (for a dependent DLL) are loaded, DWARF ones aren't. Oh well, it was worth a try.


Solution

  • Latest versions of Cygwin GDB require the bin directory to be in the PATH

    (usually c:\cygwin64\bin )

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