Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » gdb gets incorrect path from Eclipse(Mangling of paths on Windows 10)
gdb gets incorrect path from Eclipse [message #1857449] Wed, 08 February 2023 10:47 Go to next message
Gert-Jan Schurer is currently offline Gert-Jan SchurerFriend
Messages: 3
Registered: February 2023
Junior Member
I have been using Eclipse for Java programming for quite a while. Recently I decided to use it for C++ too. It may or may not be relevant that I use the same Workspace for Java and for C++.
Eventually I got most of it working, but the debugger gets a wrong path to the executable, and I cannot find out how to rectify that. Two examples, which will hopefully make clear what is going wrong (albeit not why):

/cygdrive/c/Users/gjschurer/Desktop/D:/Develop/CPP/Compress/ScC/D:/Develop/CPP/Compress/ScC/Default/ScC.exe
/cygdrive/c/Users/gjschurer/eclipse/cpp-2022-122/eclipse/D:/Develop/CPP/Compress/ScC/D:/Develop/CPP/Compress/ScC/Default/ScC.exe

The first time I had started Eclipse from a link on my desktop, and the path to that link was inserted into the path where gdb is supposed to find the executable to debug. The second time I started Eclipse from its own executable, and then that path got mangled into the gbd argument.
It does not surprise me that gbd can't find my program to debug, given the mess that is made of the path, but it does surprise me that Eclipse is doing this.

Out of curiosity: why does this happen?
And, more seriously: how do I stop it and get Eclipse to give correct paths to the debugger (and whatever other Cygwin programs I might use later)?
Re: gdb gets incorrect path from Eclipse [message #1857457 is a reply to message #1857449] Wed, 08 February 2023 15:27 Go to previous messageGo to next message
Gert-Jan Schurer is currently offline Gert-Jan SchurerFriend
Messages: 3
Registered: February 2023
Junior Member
I realised that it might not be clear enough what error message is produced and where, so I will expand on that a bit. When I try to start the debugger, I am informed there is a problem, and the following are the details that are provided with it, from which I took the line in my previous post:

Error in final launch sequence:

Failed to execute MI command:
-exec-run
Error message from debugger back end:
Error creating process /cygdrive/c/Users/gjschurer/eclipse/cpp-2022-122/eclipse/D:/Develop/CPP/Compress/ScC/D:/Develop/CPP/Compress/ScC/Default/ScC.exe, (error 2).
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Error creating process /cygdrive/c/Users/gjschurer/eclipse/cpp-2022-122/eclipse/D:/Develop/CPP/Compress/ScC/D:/Develop/CPP/Compress/ScC/Default/ScC.exe, (error 2).
Error creating process /cygdrive/c/Users/gjschurer/eclipse/cpp-2022-122/eclipse/D:/Develop/CPP/Compress/ScC/D:/Develop/CPP/Compress/ScC/Default/ScC.exe, (error 2).
Re: gdb gets incorrect path from Eclipse [message #1857501 is a reply to message #1857457] Fri, 10 February 2023 18:21 Go to previous messageGo to next message
Gert-Jan Schurer is currently offline Gert-Jan SchurerFriend
Messages: 3
Registered: February 2023
Junior Member
The problem is not with Eclipse. It is a problem with gdb. I had downloaded the newest version (11.2-1), and that does not work. Following comments on the Internet, I tried with version 9.2-1 instead, and that does work.

Not a solution that I am particularly happy with, but it will have to do.
Re: gdb gets incorrect path from Eclipse [message #1857595 is a reply to message #1857501] Thu, 16 February 2023 12:24 Go to previous messageGo to next message
Hassan Izhar is currently offline Hassan IzharFriend
Messages: 6
Registered: January 2023
Junior Member
It's possible that Eclipse is modifying the system path environment variable when it is launched, which can cause the path to be incorrectly set for other programs like gdb. This can happen if Eclipse is launched with an environment that does not properly initialize the path.

To prevent Eclipse from modifying the system path, you can try setting the path explicitly in your Eclipse launch configuration. To do this, go to Run > Debug Configurations and select your launch configuration. Then, go to the Environment tab and add a PATH variable with the correct value for your system. This should ensure that Eclipse uses the correct path for debugging and other Cygwin programs.

Another option is to manually set the system path environment variable before launching Eclipse, so that Eclipse inherits the correct path. To do this, open the Control Panel and go to System > Advanced system settings > Environment Variables. Then, select the PATH variable in the System variables section and edit it to include the correct path. After making this change, launch Eclipse and verify that the correct path is being used for debugging.

It's worth noting that the behavior you're seeing is specific to your setup and may not be a common issue with Eclipse or gdb. However, these solutions should help to ensure that the path is set correctly for debugging and other Cygwin programs.
Re: gdb gets incorrect path from Eclipse [message #1863701 is a reply to message #1857449] Wed, 21 February 2024 19:26 Go to previous messageGo to next message
Peter Horn is currently offline Peter HornFriend
Messages: 1
Registered: February 2024
Junior Member
I run into the same problem. There are multiple MSYS2 gdb packages for the different runtime environments supported. First I just installed the gdb package which is for MSYS 2 and faced the path mangling issues.

Things started to work ok after installing the mingw-w64-x86_64-gdb package.

[Updated on: Wed, 21 February 2024 21:46]

Report message to a moderator

Re: gdb gets incorrect path from Eclipse [message #1864897 is a reply to message #1863701] Fri, 19 April 2024 10:26 Go to previous messageGo to next message
Eleaner Lucy is currently offline Eleaner LucyFriend
Messages: 1
Registered: October 2023
Junior Member
Eclipse can get confused by mixed workspaces for Java and C++. The desktop shortcut and potentially mixed paths in your workspace contribute to the mangled debug paths you're seeing (e.g., /cygdrive/c/Users/gjschurer/...).

Fixing the Debug Path:

Separate Workspaces: Consider creating a dedicated workspace for C++ projects. This keeps things organized and avoids conflicts between Java and C++ project settings.

Relative Paths: Use relative paths from your source code to the executable instead of absolute paths. This ensures Eclipse finds the executable consistently regardless of the working directory.

Debug Configuration: Double-check your debug configuration settings in Eclipse. Look for options like "Working Directory" or "Source Lookup Path" and make sure they point to the correct location of your C++ project and executable.

Environment Variables: Ensure Cygwin paths are set correctly in your system environment variables (not just within Eclipse). This helps Cygwin programs (including gdb) locate tools and libraries they need.

Stopping the Mangling:

By using a dedicated workspace, relative paths, and proper debug configuration, you can prevent Eclipse from messing with your debug paths.

Bonus Tip:

Consider using a Cygwin launcher script for Eclipse. This allows you to set specific Cygwin environment variables before launching Eclipse, ensuring a clean environment for C++ development.
Re: gdb gets incorrect path from Eclipse [message #1866726 is a reply to message #1864897] Wed, 05 June 2024 20:40 Go to previous messageGo to next message
Ralf Streicher is currently offline Ralf StreicherFriend
Messages: 1
Registered: June 2024
Junior Member
OMG - I know this topic is stone old....

I use Cygwin on windows and program D:\Desktop\eclipse\src\main.c which gets compiled with the gcc:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
return EXIT_SUCCESS;
}

But Debugging is not possible as the gdb returns the well know message (partly German, sorry):
Error in final launch sequence:

Failed to execute MI command:
-exec-run
Error message from debugger back end:
Error creating process /cygdrive/d/Desktop/D:/Desktop/eclipse/D:/Desktop/eclipse/Debug/eclipse.exe, (error 2: Das System kann die angegebene Datei nicht finden.)
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Error creating process /cygdrive/d/Desktop/D:/Desktop/eclipse/D:/Desktop/eclipse/Debug/eclipse.exe, (error 2: Das System kann die angegebene Datei nicht finden.)
Error creating process /cygdrive/d/Desktop/D:/Desktop/eclipse/D:/Desktop/eclipse/Debug/eclipse.exe, (error 2: Das System kann die angegebene Datei nicht finden.)

Your message suggests there is a workaround but I do not really undestand the steps. Can you elaborate this a bit more with screenshots or which menus to use in the IDE?

Just as a note: Same behavior is in Visual Code or CodeBlocks, I have not tested whether gdb running on a command line with or without cgdb would have the same problem, but I assume so.

[Updated on: Fri, 07 June 2024 22:29]

Report message to a moderator

Re: gdb gets incorrect path from Eclipse [message #1872506 is a reply to message #1866726] Tue, 05 November 2024 06:58 Go to previous message
Wilber Conn is currently offline Wilber ConnFriend
Messages: 1
Registered: November 2024
Junior Member
Ralf Streicher wrote on Wed, 05 June 2024 20:40
OMG - I know this topic is stone old....

I use Cygwin on windows and program D:\Desktop\eclipse\src\main.c which gets compiled with the gcc:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
return EXIT_SUCCESS;
}

But Debugging is not possible as the gdb returns the well know message (partly German, sorry):
Error in final launch sequence:

Failed to execute MI command:
-exec-run
Error message from debugger back end:
Error creating process /cygdrive/d/Desktop/D:/Desktop/eclipse/D:/Desktop/eclipse/Debug/eclipse.exe, (error 2: Das System kann die angegebene Datei nicht finden.)
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Error creating process /cygdrive/d/Desktop/D:/Desktop/eclipse/D:/Desktop/eclipse/Debug/eclipse.exe, (error 2: Das System kann die angegebene Datei nicht finden.)
Error creating process /cygdrive/d/Desktop/D:/Desktop/eclipse/D:/Desktop/eclipse/Debug/eclipse.exe, (error 2: Das System kann die angegebene Datei nicht finden.)

Your message suggests there is a workaround but I do not really undestand the steps. Can you elaborate this a bit more with screenshots or which menus to use in the IDE?

Just as a note: Same behavior is in Visual Code or CodeBlocks, I have not tested whether gdb running on a command line with or without cgdb would have the same problem, but I assume so.


What steps can be taken to configure Cygwin and Eclipse properly to ensure that the debugger (gdb) can locate and execute the compiled program without encountering path errors?
Previous Topic:Errors running builder 'CDT Core Builder' on project
Next Topic:Program file does not exist
Goto Forum:
  


Current Time: Wed Jan 15 14:53:55 GMT 2025

Powered by FUDForum. Page generated in 0.04006 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top