The remote packet buffer size is currently capped to 16384 mostly for
historical reasons, related to use of alloca. Stop using alloca and
remove the limitation.
Tested on x86_64 Fedora 20.
gdb/ChangeLog:
2015-08-27 Pedro Alves <palves@redhat.com>
* remote.c (DEFAULT_MAX_MEMORY_PACKET_SIZE)
(MIN_MEMORY_PACKET_SIZE): New.
(MAX_REMOTE_PACKET_SIZE, MIN_REMOTE_PACKET_SIZE): Delete.
(get_memory_packet_size): Adjust. No longer limit the max packet
size.
(set_memory_packet_size): Adjust, and remove dead code.
(remote_check_symbols): Use xmalloc and a cleanup instead of
alloca.
(remote_packet_size): No longer cap the packet size.
(putpkt_binary): Use xmalloc and a cleanup instead of alloca.
+2015-08-27 Pedro Alves <palves@redhat.com>
+
+ * remote.c (DEFAULT_MAX_MEMORY_PACKET_SIZE)
+ (MIN_MEMORY_PACKET_SIZE): New.
+ (MAX_REMOTE_PACKET_SIZE, MIN_REMOTE_PACKET_SIZE): Delete.
+ (get_memory_packet_size): Adjust. No longer limit the max packet
+ size.
+ (set_memory_packet_size): Adjust, and remove dead code.
+ (remote_check_symbols): Use xmalloc and a cleanup instead of
+ alloca.
+ (remote_packet_size): No longer cap the packet size.
+ (putpkt_binary): Use xmalloc and a cleanup instead of alloca.
+
2015-08-26 Luis Machado <lgustavo@codesourcery.com>
* compile/compile.c (compile_to_object): Mention language in
2015-08-26 Luis Machado <lgustavo@codesourcery.com>
* compile/compile.c (compile_to_object): Mention language in
+/* The default max memory-write-packet-size. The 16k is historical.
+ (It came from older GDB's using alloca for buffers and the
+ knowledge (folklore?) that some hosts don't cope very well with
+ large alloca calls.) */
+#define DEFAULT_MAX_MEMORY_PACKET_SIZE 16384
+
+/* The minimum remote packet size for memory transfers. Ensures we
+ can write at least one byte. */
+#define MIN_MEMORY_PACKET_SIZE 20
+
/* Compute the current size of a read/write packet. Since this makes
use of ``actual_register_packet_size'' the computation is dynamic. */
/* Compute the current size of a read/write packet. Since this makes
use of ``actual_register_packet_size'' the computation is dynamic. */
struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state ();
struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state ();
- /* NOTE: The somewhat arbitrary 16k comes from the knowledge (folk
- law?) that some hosts don't cope very well with large alloca()
- calls. Eventually the alloca() code will be replaced by calls to
- xmalloc() and make_cleanups() allowing this restriction to either
- be lifted or removed. */
-#ifndef MAX_REMOTE_PACKET_SIZE
-#define MAX_REMOTE_PACKET_SIZE 16384
-#endif
- /* NOTE: 20 ensures we can write at least one byte. */
-#ifndef MIN_REMOTE_PACKET_SIZE
-#define MIN_REMOTE_PACKET_SIZE 20
-#endif
long what_they_get;
if (config->fixed_p)
{
if (config->size <= 0)
long what_they_get;
if (config->fixed_p)
{
if (config->size <= 0)
- what_they_get = MAX_REMOTE_PACKET_SIZE;
+ what_they_get = DEFAULT_MAX_MEMORY_PACKET_SIZE;
else
what_they_get = config->size;
}
else
what_they_get = config->size;
}
&& what_they_get > rsa->actual_register_packet_size)
what_they_get = rsa->actual_register_packet_size;
}
&& what_they_get > rsa->actual_register_packet_size)
what_they_get = rsa->actual_register_packet_size;
}
- if (what_they_get > MAX_REMOTE_PACKET_SIZE)
- what_they_get = MAX_REMOTE_PACKET_SIZE;
- if (what_they_get < MIN_REMOTE_PACKET_SIZE)
- what_they_get = MIN_REMOTE_PACKET_SIZE;
+ if (what_they_get < MIN_MEMORY_PACKET_SIZE)
+ what_they_get = MIN_MEMORY_PACKET_SIZE;
/* Make sure there is room in the global buffer for this packet
(including its trailing NUL byte). */
/* Make sure there is room in the global buffer for this packet
(including its trailing NUL byte). */
size = strtoul (args, &end, 0);
if (args == end)
error (_("Invalid %s (bad syntax)."), config->name);
size = strtoul (args, &end, 0);
if (args == end)
error (_("Invalid %s (bad syntax)."), config->name);
-#if 0
- /* Instead of explicitly capping the size of a packet to
- MAX_REMOTE_PACKET_SIZE or dissallowing it, the user is
- instead allowed to set the size to something arbitrarily
- large. */
- if (size > MAX_REMOTE_PACKET_SIZE)
- error (_("Invalid %s (too large)."), config->name);
-#endif
+
+ /* Instead of explicitly capping the size of a packet to or
+ disallowing it, the user is allowed to set the size to
+ something arbitrarily large. */
+
+ /* So that the query shows the correct value. */
+ if (size <= 0)
+ size = DEFAULT_MAX_MEMORY_PACKET_SIZE;
+
/* Extra checks? */
if (fixed_p && !config->fixed_p)
{
/* Extra checks? */
if (fixed_p && !config->fixed_p)
{
char *msg, *reply, *tmp;
struct bound_minimal_symbol sym;
int end;
char *msg, *reply, *tmp;
struct bound_minimal_symbol sym;
int end;
+ struct cleanup *old_chain;
/* The remote side has no concept of inferiors that aren't running
yet, it only knows about running processes. If we're connected
/* The remote side has no concept of inferiors that aren't running
yet, it only knows about running processes. If we're connected
/* Allocate a message buffer. We can't reuse the input buffer in RS,
because we need both at the same time. */
/* Allocate a message buffer. We can't reuse the input buffer in RS,
because we need both at the same time. */
- msg = alloca (get_remote_packet_size ());
+ msg = xmalloc (get_remote_packet_size ());
+ old_chain = make_cleanup (xfree, msg);
/* Invite target to request symbol lookups. */
/* Invite target to request symbol lookups. */
getpkt (&rs->buf, &rs->buf_size, 0);
reply = rs->buf;
}
getpkt (&rs->buf, &rs->buf_size, 0);
reply = rs->buf;
}
+
+ do_cleanups (old_chain);
- if (packet_size > MAX_REMOTE_PACKET_SIZE)
- {
- warning (_("limiting remote suggested packet size (%d bytes) to %d"),
- packet_size, MAX_REMOTE_PACKET_SIZE);
- packet_size = MAX_REMOTE_PACKET_SIZE;
- }
-
/* Record the new maximum packet size. */
rs->explicit_packet_size = packet_size;
}
/* Record the new maximum packet size. */
rs->explicit_packet_size = packet_size;
}
struct remote_state *rs = get_remote_state ();
int i;
unsigned char csum = 0;
struct remote_state *rs = get_remote_state ();
int i;
unsigned char csum = 0;
- char *buf2 = alloca (cnt + 6);
+ char *buf2 = xmalloc (cnt + 6);
+ struct cleanup *old_chain = make_cleanup (xfree, buf2);
case '+':
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "Ack\n");
case '+':
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "Ack\n");
+ do_cleanups (old_chain);
return 1;
case '-':
if (remote_debug)
return 1;
case '-':
if (remote_debug)
case SERIAL_TIMEOUT:
tcount++;
if (tcount > 3)
case SERIAL_TIMEOUT:
tcount++;
if (tcount > 3)
+ {
+ do_cleanups (old_chain);
+ return 0;
+ }
break; /* Retransmit buffer. */
case '$':
{
break; /* Retransmit buffer. */
case '$':
{
+
+ do_cleanups (old_chain);