gdb gets incorrect path from Eclipse [message #1857449] |
Wed, 08 February 2023 05:47  |
Eclipse User |
|
|
|
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 #1857595 is a reply to message #1857501] |
Thu, 16 February 2023 07:24   |
Eclipse User |
|
|
|
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 #1872506 is a reply to message #1866726] |
Tue, 05 November 2024 01:58  |
Eclipse User |
|
|
|
Ralf Streicher wrote on Wed, 05 June 2024 20:40OMG - 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?
|
|
|
Powered by
FUDForum. Page generated in 0.38589 seconds