This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch gdb]: Fix some DOS-path related issues in gdb


On Wednesday 23 March 2011 10:39:33, Kai Tietz wrote:
> --- gdb.orig/source.c   2011-03-23 10:30:42.614811600 +0100
> +++ gdb/source.c        2011-03-23 10:56:17.194745900 +0100
> @@ -569,15 +569,10 @@ add_path (char *dirname, char **which_pa
>         p = *which_path;
>         while (1)
>           {
> -           /* FIXME: strncmp loses in interesting ways on MS-DOS and
> -              MS-Windows because of case-insensitivity and two different
> -              but functionally identical slash characters.  We need a
> -              special filesystem-dependent file-name comparison function.
> -
> -              Actually, even on Unix I would use realpath() or its work-
> +           /* Actually, even on Unix I would use realpath() or its work-
>                alike before comparing.  Then all the code above which
>                removes excess slashes and dots could simply go away.  */
> -           if (!strncmp (p, name, len)
> +           if (!filename_ncmp (p, name, len)
>                 && (p[len] == '\0' || p[len] == DIRNAME_SEPARATOR))

Without the previous paragraph, the comment left now doesn't make
sense on its own as is.  The "Actually, even on Unix" appears out of
the blue.

> --- gdb.orig/xml-support.c      2011-03-23 10:30:42.620811600 +0100
> +++ gdb/xml-support.c   2011-03-23 10:56:17.265754900 +0100
> @@ -25,6 +25,7 @@
>  
>  #include "gdb_string.h"
>  #include "safe-ctype.h"
> +#include "filenames.h"
>  
>  /* Debugging flag.  */
>  static int debug_xml;
> @@ -946,7 +947,7 @@ fetch_xml_builtin (const char *filename)
>    const char *(*p)[2];
>  
>    for (p = xml_builtin; (*p)[0]; p++)
> -    if (strcmp ((*p)[0], filename) == 0)
> +    if (filename_cmp ((*p)[0], filename) == 0)
>        return (*p)[1];
>  
>    return NULL;

I don't think this one makes sense to behave different depending
on host.  These are files that are built into the GDB binary, with
filenames hardcoded, and always basenamed.  No need to do case
insensitive, or path separator style sensitive match.

> --- gdb.orig/dwarf2read.c       2011-03-23 10:32:00.336248300 +0100
> +++ gdb/dwarf2read.c    2011-03-23 10:56:17.285257400 +0100
> @@ -5211,7 +5211,8 @@ find_file_and_directory (struct die_info
>          directory, get rid of it.  */
>        char *cp = strchr (*comp_dir, ':');
>  
> -      if (cp && cp != *comp_dir && cp[-1] == '.' && cp[1] == '/')
> +      if (cp && cp != *comp_dir && cp[-1] == '.'
> +         && IS_ABSOLUTE_PATH (&cp[1]))
>         *comp_dir = cp + 1;
>      }
>  

I've already told you in another thread that this one is wrong.
We do not want to match anything other than '/' here, even
on Windows.  On a Windows x Irix gdb, we'd want to check for '/',
literally.  The Irix native cc compiler is not going to
use '\' or drive names:

  if (*comp_dir != NULL)
    {
      /* Irix 6.2 native cc prepends <machine>.: to the compilation
	 directory, get rid of it.  */
      char *cp = strchr (*comp_dir, ':');

      if (cp && cp != *comp_dir && cp[-1] == '.' && cp[1] == '/')
	*comp_dir = cp + 1;
    }

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]