Author Topic: Fix for Cygwin+GDB problem (gdb can't find source files)  (Read 11923 times)

Offline nightlight

  • Multiple posting newcomer
  • *
  • Posts: 21
Fix for Cygwin+GDB problem (gdb can't find source files)
« on: December 02, 2010, 12:25:02 am »
The combo of recent Cygwin versions (1.7+) with C::B has broken gdb plugin support due to changes in Cygwin registry entries. As results the GDB cannot find the source file and one can't use GUI debugging. An example of error message one gets is below:

Quote
Debugger name and version: GNU gdb 6.8.0.20080328-cvs (cygwin-special)
Warning: /cygdrive/c/C/exp/cyg/C: No such file or directory.
Warning: /cygdrive/c/C/exp/cyg/C: No such file or directory.
Child process PID: 2560
Cannot open file: C:\C\exp\cyg\\cygdrive\c\C\exp\cyg\main.c
At /cygdrive/c/C/exp/cyg/main.c:60

Checking the debugger plugin source, I noticed a method GDB_driver::DetectCygwinMount where they check for the presence of Cygwin and obtain the virtual cygdrive prefix from registry. Since cygwin has changed in the latest rev 1.7 its handling of registry (it took everything out), the debugger plugin failed to detect the cygwin and then misbehaved as described above. Looking through older cygwin docs, I found the piece that debugger plugin is missing, put it in the registry by hand and gdb started working correctly.

Here is the fix:

1. Run regedit and locate in registry the key:

   HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2

2. Right click in the right pannel (it's empty since cygwin 1.7) and select New,
    then submenu "String value". It will ask you for the string name - enter:

    cygdrive prefix

    then right click the name to set the string value as:

    /cygdrive


Restart C::B and the debugger will now work.
« Last Edit: December 02, 2010, 12:29:51 am by nightlight »

Offline gamert

  • Single posting newcomer
  • *
  • Posts: 3
Re: Fix for Cygwin+GDB problem (gdb can't find source files)
« Reply #1 on: September 24, 2011, 07:46:10 am »
1. "Cygnus solutions" key has been moved from cygwin 1.7? I only find HKLM\Cygwin after cygwin setup.

Offline elimcodmartinez

  • Single posting newcomer
  • *
  • Posts: 4
Re: Fix for Cygwin+GDB problem (gdb can't find source files)
« Reply #2 on: February 06, 2014, 08:24:28 am »
The solution given above was not enough, you need to create the "cygdrive prefix" value in these two keys:

    HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
    HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\mounts v2

which, by the way, do not exist (@gamert, you must create both Cygnus Solutions keys...).

I found that here:
http://stackoverflow.com/questions/20477387/cygwin-with-codeblocks-debugger-error

It's three years old, shouldn't those keys be created by default or be configurable somewhere easy to find?
Hopefully I'll remember this after the next install :-/