Re: [RFA/commit/Windows] run program with space in path to exe.

Eli Zaretskii
2012-10-20T08:03:35Z

> From: Joel Brobecker <brobecker@adacore.com>
> Cc: Joel Brobecker <brobecker@adacore.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
> above.

Does it work if you say

% gdb "\"c:\path to exe\foo.exe\""

instead?

> 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

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx

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?