diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 18 | ||||
-rw-r--r-- | gdb/Makefile.in | 10 | ||||
-rw-r--r-- | gdb/common/common-remote-fileio.c | 119 | ||||
-rw-r--r-- | gdb/common/common-remote-fileio.h | 61 | ||||
-rw-r--r-- | gdb/gdbserver/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/gdbserver/Makefile.in | 8 | ||||
-rw-r--r-- | gdb/gdbserver/config.in | 6 | ||||
-rwxr-xr-x | gdb/gdbserver/configure | 77 | ||||
-rw-r--r-- | gdb/gdbserver/configure.ac | 2 | ||||
-rw-r--r-- | gdb/remote-fileio.c | 111 | ||||
-rw-r--r-- | gdb/remote-fileio.h | 2 |
11 files changed, 308 insertions, 116 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d496ffd..ec92c7d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,21 @@ +2015-03-11 Gary Benson <gbenson@redhat.com> + + * common/common-remote-fileio.h: New file. + * common/common-remote-fileio.c: Likewise. + * Makefile.in (SFILES): Add common/common-remote-fileio.c. + (HFILES_NO_SRCDIR): Add common/common-remote-fileio.h. + (COMMON_OBS): Add common-remote-fileio.o. + (common-remote-fileio.o): New rule. + * remote-fileio.h (common-remote-fileio.h): New include. + * remote-fileio.c (gdb/fileio.h): Do not include. + (remote_fileio_to_be): Moved to common-remote-fileio.h. + (remote_fileio_to_fio_uint): Likewise. + (remote_fileio_to_fio_time): Likewise. + (remote_fileio_mode_to_target): Moved to common-remote-fileio.c. + (remote_fileio_to_fio_mode): Likewise. + (remote_fileio_to_fio_ulong): Likewise. + (remote_fileio_to_fio_stat): Likewise. + 2015-03-11 Andy Wingo <wingo@igalia.com> * guile/scm-value.c (gdbscm_value_dynamic_type): Fix typo in which diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 8c2a4de..0ddcd72 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -877,7 +877,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \ common/format.c common/filestuff.c btrace.c record-btrace.c ctf.c \ target/waitstatus.c common/print-utils.c common/rsp-low.c \ common/errors.c common/common-debug.c common/common-exceptions.c \ - common/btrace-common.c \ + common/btrace-common.c common/common-remote-fileio.c \ $(SUBDIR_GCC_COMPILE_SRCS) LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c @@ -966,7 +966,8 @@ common/print-utils.h common/rsp-low.h nat/x86-dregs.h x86-linux-nat.h \ i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \ common/common-debug.h common/cleanups.h common/gdb_setjmp.h \ common/common-exceptions.h target/target.h common/symbol.h \ -common/common-regcache.h fbsd-tdep.h nat/linux-personality.h +common/common-regcache.h fbsd-tdep.h nat/linux-personality.h \ +common/common-remote-fileio.h # Header files that already have srcdir in them, or which are in objdir. @@ -1065,7 +1066,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o \ format.o registry.o btrace.o record-btrace.o waitstatus.o \ print-utils.o rsp-low.o errors.o common-debug.o debug.o \ - common-exceptions.o btrace-common.o \ + common-exceptions.o btrace-common.o common-remote-fileio.o \ $(SUBDIR_GCC_COMPILE_OBS) TSOBS = inflow.o @@ -2244,6 +2245,9 @@ btrace-common.o: ${srcdir}/common/btrace-common.c $(COMPILE) $(srcdir)/common/btrace-common.c $(POSTCOMPILE) +common-remote-fileio.o: ${srcdir}/common/common-remote-fileio.c + $(COMPILE) $(srcdir)/common/common-remote-fileio.c + $(POSTCOMPILE) # # gdb/target/ dependencies # diff --git a/gdb/common/common-remote-fileio.c b/gdb/common/common-remote-fileio.c new file mode 100644 index 0000000..f78b3f7 --- /dev/null +++ b/gdb/common/common-remote-fileio.c @@ -0,0 +1,119 @@ +/* Remote File-I/O communications + + Copyright (C) 2003-2015 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "common-defs.h" +#include "common-remote-fileio.h" +#include <sys/stat.h> + +/* Convert a host-format mode_t into a bitmask of File-I/O flags. */ + +static LONGEST +remote_fileio_mode_to_target (mode_t mode) +{ + mode_t tmode = 0; + + if (S_ISREG (mode)) + tmode |= FILEIO_S_IFREG; + if (S_ISDIR (mode)) + tmode |= FILEIO_S_IFDIR; + if (S_ISCHR (mode)) + tmode |= FILEIO_S_IFCHR; + if (mode & S_IRUSR) + tmode |= FILEIO_S_IRUSR; + if (mode & S_IWUSR) + tmode |= FILEIO_S_IWUSR; + if (mode & S_IXUSR) + tmode |= FILEIO_S_IXUSR; +#ifdef S_IRGRP + if (mode & S_IRGRP) + tmode |= FILEIO_S_IRGRP; +#endif +#ifdef S_IWRGRP + if (mode & S_IWGRP) + tmode |= FILEIO_S_IWGRP; +#endif +#ifdef S_IXGRP + if (mode & S_IXGRP) + tmode |= FILEIO_S_IXGRP; +#endif + if (mode & S_IROTH) + tmode |= FILEIO_S_IROTH; +#ifdef S_IWOTH + if (mode & S_IWOTH) + tmode |= FILEIO_S_IWOTH; +#endif +#ifdef S_IXOTH + if (mode & S_IXOTH) + tmode |= FILEIO_S_IXOTH; +#endif + return tmode; +} + +/* Pack a host-format mode_t into an fio_mode_t. */ + +static void +remote_fileio_to_fio_mode (mode_t num, fio_mode_t fnum) +{ + remote_fileio_to_be (remote_fileio_mode_to_target (num), + (char *) fnum, 4); +} + +/* Pack a host-format integer into an fio_ulong_t. */ + +static void +remote_fileio_to_fio_ulong (LONGEST num, fio_ulong_t fnum) +{ + remote_fileio_to_be (num, (char *) fnum, 8); +} + +/* See common-remote-fileio.h. */ + +void +remote_fileio_to_fio_stat (struct stat *st, struct fio_stat *fst) +{ + LONGEST blksize; + + remote_fileio_to_fio_uint ((long) st->st_dev, fst->fst_dev); + remote_fileio_to_fio_uint ((long) st->st_ino, fst->fst_ino); + remote_fileio_to_fio_mode (st->st_mode, fst->fst_mode); + remote_fileio_to_fio_uint ((long) st->st_nlink, fst->fst_nlink); + remote_fileio_to_fio_uint ((long) st->st_uid, fst->fst_uid); + remote_fileio_to_fio_uint ((long) st->st_gid, fst->fst_gid); + remote_fileio_to_fio_uint ((long) st->st_rdev, fst->fst_rdev); + remote_fileio_to_fio_ulong ((LONGEST) st->st_size, fst->fst_size); +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE + blksize = st->st_blksize; +#else + blksize = 512; +#endif + remote_fileio_to_fio_ulong (blksize, fst->fst_blksize); +#if HAVE_STRUCT_STAT_ST_BLOCKS + remote_fileio_to_fio_ulong ((LONGEST) st->st_blocks, fst->fst_blocks); +#else + /* FIXME: This is correct for DJGPP, but other systems that don't + have st_blocks, if any, might prefer 512 instead of st_blksize. + (eliz, 30-12-2003) */ + remote_fileio_to_fio_ulong (((LONGEST) st->st_size + blksize - 1) + / blksize, + fst->fst_blocks); +#endif + remote_fileio_to_fio_time (st->st_atime, fst->fst_atime); + remote_fileio_to_fio_time (st->st_mtime, fst->fst_mtime); + remote_fileio_to_fio_time (st->st_ctime, fst->fst_ctime); +} diff --git a/gdb/common/common-remote-fileio.h b/gdb/common/common-remote-fileio.h new file mode 100644 index 0000000..b838186 --- /dev/null +++ b/gdb/common/common-remote-fileio.h @@ -0,0 +1,61 @@ +/* Remote File-I/O communications + + Copyright (C) 2003-2015 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef COMMON_REMOTE_FILEIO_H +#define COMMON_REMOTE_FILEIO_H + +#include "gdb/fileio.h" + +struct stat; + +/* Pack a host-format integer into a byte buffer in big-endian format + ready for transmission over the remote protocol. BYTES specifies + the size of the integer to pack in bytes. */ + +static inline void +remote_fileio_to_be (LONGEST num, char *buf, int bytes) +{ + int i; + + for (i = 0; i < bytes; ++i) + buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff; +} + +/* Pack a host-format integer into an fio_uint_t. */ + +static inline void +remote_fileio_to_fio_uint (long num, fio_uint_t fnum) +{ + remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4); +} + +/* Pack a host-format time_t into an fio_time_t. */ + +static inline void +remote_fileio_to_fio_time (time_t num, fio_time_t fnum) +{ + remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4); +} + +/* Pack a host-format struct stat into a struct fio_stat. */ + +extern void remote_fileio_to_fio_stat (struct stat *st, + struct fio_stat *fst); + +#endif /* COMMON_REMOTE_FILEIO_H */ diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index d611bfd..1a57867 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,13 @@ +2015-03-11 Gary Benson <gbenson@redhat.com> + + * configure.ac (AC_CHECK_MEMBERS): Add checks for + struct stat.st_blocks and struct stat.st_blksize. + * configure: Regenerate. + * config.in: Likewise. + * Makefile.in (SFILES): Add common/common-remote-fileio.c. + (OBS): Add common-remote-fileio.o. + (common-remote-fileio.o): New rule. + 2015-03-09 Pedro Alves <palves@redhat.com> * tracepoint.c (gdb_agent_helper_thread): Cast '&sockaddr' to diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in index 6dddf26..b425ee2 100644 --- a/gdb/gdbserver/Makefile.in +++ b/gdb/gdbserver/Makefile.in @@ -179,7 +179,8 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \ $(srcdir)/common/rsp-low.c $(srcdir)/common/errors.c \ $(srcdir)/common/common-debug.c $(srcdir)/common/cleanups.c \ $(srcdir)/common/common-exceptions.c $(srcdir)/symbol.c \ - $(srcdir)/common/btrace-common.c + $(srcdir)/common/btrace-common.c \ + $(srcdir)/common/common-remote-fileio.c DEPFILES = @GDBSERVER_DEPFILES@ @@ -193,7 +194,7 @@ OBS = agent.o ax.o inferiors.o regcache.o remote-utils.o server.o signals.o \ mem-break.o hostio.o event-loop.o tracepoint.o xml-utils.o \ common-utils.o ptid.o buffer.o format.o filestuff.o dll.o notif.o \ tdesc.o print-utils.o rsp-low.o errors.o common-debug.o cleanups.o \ - common-exceptions.o symbol.o btrace-common.o \ + common-exceptions.o symbol.o btrace-common.o common-remote-fileio.o \ $(XML_BUILTIN) $(DEPFILES) $(LIBOBJS) GDBREPLAY_OBS = gdbreplay.o version.o GDBSERVER_LIBS = @GDBSERVER_LIBS@ @@ -572,6 +573,9 @@ common-exceptions.o: ../common/common-exceptions.c waitstatus.o: ../target/waitstatus.c $(COMPILE) $< $(POSTCOMPILE) +common-remote-fileio.o: ../common/common-remote-fileio.c + $(COMPILE) $< + $(POSTCOMPILE) # Native object files rules from ../nat diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index 8114628..3c3bfca 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -210,6 +210,12 @@ /* Define to 1 if you have the <string.h> header file. */ #undef HAVE_STRING_H +/* Define to 1 if `struct stat' is a member of `st_blksize'. */ +#undef HAVE_STRUCT_STAT_ST_BLKSIZE + +/* Define to 1 if `struct stat' is a member of `st_blocks'. */ +#undef HAVE_STRUCT_STAT_ST_BLOCKS + /* Define to 1 if the target supports __sync_*_compare_and_swap */ #undef HAVE_SYNC_BUILTINS diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index cbf4b4e..75860dd 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -2109,6 +2109,63 @@ rm -f conftest.val return $ac_retval } # ac_fn_c_compute_int + +# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES +# ---------------------------------------------------- +# Tries to find if the field MEMBER exists in type AGGR, after including +# INCLUDES, setting cache variable VAR accordingly. +ac_fn_c_check_member () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 +$as_echo_n "checking for $2.$3... " >&6; } +if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (sizeof ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + eval "$4=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$4 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_member cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -6085,6 +6142,26 @@ cat >>confdefs.h <<_ACEOF _ACEOF +ac_fn_c_check_member "$LINENO" "struct stat" "st_blocks" "ac_cv_member_struct_stat_st_blocks" "$ac_includes_default" +if test "x$ac_cv_member_struct_stat_st_blocks" = x""yes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 +_ACEOF + + +fi +ac_fn_c_check_member "$LINENO" "struct stat" "st_blksize" "ac_cv_member_struct_stat_st_blksize" "$ac_includes_default" +if test "x$ac_cv_member_struct_stat_st_blksize" = x""yes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 +_ACEOF + + +fi + + ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include <sys/types.h> #include <sys/socket.h> diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index 0381aa9..34af269 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -226,6 +226,8 @@ libiberty_INIT AC_CHECK_DECLS([strerror, perror, vasprintf, vsnprintf]) +AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize]) + AC_CHECK_TYPES(socklen_t, [], [], [#include <sys/types.h> #include <sys/socket.h> diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 00a86ca..0ce0714 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -22,7 +22,6 @@ #include "defs.h" #include "gdbcmd.h" #include "remote.h" -#include "gdb/fileio.h" #include "gdb_wait.h" #include <sys/stat.h> #include "remote-fileio.h" @@ -194,48 +193,6 @@ remote_fileio_mode_to_host (long mode, int open_call) return hmode; } -static LONGEST -remote_fileio_mode_to_target (mode_t mode) -{ - mode_t tmode = 0; - - if (S_ISREG(mode)) - tmode |= FILEIO_S_IFREG; - if (S_ISDIR(mode)) - tmode |= FILEIO_S_IFDIR; - if (S_ISCHR(mode)) - tmode |= FILEIO_S_IFCHR; - if (mode & S_IRUSR) - tmode |= FILEIO_S_IRUSR; - if (mode & S_IWUSR) - tmode |= FILEIO_S_IWUSR; - if (mode & S_IXUSR) - tmode |= FILEIO_S_IXUSR; -#ifdef S_IRGRP - if (mode & S_IRGRP) - tmode |= FILEIO_S_IRGRP; -#endif -#ifdef S_IWRGRP - if (mode & S_IWGRP) - tmode |= FILEIO_S_IWGRP; -#endif -#ifdef S_IXGRP - if (mode & S_IXGRP) - tmode |= FILEIO_S_IXGRP; -#endif - if (mode & S_IROTH) - tmode |= FILEIO_S_IROTH; -#ifdef S_IWOTH - if (mode & S_IWOTH) - tmode |= FILEIO_S_IWOTH; -#endif -#ifdef S_IXOTH - if (mode & S_IXOTH) - tmode |= FILEIO_S_IXOTH; -#endif - return tmode; -} - static int remote_fileio_errno_to_target (int error) { @@ -381,34 +338,6 @@ remote_fileio_extract_ptr_w_len (char **buf, CORE_ADDR *ptrval, int *length) return 0; } -/* Convert to big endian. */ -static void -remote_fileio_to_be (LONGEST num, char *buf, int bytes) -{ - int i; - - for (i = 0; i < bytes; ++i) - buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff; -} - -static void -remote_fileio_to_fio_uint (long num, fio_uint_t fnum) -{ - remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4); -} - -static void -remote_fileio_to_fio_mode (mode_t num, fio_mode_t fnum) -{ - remote_fileio_to_be (remote_fileio_mode_to_target(num), (char *) fnum, 4); -} - -static void -remote_fileio_to_fio_time (time_t num, fio_time_t fnum) -{ - remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4); -} - static void remote_fileio_to_fio_long (LONGEST num, fio_long_t fnum) { @@ -416,46 +345,6 @@ remote_fileio_to_fio_long (LONGEST num, fio_long_t fnum) } static void -remote_fileio_to_fio_ulong (LONGEST num, fio_ulong_t fnum) -{ - remote_fileio_to_be (num, (char *) fnum, 8); -} - -static void -remote_fileio_to_fio_stat (struct stat *st, struct fio_stat *fst) -{ - LONGEST blksize; - - /* `st_dev' is set in the calling function. */ - remote_fileio_to_fio_uint ((long) st->st_ino, fst->fst_ino); - remote_fileio_to_fio_mode (st->st_mode, fst->fst_mode); - remote_fileio_to_fio_uint ((long) st->st_nlink, fst->fst_nlink); - remote_fileio_to_fio_uint ((long) st->st_uid, fst->fst_uid); - remote_fileio_to_fio_uint ((long) st->st_gid, fst->fst_gid); - remote_fileio_to_fio_uint ((long) st->st_rdev, fst->fst_rdev); - remote_fileio_to_fio_ulong ((LONGEST) st->st_size, fst->fst_size); -#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE - blksize = st->st_blksize; -#else - blksize = 512; -#endif - remote_fileio_to_fio_ulong (blksize, fst->fst_blksize); -#if HAVE_STRUCT_STAT_ST_BLOCKS - remote_fileio_to_fio_ulong ((LONGEST) st->st_blocks, fst->fst_blocks); -#else - /* FIXME: This is correct for DJGPP, but other systems that don't - have st_blocks, if any, might prefer 512 instead of st_blksize. - (eliz, 30-12-2003) */ - remote_fileio_to_fio_ulong (((LONGEST) st->st_size + blksize - 1) - / blksize, - fst->fst_blocks); -#endif - remote_fileio_to_fio_time (st->st_atime, fst->fst_atime); - remote_fileio_to_fio_time (st->st_mtime, fst->fst_mtime); - remote_fileio_to_fio_time (st->st_ctime, fst->fst_ctime); -} - -static void remote_fileio_to_fio_timeval (struct timeval *tv, struct fio_timeval *ftv) { remote_fileio_to_fio_time (tv->tv_sec, ftv->ftv_sec); diff --git a/gdb/remote-fileio.h b/gdb/remote-fileio.h index 40a614a..8b32868 100644 --- a/gdb/remote-fileio.h +++ b/gdb/remote-fileio.h @@ -22,6 +22,8 @@ #ifndef REMOTE_FILEIO_H #define REMOTE_FILEIO_H +#include "common-remote-fileio.h" + struct cmd_list_element; /* Unified interface to remote fileio, called in remote.c from |