diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e8de369b5a..e7a574be5f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2015-06-05 Gary Benson + + * gdb_bfd.c (gdb_bfd_open): Move vgdb special case to... + * remote.c (remote_filesystem_is_local): ...here. + 2015-06-04 Yao Qi * gdbarch.c: Regenerate it. diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 3d5d23f7cb..2cd91ef96b 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -326,25 +326,11 @@ gdb_bfd_open (const char *name, const char *target, int fd) { gdb_assert (fd == -1); - abfd = gdb_bfd_openr_iovec (name, target, + return gdb_bfd_openr_iovec (name, target, gdb_bfd_iovec_fileio_open, NULL, gdb_bfd_iovec_fileio_pread, gdb_bfd_iovec_fileio_close, gdb_bfd_iovec_fileio_fstat); - - if (abfd != NULL || errno != ENOSYS) - return abfd; - - /* gdb_bfd_iovec_fileio_open failed with ENOSYS. This can - happen, for example, with vgdb (Valgrind GDB), which - presents itself as a remote target but works on the local - filesystem: it does not implement remote get and users - are not expected to set gdb_sysroot. To handle this case - we fall back to trying the local filesystem iff - gdb_sysroot is exactly TARGET_SYSROOT_PREFIX. */ - if (gdb_sysroot == NULL - || strcmp (gdb_sysroot, TARGET_SYSROOT_PREFIX) != 0) - return NULL; } name += strlen (TARGET_SYSROOT_PREFIX); diff --git a/gdb/remote.c b/gdb/remote.c index dfe115b323..53918caeb1 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -10213,15 +10213,6 @@ remote_hostio_send_command (int command_bytes, int which_packet, return ret; } -/* Return nonzero if the filesystem accessed by the target_fileio_* - methods is the local filesystem, zero otherwise. */ - -static int -remote_filesystem_is_local (struct target_ops *self) -{ - return 0; -} - /* Open FILENAME on the remote target, using FLAGS and MODE. Return a remote file descriptor, or -1 if an error occurs (and set *REMOTE_ERRNO). */ @@ -10459,6 +10450,59 @@ remote_hostio_fstat (struct target_ops *self, return 0; } +/* Return nonzero if the filesystem accessed by the target_fileio_* + methods is the local filesystem, zero otherwise. */ + +static int +remote_filesystem_is_local (struct target_ops *self) +{ + /* Valgrind GDB presents itself as a remote target but works + on the local filesystem: it does not implement remote get + and users are not expected to set a sysroot. To handle + this case we treat the remote filesystem as local if the + sysroot is exactly TARGET_SYSROOT_PREFIX and if the stub + does not support vFile:open. */ + if (gdb_sysroot != NULL + && strcmp (gdb_sysroot, TARGET_SYSROOT_PREFIX) == 0) + { + enum packet_support ps = packet_support (PACKET_vFile_open); + + if (ps == PACKET_SUPPORT_UNKNOWN) + { + int fd, remote_errno; + + /* Try opening a file to probe support. The supplied + filename is irrelevant, we only care about whether + the stub recognizes the packet or not. */ + fd = remote_hostio_open (self, "just probing", + FILEIO_O_RDONLY, 0700, + &remote_errno); + + if (fd >= 0) + remote_hostio_close (self, fd, &remote_errno); + + ps = packet_support (PACKET_vFile_open); + } + + if (ps == PACKET_DISABLE) + { + static int warning_issued = 0; + + if (!warning_issued) + { + warning (_("remote target does not support file" + " transfer, attempting to access files" + " from local filesystem.")); + warning_issued = 1; + } + + return 1; + } + } + + return 0; +} + static int remote_fileio_errno_to_host (int errnum) {