From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 127211 invoked by alias); 11 Aug 2015 17:15:32 -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 127202 invoked by uid 89); 11 Aug 2015 17:15:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_20,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f201.google.com Received: from mail-pd0-f201.google.com (HELO mail-pd0-f201.google.com) (209.85.192.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 11 Aug 2015 17:15:30 +0000 Received: by pdbfa8 with SMTP id fa8so12105324pdb.1 for ; Tue, 11 Aug 2015 10:15:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:message-id:date:subject:from:to:cc :content-type; bh=H62pTTo8za2RDapbq9VZA0iH3ljnIBfToa30bJgQFiY=; b=cJVKyj5n7NgDtgVgYOjWc/J8LwFYoNiYfQG29EJdome6FvlJrGfC7nwm8w33jzPMSe 3sQsfF+AGxDKJsaHylYjQkt4iOa+Q5X2QzbitJvxOCNMGxkKDVRbUnMmMCEEy/qpdV4g 7CIOziS1IA7nfe8OkeQvdkA5GTisEOLJTpW5FmPFV5Cyx+u9W7za29GaspqR1mIQ0Y6l mbA4gsJGyXiqLvx6oRCdBvVLeoJSGnptg/kkAJWHS3oxjUckndfA2pdBsrR3FHusdch+ RcO6mZEsmBFZo4xC4+9BSjOmi38B56sr0ceZ1TpJui2p3hlg4Zx6tFwfUz5vcUiH81E3 Znvg== X-Gm-Message-State: ALoCoQmbZi5l0wvrJqv/UyogOMMzer7jKY+mZUGwU50hhywHUqQZiutyw4L2IV+gifNq0ZU8yzwO MIME-Version: 1.0 X-Received: by 10.66.164.225 with SMTP id yt1mr26532359pab.32.1439313328771; Tue, 11 Aug 2015 10:15:28 -0700 (PDT) Message-ID: <047d7b86c3b0aeea05051d0c3fb7@google.com> Date: Tue, 11 Aug 2015 17:15:00 -0000 Subject: Re: [PATCH 1/2] Warn when accessing binaries over RSP From: Doug Evans To: Gary Benson Cc: Andrew Burgess , gdb-patches@sourceware.org, Sandra Loosemore , Pedro Alves , Jan Kratochvil , "=?iso-8859-1?Q?Andr=E9_P=F6nitz?=" , Paul_Koning@Dell.com Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00241.txt.bz2 Gary Benson writes: > 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. FAOD, target_fileio_open_warn_if_slow?