From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120749 invoked by alias); 11 Aug 2015 14:04:45 -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 120740 invoked by uid 89); 11 Aug 2015 14:04:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_20,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no 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; Tue, 11 Aug 2015 14:04:44 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id BBA8155; Tue, 11 Aug 2015 14:04:42 +0000 (UTC) Received: from blade.nx (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7BE4fv5027457; Tue, 11 Aug 2015 10:04:42 -0400 Received: by blade.nx (Postfix, from userid 1000) id 0A05D2642FC; Tue, 11 Aug 2015 15:04:40 +0100 (BST) Date: Tue, 11 Aug 2015 14:04:00 -0000 From: Gary Benson To: Andrew Burgess Cc: gdb-patches@sourceware.org, Sandra Loosemore , Doug Evans , Pedro Alves , Jan Kratochvil , =?iso-8859-1?Q?Andr=E9_P=F6nitz?= , Paul_Koning@Dell.com Subject: Re: [PATCH 1/2] Warn when accessing binaries over RSP Message-ID: <20150811140440.GB24095@blade.nx> References: <1438788496-32246-1-git-send-email-gbenson@redhat.com> <1438788496-32246-2-git-send-email-gbenson@redhat.com> <20150811115538.GA7352@embecosm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150811115538.GA7352@embecosm.com> X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00237.txt.bz2 Andrew Burgess wrote: > * Gary Benson [2015-08-05 16:28:15 +0100]: > > > > diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c > > index 1781d80..b511777 100644 > > --- a/gdb/gdb_bfd.c > > +++ b/gdb/gdb_bfd.c > > @@ -219,13 +219,38 @@ gdb_bfd_iovec_fileio_open (struct bfd *abfd, void *inferior) > > const char *filename = bfd_get_filename (abfd); > > int fd, target_errno; > > int *stream; > > + struct target_ops *ops = find_target_at (process_stratum); > > > > gdb_assert (is_target_filename (filename)); > > + filename += strlen (TARGET_SYSROOT_PREFIX); > > + > > + /* GDB provides no indicator of progress during file operations, and > > + can appear to have locked up during slow remote transfers, so we > > + inform the user what is happening and suggest a way out. It's > > + unpleasant that we need to detect remote targets this way (rather > > + than putting the warnings in remote_hostio_open), but it's not > > + possible for remote_hostio_open to differentiate between > > + accessing inferior binaries (which can be bypassed) and accessing > > + things like /proc/ (which is unavoidable). */ > > + if (strcmp (ops->to_shortname, "remote") == 0 > > + || strcmp (ops->to_shortname, "extended-remote") == 0) > > + { > > + static int warning_issued = 0; > > + > > + printf_unfiltered (_("Reading %s from remote target\n"), > > + filename); > > + > > + if (!warning_issued) > > + { > > + warning (_("File transfers from remote targets can be slow.\n" > > + "Use \"set sysroot\" to access files locally" > > + " instead.")); > > + warning_issued = 1; > > + } > > + } > > Altering the behaviour based on to_shortname feels like breaking > this nice target OO model we have. Yeah... :-/ > Could the warning not be moved down into target_fileio_open instead? Not so much target_fileio_open as remote_hostio_open; only remote targets need the warning. And originally I thought no, the warning couldn't go there, because target_fileio_open/remote_hostio_open is used for various internal things such as /proc/ file reads on Linux that the user shouldn't see. ...however... remote_hostio_open *can* differentiate between reading inferior binaries and reading internal stuff because the internal stuff is accessed with the INF argument NULL and binaries are accessed with a non-NULL INF. So I can do that, if it doesn't seem too hacky. > Or if that's really not an appropriate place should we add a new > target method? I considered that but couldn't think of a good name :-) target_fileio_warn_if_slow ?? I can do that too. Cheers, Gary -- http://gbenson.net/