views:

1074

answers:

4

This is shown when I try to debug my code with Eclipse:

alt text

I then tried creating a simple Hello World program manually with Notepad++ and the command-line gcc. When I launched the gdb debugger this happened:

(gdb) run

Starting program: C:\Documents and Settings\Pieter\Bureaublad/test.exe Error creating process C:\Documents and Settings\Pieter\Bureaublad/test.exe, (error 193).

The binary runs fine, but as soon as I try to debug it error 193 is returned. I'm working with C code that is processed by the MinGW GCC compiler. I tried reinstalling both the compiler and the debugger (latest versions) but that didn't change anything. It has worked in the past, and I do not remember making any changes to settings related to the compiler.

Here's an example of an error log as it was generated by Eclipse.

!ENTRY org.eclipse.cdt.dsf.gdb 4 5012 2010-02-09 18:19:47.375 !MESSAGE Error in final launch sequence !STACK 1 org.eclipse.core.runtime.CoreException: Failed to execute MI command: -exec-run Error message from debugger back end: Error creating process C:/Documents and Settings/Pieter/Mijn documenten/My Dropbox/Unief/C/H12/Opdr07/Debug/CH12O07.exe, (error 193). at org.eclipse.cdt.dsf.concurrent.Sequence.abortExecution(Sequence.java:560) at org.eclipse.cdt.dsf.concurrent.Sequence.access$4(Sequence.java:552) at org.eclipse.cdt.dsf.concurrent.Sequence$2.handleErrorOrWarning(Sequence.java:424) at org.eclipse.cdt.dsf.concurrent.RequestMonitor.handleFailure(RequestMonitor.java:314) at org.eclipse.cdt.dsf.concurrent.RequestMonitor.handleCompleted(RequestMonitor.java:277) at org.eclipse.cdt.dsf.concurrent.RequestMonitor$2.run(RequestMonitor.java:239) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) !SUBENTRY 1 org.eclipse.cdt.dsf.gdb 4 10004 2010-02-09 18:19:47.546 !MESSAGE Failed to execute MI command: -exec-run Error message from debugger back end: Error creating process C:/Documents and Settings/Pieter/Mijn documenten/My Dropbox/Unief/C/H12/Opdr07/Debug/CH12O07.exe, (error 193).

A: 

Google tells me that "Error 193" is a Windows error code that means an executable is not, in fact, executable. Looks like there's something wrong with your EXE - can you start it directly?

Michael Borgwardt
I can start it directly, but I need to debug it since it crashes.
Pieter
@Pieter: I've found a thread in a German C++ forum descrbing the same problem: http://www.c-plusplus.de/forum/viewtopic-var-t-is-229700.html - It doesn't seem to offer a clear-cut solution (in a linked-to thread, someone got gdb to work only after using subst to put the executable on its own drive), but it looks like you're Dutch, so perhaps it can give you some hints.
Michael Borgwardt
Are they suggesting that I run Cygwin to build a Linux binary instead of a Windows binary?
Pieter
Cygwin seems to have been the key in that case, but of course it would still build Windows binaries.
Michael Borgwardt
Yikes. That's a frustrating workaround. I'll keep this question opened for another while just in case there are easier solutions.
Pieter
A: 

This thread does mention:

  • Error 193 is ERROR_BAD_EXE_FORMAT
  • this can be an issue with your cygwin installation.

Note (as an example of "problem with cygwin installation): there was a bug with gdb if installed in a cygwin referenced with a path including a space in it (see this thread)

What version of gdb are you using when you reproduce the issue outside of Eclipse CDT?

VonC
I've tried several versions of gdb, all were >= 7.0. The version I used before the problems started occurring is GDB-7.0.50.20100202. I don't use Cygwin to compile my projects, although I've tried but Eclipse didn't detect it. The compiler I use is MinGW GCC.
Pieter
@Pieter Could you try using cygwin though, to check if the problem persist in that environment? For CDT + cygwin, you can try and follow http://blog.genius-field.com/2009/04/20/build-up-cc-environment-on-eclipse-using-cdt-cygwin/ (or http://homepage.cs.uri.edu/courses/fall2007/csc406/Handouts/eclipseTutorial.pdf). Check also http://old.nabble.com/cygwin-toolchain-unsupported--td15180630.html and http://dreamlayers.blogspot.com/2010/01/eclipse-incompatibility-with-cygwin-17.html
VonC
Check also http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg16936.html for issue with "gcc.exe" in new Cygwin (1.7).
VonC
I put Cygwin's bin folder in the path, but Eclipse still isn't detecting Cygwin. I made sure I restarted Eclipse after Cygwin installed and I did check gcc, gcc-core and make.
Pieter
@Pieter: did you check http://cdt-devel-faq.wikidot.com/#toc27 ?
VonC
Where do I put my etc directory (C:\cygwin\etc) in "HKCU\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2"? Should I set it as the value of the default key?
Pieter
@Pieter: If I believe http://www.cygwin.com/ml/cygwin/2001-04/msg00076.html, maybe by adding a `HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/etc`, with: `(default) = `C:/CygWin/etc'` and `flags = 0x0000000a`
VonC
I added the key to the registry, but Cygwin GCC is still not listed as a supported toolchain. By the way, I think I recall reading that Cygwin 1.7+ no longer stores the mounts in the registry so maybe that has something to do with it.
Pieter
@Pieter: correct, http://www.cygwin.com/cygwin-ug-net/ov-new1.7.html#ov-new1.7-os : try to declare the /etc mount point in `/etc/fstab` instead.
VonC
Like this? `/cygdrive/c/cygwin/etc /etc cygdrive defaults 0 0`
Pieter
@Pieter: I missed your last comment. Did you make any progress on that issue?
VonC
No I didn't. I still haven't figured out how I can make Eclipse recognize Cygwin.
Pieter
+1  A: 

Could it be that either you are using an older version of gdb, that doesn't support native MinGW debugging (unlikely since you said you updated to the latest version), or you are invoking the debugger incorrectly? In other words, if your executable is named helloworld.exe, gdb helloworld may give you that error, whereas gdb helloworld.exe may work.

Edit: further googling says that trying a directory name without spaces might work (the solution is for Code::Blocks, but it doesn't hurt to try).

Alok
It has worked before in directories that contain spaces, but I'll try it anyway. I'll get back to you later today, hopefully.
Pieter
You're right, for some reason the debugger doesn't like directory names with spaces in them. But that doesn't explain why Eclipse used to be able to debug programs like this inside the same directory structure that contained spaces in some folder names. I think I'm onto something: http://mingw.org/wiki/Getting_Started
Pieter
Putting the EXE in a path that doesn't contain spaces does work, but then I can't use Eclipse to debug. Any patches or workarounds I can try?
Pieter
Alok
Why can't you use eclipse to debug? You should install eclipse and mingw in directories without spaces in their names. It's a silly restriction, but you might have to live with it. Good luck!
Alok
I keep my Eclipse projects in a Dropbox subdirectory, the root of which is located in C:\Documents and Settings\Pieter De Decker\Mijn documenten\Dropbox\. So there's no way I can put it in a directory without spaces. Why is this such a big deal anyway? Isn't this a minor technical glitch that can be fixed easily?
Pieter
@Pieter: I agree with you - unfortunately I haven't been able to find a way of overcoming that restriction yet. It really is a silly restriction.
Alok
Here's an email by someone who got eclipse and cygwin to work properly: http://old.nabble.com/Re:-Cannot-run-program-"gdb":-Launching-failed-p20574812.html. You might want to try that maybe?
Alok
Are you suggesting my problem is caused by a malformed PATH? Just in case, here it is: `%CommonProgramFiles%\Microsoft Shared\Windows Live;C:\Program Files\CVSNT\;C:\Program Files\doxygen\graphviz\bin;C:\Program Files\Java\jdk1.6.0_18\bin;C:\MinGW\bin` I put GDB in C:\MinGW\bin.
Pieter
No, that link was to make eclipse work with cygwin. The problem with spaces is due to eclipse CDT and gdb interaction, and there seems to be no easy way out of it. See if you can do what you're doing with symbolic links, so you still put files in your dropbox, but have a symlink to it that is a name without spaces, and use that path in eclipse. http://en.wikipedia.org/wiki/NTFS_symbolic_link
Alok
I'm an XP user, so no symbolic links for me... :-(
Pieter
Maybe try http://shell-shocked.org/article.php?id=284#proggies, in particular the "junction" program *may* be able to help you with symlinks. I totally feel your frustration, though. Junction seems to be at http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx, and here is a list of more programs: http://blog.taragana.com/index.php/archive/how-to-create-hardlinks-junctions-and-symboliclinks-on-windows/
Alok
Bingo! The bounty is yours!
Pieter
Glad to be of help.
Alok
I had the same problem in Qt Creator and this solution (removing spaces from the path) worked for me.
Jake Petroules
A: 

You said:

(gdb) run

Starting program: C:\Documents and Settings\Pieter\Bureaublad/test.exe Error creating process C:\Documents and Settings\Pieter\Bureaublad/test.exe, (error 193).

Might it have anything to do with the forward/reverse slash at the end of the executable path? Perhaps the part Bureaublad/test.exe is here intended as a single executable, and it can't be found?

lorenzog
If I do `gdb "C:\Documents and Settings\Pieter\Bureaublad\CH14O01.exe"` (this file does in fact exist), the debugger returns the same error even though there's no forward slash this time: `Error creating process C:\Documents and Settings\Pieter\Bureaublad\CH14O01.exe, (error 193).`.
Pieter