views:

2797

answers:

3

I'm using Eclipse on Windows to program C++ using Cygwin's toolchain. I would like to use it for debugging as well, but my problem is the following:

  • The executable to debug is in a sub-folder of the workspace (pretty standard, I guess) but not of the actual Project from which the executable is built.
  • Eclipse and GDB have different path formats: Eclipse works with Windows paths, whereas GDB works with posix paths. Eclipse knows D:\Path\To\Exe whereas GDB needs /cygdrive/d/Path/To/Exe.
  • Eclipse insists that it can find the executable to debug when I enter the path in the "Debug configurations..." dialog. The "Debug" button is disabled until the path is correct.
  • Eclipse does not seem to take ${workspace_loc} in that particular input box.

Is there some hidden option I don't know about? Have you had the problem before?

What I've tried so far

  • Forcing Eclipse to pass the path I input to GDB --- did not work.
  • Fiddling with source lookup paths and path mappings --- did not work, it's really just for source files.
  • Creating a C++ Project for the output folder where the executable is, so I could have a relative path to the exe inside the project --- did not work.

Things I could still try

  • Use the .gdbinit file to discard the path given by Eclipse and load the real executable with posix paths --- tried that, but not very hard.
  • Specify a wrapper as argument to GDB --- pollutes the root of my workspace.
  • Provide my own plug-in to deal with the case --- adds another piece of code to maintain in another language.
+1  A: 

Cygwin comes with a program called cygpath to translate paths from windows to unix and vice-versa, e.g.

$ cygpath -u 'c:\Users\Andrew\Documents\svn'
/cygdrive/c/Users/Andrew/Documents/svn

do a cygpath --help for more info.

So you probably want to write a wrapper for GDB that translates any windows-specific paths to unix paths, and then invokes the real GDB.

andrew
+1  A: 

In Eclipse in Preferences->C/C++->Debug->"Common Source Lookup Path" add new path mapping. As compilation path you should use Unix like path (e.g. /cygdrive/c), as local system path you should use Windows like path (e.g. c:).

Thanks, pensamiento, I did try that, but it did not work. My understanding is that this path mapping does not affect the path that Eclipse hands to GDB as executable to debug. The name of the setting does not suggest that this should work, either.
Carl Seleborg
This worked for me. Thanks pensamiento!
Ben Gartner
A: 

The problem went away when upgrading to Eclipse Ganymede.

Carl Seleborg