Debugging with GDB - incorrect path to executable [message #1834836] |
Wed, 18 November 2020 14:32  |
Eclipse User |
|
|
|
I've installed Eclipse 2020-09, with Cygwin64 and packages gcc-core 10.2.0-1; gcc-g++ 10.2.0-1. This is on a Windows 10 VM running on MacOS.
I have a very simple helloworld program which compiles and runs in Eclipse, outputting "hello world!" on the console. When I try to debug this, I get a gdb error which I can't fathom:
"failed to execute MI command: -exec-run .... Error creating process: /cygdrive/c/eclipse/C:/Users/andrewjohnson/eclipse-workspace/HelloWorld/C:/Users/andrewjohnson/eclipse-workspace/HelloWorld/Debug/HelloWorld.exe, (error 2)."
Error 2 is a Windows code relating to file not found I believe. Not surprising given that path!
If I run If I run gdb from the command line in the HelloWorld\Debug directory - gdb .\HelloWorld.exe - it works fine and I get "hello world!" output.
I can't work out how Eclipse is building that path to pass to GDB. I do have a Path Mapping set in Source Lookup Path /cydrive/c -> C:\ (although I get that incorrect path generated irrespective).
What's being generated looks like a concatenation of Cygwin_Home, eclipse, CWD or PWD and the project executable. I'm pretty new to this so I've run out of ideas of what to check: it must be a configuration issue with Eclipse that I'm missing so if anyone can help I'd really appreciate it.
thanks
|
|
|
|
|
|
|
|
|
|
Re: Debugging with GDB - incorrect path to executable [message #1858822 is a reply to message #1850349] |
Mon, 24 April 2023 15:06   |
Eclipse User |
|
|
|
Hi everyone,
I found a quick and dirty way to fix the issue in my environment eclipse (STM32CubeIDE Version: 1.12.0) and gdb v13.1 on cygwin
The way I fixed it implies the gdb binary recompilation .
I downloaded the latest version (13.1, in test) and modified a specific file before recompiling the binary.
what I changed is the file named windows-nat.c located in the gdb folder (where i uncompress the downloaded tar) : gdb13.1/gdb/windows-nat.c
what I modified in that file is a couple of line : find the following lines :
args = (wchar_t *) alloca ((wcslen (toexec) + wcslen (cygallargs) + 2)
* sizeof (wchar_t));
wcscpy (args, toexec);
wcscat (args, L" ");
wcscat (args, cygallargs);
and make them look like this :
args = (wchar_t *) alloca ((wcslen (toexec) + wcslen (cygallargs) + 2)
* sizeof (wchar_t));
wcscpy (args, wcsstr (toexec, L"Debug"));
// wcscat (args, L" ");
// wcscat (args, cygallargs);
then recompile the binary.
then in eclipse, in the debug configuration configure the debugger to run the newly compiled gdb binary.
Remember, this is a quick and dirty workaround, not a permanent fix.
hope this helps.
|
|
|
|
Powered by
FUDForum. Page generated in 0.10852 seconds