From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56638 invoked by alias); 7 May 2015 10:09:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 56578 invoked by uid 89); 7 May 2015 10:09:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 07 May 2015 10:09:52 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 65CC0293216 for ; Thu, 7 May 2015 10:09:51 +0000 (UTC) Received: from blade.nx (ovpn-116-110.ams2.redhat.com [10.36.116.110]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t47A9ngW027210 for ; Thu, 7 May 2015 06:09:50 -0400 Received: by blade.nx (Postfix, from userid 1000) id 7CBE0263CAF; Thu, 7 May 2015 11:09:48 +0100 (BST) Date: Thu, 07 May 2015 10:09:00 -0000 From: Gary Benson To: gdb-patches@sourceware.org Subject: [PING][PATCH] Move vgdb special case into remote_filesystem_is_local Message-ID: <20150507100948.GA31781@blade.nx> References: <1430146276-15606-1-git-send-email-gbenson@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1430146276-15606-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-05/txt/msg00136.txt.bz2 Ping: https://sourceware.org/ml/gdb-patches/2015-04/msg00991.html Gary Benson wrote: > Hi all, > > 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. > > Built and regtested on RHEL6.6 x86_64. > > Ok to commit? > > Cheers, > Gary > > > gdb/ChangeLog: > > * gdb_bfd.c (gdb_bfd_open): Move vgdb special case to... > * remote.c (remote_filesystem_is_local): ...here. > --- > gdb/ChangeLog | 5 ++++ > gdb/gdb_bfd.c | 16 +------------- > gdb/remote.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-------- > 3 files changed, 59 insertions(+), 24 deletions(-) > > diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c > index 3d5d23f..2cd91ef 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 3b2325f..099ddbb 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -9879,15 +9879,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). */ > @@ -10125,6 +10116,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) > { > -- > 1.7.1 > -- http://gbenson.net/