diff options
author | Gary Benson <gbenson@redhat.com> | 2015-06-05 16:08:05 +0100 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2015-06-05 16:08:05 +0100 |
commit | e3dd7556ad89bf00c2a92f76079ae1c53dc130a8 (patch) | |
tree | 79bf7fdb88953c5a9aaefc0cded72b96d94518ad /gdb/remote.c | |
parent | f8b447819b3d65c3bea65dee860110aa198c081e (diff) | |
download | gdb-e3dd7556ad89bf00c2a92f76079ae1c53dc130a8.zip gdb-e3dd7556ad89bf00c2a92f76079ae1c53dc130a8.tar.gz gdb-e3dd7556ad89bf00c2a92f76079ae1c53dc130a8.tar.bz2 |
Move vgdb special case into remote_filesystem_is_local
Valgrind GDB (vgdb) presents itself as a remote target but works on
the local filesystem. gdb_bfd_open contained a special case to make
vgdb work with "target:" sysroots, but the implementation meant that
GDB would fall back to the local filesystem if *any* to_fileio_open
method failed with ENOSYS for *any* reason. This commit moves the
vgdb special case to remote_filesystem_is_local to allow the fallback
to be restricted only to the specific case that remote file transfer
is unsupported. This commit also adds a warning which is displayed
the first time the fallback is used.
gdb/ChangeLog:
* gdb_bfd.c (gdb_bfd_open): Move vgdb special case to...
* remote.c (remote_filesystem_is_local): ...here.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 62 |
1 files changed, 53 insertions, 9 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index dfe115b..53918ca 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) { |