This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA/commit/Windows] run program with space in path to exe.
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org, brobecker at adacore dot com
- Date: Sat, 20 Oct 2012 10:02:19 +0200
- Subject: Re: [RFA/commit/Windows] run program with space in path to exe.
- References: <1350692925-14181-1-git-send-email-brobecker@adacore.com>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> 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?