From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 08/10] Handle "show remote memory-write-packet-size" when not connected
Date: Wed, 16 May 2018 14:28:00 -0000 [thread overview]
Message-ID: <20180516141830.16859-9-palves@redhat.com> (raw)
In-Reply-To: <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 <palves@redhat.com>
* 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 <palves@redhat.com>
* 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"
#
--
2.14.3
next prev parent reply other threads:[~2018-05-16 14:25 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-16 14:18 [PATCH 00/10] remote: More multi-target preparation Pedro Alves
2018-05-16 14:18 ` [PATCH 10/10] remote: one struct remote_state per struct remote_target Pedro Alves
2018-05-22 5:07 ` Simon Marchi
2018-05-22 21:06 ` Pedro Alves
2018-05-24 17:00 ` [PATCH 11/10] remote_target::m_remote_state, pointer -> object (Re: [PATCH 10/10] remote: one struct remote_state per struct remote_target) Pedro Alves
2018-05-25 5:23 ` Simon Marchi
2018-05-16 14:18 ` [PATCH 01/10] remote: struct remote_state, use op new Pedro Alves
2018-05-18 20:57 ` Simon Marchi
2018-05-21 15:36 ` [PATCH 1.2 01/10] remote: struct remote_state, use op new, fix leaks Pedro Alves
2018-05-16 14:18 ` [PATCH 02/10] remote: Eliminate remote_hostio_close_cleanup Pedro Alves
2018-05-16 17:43 ` Tom Tromey
2018-05-16 18:53 ` Pedro Alves
2018-05-16 19:46 ` Tom Tromey
2018-05-18 21:04 ` Simon Marchi
2018-05-16 14:18 ` [PATCH 09/10] remote: Make vcont_builder a class Pedro Alves
2018-05-22 5:07 ` Simon Marchi
2018-05-22 21:33 ` Pedro Alves
2018-05-16 14:25 ` [PATCH 05/10] remote: remote_arch_state pointers -> remote_arch_state objects Pedro Alves
2018-05-18 21:17 ` Simon Marchi
2018-05-18 21:18 ` Simon Marchi
2018-05-21 16:12 ` Pedro Alves
2018-05-16 14:25 ` [PATCH 03/10] remote: Make readahead_cache a C++ class Pedro Alves
2018-05-18 21:06 ` Simon Marchi
2018-05-16 14:27 ` [PATCH 04/10] remote: multiple remote_arch_state instances per arch Pedro Alves
2018-05-18 21:09 ` Simon Marchi
2018-05-16 14:28 ` Pedro Alves [this message]
2018-05-18 21:42 ` [PATCH 08/10] Handle "show remote memory-write-packet-size" when not connected Simon Marchi
2018-05-21 20:41 ` Pedro Alves
2018-05-22 3:37 ` Simon Marchi
2018-05-22 21:55 ` Sergio Durigan Junior
2018-05-22 23:26 ` [pushed] Fix gdb.base/remote.exp with native-extended-gdbserver board (Re: [PATCH 08/10] Handle "show remote memory-write-packet-size" when not connected) Pedro Alves
2018-05-16 15:46 ` [PATCH 07/10] remote: Move discard_pending_stop_replies call Pedro Alves
2018-05-18 21:29 ` Simon Marchi
2018-05-16 15:50 ` [PATCH 06/10] remote: Small cleanup in compare_section_command Pedro Alves
2018-05-18 21:26 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180516141830.16859-9-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox