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 3/7] Import lstat


> 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


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