From patchwork Wed May 16 14:18:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 27290 Received: (qmail 63258 invoked by alias); 16 May 2018 14:25:33 -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 60521 invoked by uid 89); 16 May 2018 14:25:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:4341, online X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 May 2018 14:25:26 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B102440711DD for ; Wed, 16 May 2018 14:18:36 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 638451002948 for ; Wed, 16 May 2018 14:18:36 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 08/10] Handle "show remote memory-write-packet-size" when not connected Date: Wed, 16 May 2018 15:18:28 +0100 Message-Id: <20180516141830.16859-9-palves@redhat.com> In-Reply-To: <20180516141830.16859-1-palves@redhat.com> References: <20180516141830.16859-1-palves@redhat.com> Currently "show remote memory-write-packet-size" says that the packet size is limited to whatever is stored in the remote_state global, even if not connected to a target. When we get to support multiple instances of remote targets, there won't be a remote_state global anymore, so that must be replaced by something else. Since it doesn't make sense to print the limit of the packet size of a non-existing connection, this patch makes us say that the limit will be further reduced when we connect. The text is taken from the command's online help, which says: "The actual limit is further reduced dependent on the target." gdb/ChangeLog: yyyy-mm-dd Pedro Alves * remote.c (get_fixed_memory_packet_size): New. (get_memory_packet_size): Use it. (show_memory_packet_size): Use it. Don't refer to get_memory_packet_size if not connected to a remote target. gdb/testsuite/ChangeLog: yyyy-mm-dd Pedro Alves * gdb.base/remote.exp: Adjust expected output of "show remote memory-write-packet-size". --- gdb/remote.c | 34 +++++++++++++++++++++++++--------- gdb/testsuite/gdb.base/remote.exp | 6 +++--- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 230288b727..7ec8d24a3b 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1333,6 +1333,19 @@ struct memory_packet_config can write at least one byte. */ #define MIN_MEMORY_PACKET_SIZE 20 +/* Get the memory packet size, assuming it is fixed. */ + +static long +get_fixed_memory_packet_size (struct memory_packet_config *config) +{ + gdb_assert (config->fixed_p); + + if (config->size <= 0) + return DEFAULT_MAX_MEMORY_PACKET_SIZE; + else + return config->size; +} + /* Compute the current size of a read/write packet. Since this makes use of ``actual_register_packet_size'' the computation is dynamic. */ @@ -1344,12 +1357,7 @@ get_memory_packet_size (struct memory_packet_config *config) long what_they_get; if (config->fixed_p) - { - if (config->size <= 0) - what_they_get = DEFAULT_MAX_MEMORY_PACKET_SIZE; - else - what_they_get = config->size; - } + what_they_get = get_fixed_memory_packet_size (config); else { what_they_get = get_remote_packet_size (); @@ -1432,10 +1440,18 @@ show_memory_packet_size (struct memory_packet_config *config) printf_filtered (_("The %s is %ld. "), config->name, config->size); if (config->fixed_p) printf_filtered (_("Packets are fixed at %ld bytes.\n"), - get_memory_packet_size (config)); + get_fixed_memory_packet_size (config)); else - printf_filtered (_("Packets are limited to %ld bytes.\n"), - get_memory_packet_size (config)); + { + struct remote_state *rs = get_remote_state (); + + if (rs->remote_desc != NULL) + printf_filtered (_("Packets are limited to %ld bytes.\n"), + get_memory_packet_size (config)); + else + puts_filtered ("The actual limit will be further reduced " + "dependent on the target.\n"); + } } static struct memory_packet_config memory_write_packet_config = diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp index 26361af9a5..4f0eb10ea4 100644 --- a/gdb/testsuite/gdb.base/remote.exp +++ b/gdb/testsuite/gdb.base/remote.exp @@ -35,7 +35,7 @@ if {$result != "" } then { # gdb_test "show remote memory-write-packet-size" \ - "The memory-write-packet-size is 0. Packets are limited to \[0-9\]+ bytes." \ + "The memory-write-packet-size is 0. The actual limit will be further reduced dependent on the target\." \ "write-packet default" gdb_test "set remote memory-write-packet-size" \ @@ -44,12 +44,12 @@ gdb_test "set remote memory-write-packet-size" \ gdb_test_no_output "set remote memory-write-packet-size 20" gdb_test "show remote memory-write-packet-size" \ - "The memory-write-packet-size is 20. Packets are limited to 20 bytes." \ + "The memory-write-packet-size is 20. The actual limit will be further reduced dependent on the target\." \ "set write-packet - small" gdb_test_no_output "set remote memory-write-packet-size 1" gdb_test "show remote memory-write-packet-size" \ - "The memory-write-packet-size is 1. Packets are limited to 20 bytes." \ + "The memory-write-packet-size is 1. The actual limit will be further reduced dependent on the target\." \ "set write-packet - very-small" #