aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorChristina Schimpe <christina.schimpe@intel.com>2021-11-26 18:23:48 +0000
committerChristina Schimpe <christina.schimpe@intel.com>2023-01-30 12:45:31 +0100
commitfe4c3ca0036b37ea43be1c36728b323f195ef1bb (patch)
treed370dbdef4f70cc7694e634642feaead7175b4d0 /gdb/remote.c
parentff52c0736a637fec4938f4b957bc8847c709b13c (diff)
downloadfsf-binutils-gdb-fe4c3ca0036b37ea43be1c36728b323f195ef1bb.zip
fsf-binutils-gdb-fe4c3ca0036b37ea43be1c36728b323f195ef1bb.tar.gz
fsf-binutils-gdb-fe4c3ca0036b37ea43be1c36728b323f195ef1bb.tar.bz2
gdb: Add per-remote target variables for memory read and write config
This patch adds per-remote target variables for the configuration of memory read- and write packet size. It is a further change to commit "gdb: Make global feature array a per-remote target array" to apply the fixme notes described in commit 5b6d1e4 "Multi-target support". The former global variables for that configuration are still available to allow the command line configuration for all future remote connections. Similar to the command line configuration of the per- remote target feature array, the commands - set remotewritesize (deprecated) - set remote memory-read-packet-size - set remote memory-write-packet-size will configure the current target (if available). If no target is available, the default configuration for future remote connections is adapted. The show command will display the current remote target's packet size configuration. If no remote target is selected, the default configuration for future connections will be shown. It is required to adapt the test gdb.base/remote.exp which is failing for --target_board=native-extended-gdbserver. With that board GDB connects to gdbserver at gdb start time. Due to this patch two loggings "The target may not be able to.." are shown if the command 'set remote memory-write-packet-size fixed' is executed while a target is connected for the current inferior. To fix this, the clean_restart command is moved to a later time point of the test. It is sufficient to be connected to the server when "runto_main" is executed. Now the connection time is similar to a testrun with --target_board=native-gdbserver. To allow the user to distinguish between the packet-size configuration for future remote connections and for the currently selected target, the commands' loggings are adapted.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c163
1 files changed, 117 insertions, 46 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index e433329..9f78d35 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -600,6 +600,32 @@ struct packet_config
enum packet_support support;
};
+/* User configurable variables for the number of characters in a
+ memory read/write packet. MIN (rsa->remote_packet_size,
+ rsa->sizeof_g_packet) is the default. Some targets need smaller
+ values (fifo overruns, et.al.) and some users need larger values
+ (speed up transfers). The variables ``preferred_*'' (the user
+ request), ``current_*'' (what was actually set) and ``forced_*''
+ (Positive - a soft limit, negative - a hard limit). */
+
+struct memory_packet_config
+{
+ const char *name;
+ long size;
+ int fixed_p;
+};
+
+/* These global variables contain the default configuration for every new
+ remote_feature object. */
+static memory_packet_config memory_read_packet_config =
+{
+ "memory-read-packet-size",
+};
+static memory_packet_config memory_write_packet_config =
+{
+ "memory-write-packet-size",
+};
+
/* This global array contains packet descriptions (name and title). */
static packet_description packets_descriptions[PACKET_MAX];
/* This global array contains the default configuration for every new
@@ -613,6 +639,9 @@ struct remote_features
{
remote_features ()
{
+ m_memory_read_packet_config = memory_read_packet_config;
+ m_memory_write_packet_config = memory_write_packet_config;
+
std::copy (std::begin (remote_protocol_packets),
std::end (remote_protocol_packets),
std::begin (m_protocol_packets));
@@ -658,6 +687,11 @@ struct remote_features
packet_result packet_ok (const char *buf, const int which_packet);
packet_result packet_ok (const gdb::char_vector &buf, const int which_packet);
+ /* Configuration of a remote target's memory read packet. */
+ memory_packet_config m_memory_read_packet_config;
+ /* Configuration of a remote target's memory write packet. */
+ memory_packet_config m_memory_write_packet_config;
+
/* The per-remote target array which stores a remote's packet
configurations. */
packet_config m_protocol_packets[PACKET_MAX];
@@ -1921,21 +1955,6 @@ show_remotebreak (struct ui_file *file, int from_tty,
static unsigned int remote_address_size;
-/* User configurable variables for the number of characters in a
- memory read/write packet. MIN (rsa->remote_packet_size,
- rsa->sizeof_g_packet) is the default. Some targets need smaller
- values (fifo overruns, et.al.) and some users need larger values
- (speed up transfers). The variables ``preferred_*'' (the user
- request), ``current_*'' (what was actually set) and ``forced_*''
- (Positive - a soft limit, negative - a hard limit). */
-
-struct memory_packet_config
-{
- const char *name;
- long size;
- int fixed_p;
-};
-
/* The default max memory-write-packet-size, when the setting is
"fixed". The 16k is historical. (It came from older GDB's using
alloca for buffers and the knowledge (folklore?) that some hosts
@@ -2001,13 +2020,14 @@ remote_target::get_memory_packet_size (struct memory_packet_config *config)
something really big then do a sanity check. */
static void
-set_memory_packet_size (const char *args, struct memory_packet_config *config)
+set_memory_packet_size (const char *args, struct memory_packet_config *config,
+ bool target_connected)
{
int fixed_p = config->fixed_p;
long size = config->size;
if (args == NULL)
- error (_("Argument required (integer, `fixed' or `limited')."));
+ error (_("Argument required (integer, \"fixed\" or \"limit\")."));
else if (strcmp (args, "hard") == 0
|| strcmp (args, "fixed") == 0)
fixed_p = 1;
@@ -2035,31 +2055,49 @@ set_memory_packet_size (const char *args, struct memory_packet_config *config)
? DEFAULT_MAX_MEMORY_PACKET_SIZE_FIXED
: size);
- if (! query (_("The target may not be able to correctly handle a %s\n"
- "of %ld bytes. Change the packet size? "),
- config->name, query_size))
+ if (target_connected
+ && !query (_("The target may not be able to correctly handle a %s\n"
+ "of %ld bytes. Change the packet size? "),
+ config->name, query_size))
+ error (_("Packet size not changed."));
+ else if (!target_connected
+ && !query (_("Future remote targets may not be able to "
+ "correctly handle a %s\nof %ld bytes. Change the "
+ "packet size for future remote targets? "),
+ config->name, query_size))
error (_("Packet size not changed."));
}
/* Update the config. */
config->fixed_p = fixed_p;
config->size = size;
+
+ const char *target_type = get_target_type_name (target_connected);
+ gdb_printf (_("The %s %s is set to \"%s\".\n"), config->name, target_type,
+ args);
+
}
+/* Show the memory-read or write-packet size configuration CONFIG of the
+ target REMOTE. If REMOTE is nullptr, the default configuration for future
+ remote targets should be passed in CONFIG. */
+
static void
-show_memory_packet_size (struct memory_packet_config *config)
+show_memory_packet_size (memory_packet_config *config, remote_target *remote)
{
+ const char *target_type = get_target_type_name (remote != nullptr);
+
if (config->size == 0)
- gdb_printf (_("The %s is 0 (default). "), config->name);
+ gdb_printf (_("The %s %s is 0 (default). "), config->name, target_type);
else
- gdb_printf (_("The %s is %ld. "), config->name, config->size);
+ gdb_printf (_("The %s %s is %ld. "), config->name, target_type,
+ config->size);
+
if (config->fixed_p)
gdb_printf (_("Packets are fixed at %ld bytes.\n"),
get_fixed_memory_packet_size (config));
else
{
- remote_target *remote = get_current_remote_target ();
-
- if (remote != NULL)
+ if (remote != nullptr)
gdb_printf (_("Packets are limited to %ld bytes.\n"),
remote->get_memory_packet_size (config));
else
@@ -2068,22 +2106,39 @@ show_memory_packet_size (struct memory_packet_config *config)
}
}
-/* FIXME: needs to be per-remote-target. */
-static struct memory_packet_config memory_write_packet_config =
-{
- "memory-write-packet-size",
-};
+/* Configure the memory-write-packet size of the currently selected target. If
+ no target is available, the default configuration for future remote targets
+ is configured. */
static void
set_memory_write_packet_size (const char *args, int from_tty)
{
- set_memory_packet_size (args, &memory_write_packet_config);
+ remote_target *remote = get_current_remote_target ();
+ if (remote != nullptr)
+ {
+ set_memory_packet_size
+ (args, &remote->m_features.m_memory_write_packet_config, true);
+ }
+ else
+ {
+ memory_packet_config* config = &memory_write_packet_config;
+ set_memory_packet_size (args, config, false);
+ }
}
+/* Display the memory-write-packet size of the currently selected target. If
+ no target is available, the default configuration for future remote targets
+ is shown. */
+
static void
show_memory_write_packet_size (const char *args, int from_tty)
{
- show_memory_packet_size (&memory_write_packet_config);
+ remote_target *remote = get_current_remote_target ();
+ if (remote != nullptr)
+ show_memory_packet_size (&remote->m_features.m_memory_write_packet_config,
+ remote);
+ else
+ show_memory_packet_size (&memory_write_packet_config, nullptr);
}
/* Show the number of hardware watchpoints that can be used. */
@@ -2139,31 +2194,47 @@ show_remote_packet_max_chars (struct ui_file *file, int from_tty,
long
remote_target::get_memory_write_packet_size ()
{
- return get_memory_packet_size (&memory_write_packet_config);
+ return get_memory_packet_size (&m_features.m_memory_write_packet_config);
}
-/* FIXME: needs to be per-remote-target. */
-static struct memory_packet_config memory_read_packet_config =
-{
- "memory-read-packet-size",
-};
+/* Configure the memory-read-packet size of the currently selected target. If
+ no target is available, the default configuration for future remote targets
+ is adapted. */
static void
set_memory_read_packet_size (const char *args, int from_tty)
{
- set_memory_packet_size (args, &memory_read_packet_config);
+ remote_target *remote = get_current_remote_target ();
+ if (remote != nullptr)
+ set_memory_packet_size
+ (args, &remote->m_features.m_memory_read_packet_config, true);
+ else
+ {
+ memory_packet_config* config = &memory_read_packet_config;
+ set_memory_packet_size (args, config, false);
+ }
+
}
+/* Display the memory-read-packet size of the currently selected target. If
+ no target is available, the default configuration for future remote targets
+ is shown. */
+
static void
show_memory_read_packet_size (const char *args, int from_tty)
{
- show_memory_packet_size (&memory_read_packet_config);
+ remote_target *remote = get_current_remote_target ();
+ if (remote != nullptr)
+ show_memory_packet_size (&remote->m_features.m_memory_read_packet_config,
+ remote);
+ else
+ show_memory_packet_size (&memory_read_packet_config, nullptr);
}
long
remote_target::get_memory_read_packet_size ()
{
- long size = get_memory_packet_size (&memory_read_packet_config);
+ long size = get_memory_packet_size (&m_features.m_memory_read_packet_config);
/* FIXME: cagney/1999-11-07: Functions like getpkt() need to get an
extra buffer size argument before the memory read size can be
@@ -15082,16 +15153,16 @@ Show the maximum number of bytes per memory write packet (deprecated)."),
Set the maximum number of bytes per memory-write packet.\n\
Specify the number of bytes in a packet or 0 (zero) for the\n\
default packet size. The actual limit is further reduced\n\
-dependent on the target. Specify ``fixed'' to disable the\n\
-further restriction and ``limit'' to enable that restriction."),
+dependent on the target. Specify \"fixed\" to disable the\n\
+further restriction and \"limit\" to enable that restriction."),
&remote_set_cmdlist);
add_cmd ("memory-read-packet-size", no_class,
set_memory_read_packet_size, _("\
Set the maximum number of bytes per memory-read packet.\n\
Specify the number of bytes in a packet or 0 (zero) for the\n\
default packet size. The actual limit is further reduced\n\
-dependent on the target. Specify ``fixed'' to disable the\n\
-further restriction and ``limit'' to enable that restriction."),
+dependent on the target. Specify \"fixed\" to disable the\n\
+further restriction and \"limit\" to enable that restriction."),
&remote_set_cmdlist);
add_cmd ("memory-write-packet-size", no_class,
show_memory_write_packet_size,