[RFA/commit/Windows] run program with space in path to exe.
Sat Oct 20 08:03:00 GMT 2012
> From: Joel Brobecker <firstname.lastname@example.org>
> Cc: Joel Brobecker <email@example.com>
> Date: Fri, 19 Oct 2012 17:28:45 -0700
> The following works...
> % gdb c:\path to exe\foo.exe
> (gdb) start
> ... unless a file or directory called "c:\path" or "c:\path to" exists.
> This is what happens in the latter case:
> (gdb) start
> Error creating process C:\path to exe\foo.exe (error 193).
> This is because we are calling CreateProcess (et al) without specifying
> the lpApplicationName, so Windows determines the name of the executable
> using the second argument, which is the entire command line. This
> command line is a space-separated list of tokens, so the space in
> the path to the executable which potentially creates an ambiguity.
> The ambiguity is automatically resolved unless we're in the situation
Does it work if you say
% gdb "\"c:\path to exe\foo.exe\""
> 3. Theoretically, I have a feeling that we're breaking the case
> where the executable name contains a double quote in it.
This is impossible, at least in the MinGW case: Windows file names
cannot include the quote character. See
But what happens if the program name is already quoted? A user can do
that if she realizes the problem in advance, certainly if the program
name is specified at the GDB prompt, as in 'file "c:\foo bar\my.exe"'.
I think we should detect this case and not quote it again.
Also, what about the arguments to the program? Don't they have the
same issue when you use --args on the GDB command line?
More information about the Gdb-patches