RE: [RFC] Fix problems related to Mingw/DJGPP file names containing colons

Pierre Muller
2011-08-13T20:42:54Z

> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Eli Zaretskii
> Envoyé : samedi 13 août 2011 12:51
> À : Pierre Muller
> Cc : tromey@redhat.com; gdb-patches@sourceware.org
> Objet : Re: [RFC] Fix problems related to Mingw/DJGPP file names
containing
> colons
>
> > From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
> > Cc: <gdb-patches@sourceware.org>
> > Date: Sat, 13 Aug 2011 12:10:53 +0200
> >
> > > It's ugly and fragile, because the original name could be quoted.
> >
> > + /* Quote filenames containing ':' characters to avoid problems.
*/
> > + if (strchr (filename, ':') != NULL && filename[0] != '"')
> > + sprintf (canonical_name, "\"%s\":%d", filename, sal->line);
> >
> > The second condition already takes care of not
> > quoting already quoted file names.
>
> What if the original name already includes quote characters? That can
> happen on Posix platforms.
You are right, but we are saved by the fact
that colons are not allow on those platforms, isn't it?
(otherwise all lists of directories like in the PATH
environment variable would have a problem...)

But there might be some 'exotic' file systems that allow
both double-quotes and colons as valid characters in their
filenames. In those cases, we would be in trouble...

The main reason for now is that the code is acting directly on
addr_string pchar and should not modify it, otherwise,
we could simply call a more complete quoting function that
would escape internal colons (but of course we should then also
look for and handle those escaped colons...)

I am wondering how spaces within filenames are handled
inside GDB on mingw32...
I just tested... No very well :(

If you have "test space with name.exe" and "test.exe"
executables within the same directory,
GDB seems to load the correct file but runs the false one because
no quoting is added to CreateProcess call....

Pierre