This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 3/7] Import lstat
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 2 Dec 2014 21:01:44 +0400
- Subject: Re: [PATCH 3/7] Import lstat
- Authentication-results: sourceware.org; auth=none
- References: <1416980800-21408-1-git-send-email-yao at codesourcery dot com> <1416980800-21408-4-git-send-email-yao at codesourcery dot com>
> This patch is to import lstat gnulib module.
>
> gdb:
>
> 2014-11-26 Yao Qi <yao@codesourcery.com>
>
> * gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
> lstat.
> * gnulib/aclocal.m4: Re-generated.
> * gnulib/config.in: Re-generated.
> * gnulib/configure: Re-generated.
> * gnulib/import/Makefile.am: Re-generated.
> * gnulib/import/Makefile.in: Re-generated.
> * gnulib/import/m4/gnulib-cache.m4: Re-generated.
> * gnulib/import/m4/gnulib-comp.m4: Re-generated.
> * gnulib/import/lstat.c: New file.
> * gnulib/import/m4/lstat.m4: New file.
For the record, I think this patch causes a build failure in
remote-sim.c on Windows hosts:
In file included from /[...]/gdb/remote-sim.c:34:0:
/[...]/gdb/../include/gdb/callback.h:93:9: error: duplicate member '_stati64'
int (*lstat) (host_callback *, const char *, struct stat *);
^
What happens it that gnulib's stat.h makes the following defines:
/* Large File Support on native Windows. */
#if 1
# define stat _stati64
#endif
and then:
#if 1
# if ! 0
/* mingw does not support symlinks, therefore it does not have lstat. But
without links, stat does just fine. */
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define lstat stat
# endif
So, the following fields in struct host_callback_struct...
int (*stat) (host_callback *, const char *, struct stat *);
int (*fstat) (host_callback *, int, struct stat *);
int (*lstat) (host_callback *, const char *, struct stat *);
... get translated to...
int (*_stati64) (host_callback *, const char *, struct _stati64 *);
int (*_fstati64) (host_callback *, int, struct _stati64 *);
int (*_stati64) (host_callback *, const char *, struct _stati64 *);
... which causes two fields to have the same name.
I think the only reasonable way out to avoid this sort of issue,
short of reverting the patch, is to do the same as in struct target_ops,
where the names of the fields start with "to_...". I'll work on the
immediate problem, which is to rename those 3 fields, but I think
we'll want to be consistent and rename them all. For instance
"ftruncate" also got translated:
int (*ftruncate64) (host_callback *, int, long);
Same for lseek (->lseek64), rename (->rpl_rename).
No actual harm in those cases, but it shows that those translations
do happen.
--
Joel