This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [RFA] Avoid calling stat with empty name in relocate_gdb_directory
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'Tom Tromey'" <tromey at redhat dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Thu, 6 Dec 2012 00:44:49 +0100
- Subject: RE: [RFA] Avoid calling stat with empty name in relocate_gdb_directory
- References: <29503.7594777115$1354726985@news.gmane.org> <87sj7ks7g6.fsf@fleche.redhat.com>
> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Tom Tromey
> Envoyé?: mercredi 5 décembre 2012 19:03
> À?: Pierre Muller
> Cc?: gdb-patches@sourceware.org
> Objet?: Re: [RFA] Avoid calling stat with empty name in
> relocate_gdb_directory
>
> >>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
writes:
>
> Pierre> With the troubles that I have with my patch,
> Pierre> I started looking into a memory debugger...
> Pierre> I finally started to use drmemory
> Pierre> for mingw compiled GDB executables.
>
> Pierre> I don't know if stat is supposed to handle (*dir == '\0'),
> Pierre> but I thought that it should anyhow succeed in that case,
> Pierre> so the patch below simply don't call stat if name is empty.
>
> At least here I get an error.
>
> Pierre> Tell me if you rather think that this is a msvcrt bug that
> Pierre> should not be fixed in GDB...
>
> I don't mind working around it, but I wonder how we end up there with an
> empty 'dir' in the first place. Perhaps that is a bug instead.
It comes from here:
388 current_directory = gdb_dirbuf;
389
390 /* Set the sysroot path. */
391 gdb_sysroot = relocate_gdb_directory (TARGET_SYSTEM_ROOT,
392
TARGET_SYSTEM_ROOT_RELOCATABLE);
393
394 debug_file_directory = relocate_gdb_directory (DEBUGDIR,
395
DEBUGDIR_RELOCATABLE);
TARGET_SYTEM_ROOT is set to ""
by the configure.ac autoconf script for
1874-# Support for --with-sysroot is a copy of GDB_AC_WITH_DIR,
1875-# except that the argument to --with-sysroot is optional.
1876-# --with-sysroot (or --with-sysroot=yes) sets the default sysroot path.
1877-if test "x$with_sysroot" = xyes; then
1878- with_sysroot="${exec_prefix}/${target_alias}/sys-root"
1879-fi
1880-AC_ARG_WITH(sysroot,
1881- AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@],
1882- [search for usr/lib et al within DIR]),
1883: [TARGET_SYSTEM_ROOT=$withval], [TARGET_SYSTEM_ROOT=])
1884:AC_DEFINE_DIR(TARGET_SYSTEM_ROOT, TARGET_SYSTEM_ROOT,
1885- [search for usr/lib et al within DIR])
1886:AC_SUBST(TARGET_SYSTEM_ROOT)
1887:GDB_AC_DEFINE_RELOCATABLE(TARGET_SYSTEM_ROOT, sysroot,
${ac_define_dir})
1888-
Apparently it isn't used elsewhere...
Should we modify the default value to NULL instead of ""?
I do not master complicated autoconf things like
GDB_AC_DEFINE_RELOCATABLE well enough to know if this is
without problems...
Tell me if you think we should modify it at configury level or
if I should commit my patch, whatever you prefer!
Pierre