Author Topic: Cygwin and Unix Style Paths  (Read 10089 times)

Offline thefurlong

  • Single posting newcomer
  • *
  • Posts: 2
Cygwin and Unix Style Paths
« on: March 18, 2010, 05:54:18 pm »
Hello, I am trying to use Cygwin's version of the gdb debugger.  However, whenever I set breakpoints, I get the message Cannot open file
C:\FOO\\cygdrive\c\FOO\main.cpp, where FOO is the name of the directory where my source files are located.  When I manually use gdb in the Bash shell, as long as I use the path /cygdrive/c/FOO/, it works correctly.  From my glib understanding of how Code Blocks uses gdb, it seems to me that gdb is actually able to locate the executable, but Code Blocks is then unable to convert the Unix style path that it returns into the corresponding DOS path.  Is there any workaround for this?

Also, I would respectfully ask you not to suggest that I take a look at the Code Blocks source.  I am a professional developer, and have already wasted enough time trying to get Cygwin to work with Code Blocks in the first place.  Any other advice is welcome.  Thank you.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9597
Re: Cygwin and Unix Style Paths
« Reply #1 on: March 18, 2010, 06:05:47 pm »
Any other advice is welcome.  Thank you.
Well... you should at least tell what version of C::B/Cygwin/GDB you are using. You may want to try a nightly in case you are using C::B 08/02. There has been a lot development in this area since the 08/02 days...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline thefurlong

  • Single posting newcomer
  • *
  • Posts: 2
Re: Cygwin and Unix Style Paths
« Reply #2 on: March 18, 2010, 06:23:03 pm »
Thank you for your response.  Sorry about that.  I am using C::B version 8.02, Cygwin version 1.7.1-1, and gdb version 6.8-2.

Offline samho5888

  • Single posting newcomer
  • *
  • Posts: 2
Re: Cygwin and Unix Style Paths
« Reply #3 on: October 13, 2010, 01:28:29 pm »
Execuse me.
Did this issue have a solution?
http://forums.codeblocks.org/index.php/topic,2853.0.html seems to have the similar syndrome.

I use Win7, Cygwin-1.7.7, gdb-6.8, C::B r6688

The same simple project is OK by using MinGW.
But I need to use Cygwin and I can compile but can NOT debug well.
The cursor of current debug line can not located to proper position.

Under "Debugger" window, it shows:
Code: [Select]
Warning: /cygdrive/c/Temp/new/C: No such file or directory.
Child process PID: 4572
Cannot open file: C:\Temp\new\\cygdrive\c\Temp\new\main.c
At /cygdrive/c/Temp/new/main.c:13

Under "Debugger (debug)" window, it shows:
Code: [Select]
PATH=.;C:\Cygwin\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Tools\TortoiseSVN\bin;C:\Tools\Cppcheck\;C:\ToolsP\GnuWin32\bin
Command-line: C:\cygwin\bin\gdb.exe -nx -fullname  -quiet -args bin/Debug/new.exe
Working dir : C:\Temp\new\
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.8.0.20080328-cvs (cygwin-special)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-cygwin".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set debugevents on
>>>>>>cb_gdb:
> set new-console on
>>>>>>cb_gdb:
> set disassembly-flavor att
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined.
>>>>>>cb_gdb:
> source C:\Tools\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> directory C:/Temp/new/
Warning: /cygdrive/c/Temp/new/C: No such file or directory.
Warning: /Temp/new: No such file or directory.
>>>>>>cb_gdb:
> break "C:/Temp/new/main.c:13"
Breakpoint 1 at 0x4011cb: file C:/Temp/new/main.c, line 13.
>>>>>>cb_gdb:
> run
Error: dll starting at 0x77870000 not found.
Error: dll starting at 0x758d0000 not found.
Error: dll starting at 0x77870000 not found.
Error: dll starting at 0x77990000 not found.
gdb: win32_init_thread_list
[New thread 4572.0xce8]
[New thread 4572.0x1bc8]
Breakpoint 1, main () at C:/Temp/new/main.c:13
/cygdrive/c/Temp/new/main.c:13:159:beg:0x4011cb
>>>>>>cb_gdb:
> set debugevents off
>>>>>>cb_gdb:


Could anyone kindly give me some hints?

Thanks.

Offline nightlight

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Cygwin and Unix Style Paths
« Reply #4 on: November 30, 2010, 12:23:56 am »
I am getting the same problem with cygwin gdb. Here is the debugger window dump:

Quote
Debug
Adding source dir: C:\C\exp\cyg\
Adding source dir: C:\C\exp\cyg\
Adding source dir: C:\
Adding file: cyg.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
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

It seems the debugger concatenated the /cygdrive/.. path (green color) with the same path in Windows format (red color). I have checked command line to gdb (with process viewer) and that line doesn't have any paths or file items, so the paths and file names are being passed to gdb some other way. Has someone found a workaround for this problem?

Offline reckless

  • Regular
  • ***
  • Posts: 334
Re: Cygwin and Unix Style Paths
« Reply #5 on: November 30, 2010, 02:43:15 pm »
yep getting same behaviour in some projects on msys its damn annoying.

normally i can get around it by sifting through the makefile usually i hit something like this $(SOMETHING)/$(SOMETHINGELSE) and then removing the / between them.
but thats is at best a hack not a workaround.

Offline nightlight

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Cygwin and Unix Style Paths
« Reply #6 on: December 01, 2010, 01:23:59 pm »
yep getting same behaviour in some projects on msys its damn annoying.

normally i can get around it by sifting through the makefile usually i hit something like this $(SOMETHING)/$(SOMETHINGELSE) and then removing the / between them.
but thats is at best a hack not a workaround.

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 01, 2010, 01:27:05 pm by nightlight »