#include "regcache.h"
#include "value.h"
#include "gdb_assert.h"
+#include "observer.h"
#include <ctype.h>
#include <sys/time.h>
#ifndef MAX_REMOTE_PACKET_SIZE
#define MAX_REMOTE_PACKET_SIZE 16384
#endif
- /* NOTE: 16 is just chosen at random. */
+ /* NOTE: 20 ensures we can write at least one byte. */
#ifndef MIN_REMOTE_PACKET_SIZE
-#define MIN_REMOTE_PACKET_SIZE 16
+#define MIN_REMOTE_PACKET_SIZE 20
#endif
long what_they_get;
if (config->fixed_p)
struct cmd_list_element **show_remote_list,
int legacy)
{
- struct cmd_list_element *set_cmd;
- struct cmd_list_element *show_cmd;
char *set_doc;
char *show_doc;
- char *help_doc;
- char *print;
char *cmd_name;
+
config->name = name;
config->title = title;
config->detect = AUTO_BOOLEAN_AUTO;
name, title);
show_doc = xstrprintf ("Show current use of remote protocol `%s' (%s) packet",
name, title);
- print = xstrprintf ("Current use of remote protocol `%s' (%s) is %%s",
- name, title);
/* set/show TITLE-packet {auto,on,off} */
cmd_name = xstrprintf ("%s-packet", title);
add_setshow_auto_boolean_cmd (cmd_name, class_obscure,
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_vcont);
}
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_qSymbol);
}
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_P);
}
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_SOFTWARE_BP]);
}
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_HARDWARE_BP]);
}
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_WRITE_WP]);
}
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_READ_WP]);
}
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_ACCESS_WP]);
}
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_binary_download);
}
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_qPart_auxv);
}
struct cmd_list_element *c,
const char *value)
{
- deprecated_show_value_hack (file, from_tty, c, value);
show_packet_config_cmd (&remote_protocol_p);
}
in the buffer is not a hex character, assume that has happened
and try to fetch another packet to read. */
while ((buf[0] < '0' || buf[0] > '9')
+ && (buf[0] < 'A' || buf[0] > 'F')
&& (buf[0] < 'a' || buf[0] > 'f')
&& buf[0] != 'x') /* New: unavailable register value. */
{
{
int i;
regs = alloca (rs->sizeof_g_packet);
- memset (regs, rs->sizeof_g_packet, 0);
+ memset (regs, 0, rs->sizeof_g_packet);
for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++)
{
struct packet_reg *r = &rs->regs[i];
/* Verify that the target can support a binary download. */
check_binary_download (memaddr);
+ payload_size = get_memory_write_packet_size ();
+
/* Compute the size, and then allocate space for the largest
- possible packet. Include space for an extra trailing NULL. */
- sizeof_buf = get_memory_write_packet_size () + 1;
+ possible packet. Include space for an extra trailing NUL. */
+ sizeof_buf = payload_size + 1;
buf = alloca (sizeof_buf);
/* Compute the size of the actual payload by subtracting out the
- packet header and footer overhead: "$M<memaddr>,<len>:...#nn". */
- payload_size = (get_memory_write_packet_size () - (strlen ("$M,:#NN")
- + hexnumlen (memaddr)
- + hexnumlen (len)));
+ packet header and footer overhead: "$M<memaddr>,<len>:...#nn".
+ */
+ payload_size -= strlen ("$M,:#NN");
+ payload_size -= hexnumlen (memaddr);
/* Construct the packet header: "[MX]<memaddr>,<len>:". */
*p++ = 'X';
/* Best guess at number of bytes that will fit. */
todo = min (len, payload_size);
+ payload_size -= hexnumlen (todo);
+ todo = min (todo, payload_size);
break;
case PACKET_DISABLE:
*p++ = 'M';
/* Num bytes that will fit. */
todo = min (len, payload_size / 2);
+ payload_size -= hexnumlen (todo);
+ todo = min (todo, payload_size / 2);
break;
case PACKET_SUPPORT_UNKNOWN:
internal_error (__FILE__, __LINE__,
default:
internal_error (__FILE__, __LINE__, _("bad switch"));
}
+ if (todo <= 0)
+ internal_error (__FILE__, __LINE__,
+ _("minumum packet size too small to write data"));
/* Append "<memaddr>". */
memaddr = remote_address_masked (memaddr);
static char *
remote_pid_to_str (ptid_t ptid)
{
- static char buf[30];
+ static char buf[32];
+ int size;
- sprintf (buf, "Thread %d", PIDGET (ptid));
+ size = snprintf (buf, sizeof buf, "thread %d", ptid_get_pid (ptid));
+ gdb_assert (size < sizeof buf);
return buf;
}