From patchwork Wed Aug 5 15:28:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 8018 Received: (qmail 42981 invoked by alias); 5 Aug 2015 15:28:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 42857 invoked by uid 89); 5 Aug 2015 15:28:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, 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; Wed, 05 Aug 2015 15:28:22 +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 5FDF7B6F45; Wed, 5 Aug 2015 15:28:21 +0000 (UTC) Received: from blade.nx (ovpn-116-104.ams2.redhat.com [10.36.116.104]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t75FSJ96008722; Wed, 5 Aug 2015 11:28:20 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id D3B60264286; Wed, 5 Aug 2015 16:28:18 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Cc: Sandra Loosemore , Doug Evans , Pedro Alves , Jan Kratochvil , =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= , Paul_Koning@Dell.com Subject: [PATCH 1/2] Warn when accessing binaries over RSP Date: Wed, 5 Aug 2015 16:28:15 +0100 Message-Id: <1438788496-32246-2-git-send-email-gbenson@redhat.com> In-Reply-To: <1438788496-32246-1-git-send-email-gbenson@redhat.com> References: <1438788496-32246-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes GDB provides no indicator of progress during file operations, and can appear to have locked up during slow remote transfers. This commit updates GDB to print a warning each time a file is accessed over RSP. An additional message detailing how to avoid remote transfers is printed for the first transfer only. gdb/ChangeLog: * gdb_bfd.c (gdb_bfd_iovec_fileio_open): Print warnings when BFDs are opened via the remote protocol. gdb/testsuite/ChangeLog: * gdb.trace/pending.exp: Cope with remote transfer warnings. --- gdb/ChangeLog | 5 +++++ gdb/gdb_bfd.c | 33 +++++++++++++++++++++++++++++---- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.trace/pending.exp | 8 ++++---- 4 files changed, 42 insertions(+), 8 deletions(-) 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; + } + } - fd = target_fileio_open ((struct inferior *) inferior, - filename + strlen (TARGET_SYSROOT_PREFIX), - FILEIO_O_RDONLY, 0, - &target_errno); + fd = target_fileio_open ((struct inferior *) inferior, filename, + FILEIO_O_RDONLY, 0, &target_errno); if (fd == -1) { errno = fileio_errno_to_host (target_errno); diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp index 0399807..68e8c7b 100644 --- a/gdb/testsuite/gdb.trace/pending.exp +++ b/gdb/testsuite/gdb.trace/pending.exp @@ -221,7 +221,7 @@ proc pending_tracepoint_resolved_during_trace { trace_type } \ fail $test } } - -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { + -re "Continuing.\r\n(Reading .* from remote target\r\n)?\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { pass $test } } @@ -294,7 +294,7 @@ proc pending_tracepoint_installed_during_trace { trace_type } \ fail $test } } - -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { + -re "Continuing.\r\n(Reading .* from remote target\r\n)?\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { pass $test } } @@ -391,7 +391,7 @@ proc pending_tracepoint_disconnect_after_resolved { trace_type } \ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \ "continue to marker 1" - gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \ + gdb_test "continue" "Continuing.\r\n(Reading .* from remote target\r\n)?\r\nBreakpoint.*marker.*at.*pending.c.*" \ "continue to marker 2" # There should be no pending tracepoint, so no warning should be emitted. @@ -473,7 +473,7 @@ proc pending_tracepoint_with_action_resolved { trace_type } \ fail $test } } - -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { + -re "Continuing.\r\n(Reading .* from remote target\r\n)?\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { pass "continue to marker 2" }