From 5fec4911ec7cd9ea2ee4b5d3be0502e7a7df1f9f Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 18 Aug 2015 22:53:56 +0100 Subject: [PATCH 1/3] gdb: remove packet size limit --- gdb/remote.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index ca1f0df..a839adf 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -894,14 +894,6 @@ get_memory_packet_size (struct memory_packet_config *config) 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 @@ -910,7 +902,7 @@ get_memory_packet_size (struct memory_packet_config *config) if (config->fixed_p) { if (config->size <= 0) - what_they_get = MAX_REMOTE_PACKET_SIZE; + what_they_get = 16384; else what_they_get = config->size; } @@ -929,8 +921,6 @@ get_memory_packet_size (struct memory_packet_config *config) && 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; @@ -3911,6 +3901,7 @@ remote_check_symbols (void) 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 @@ -3929,7 +3920,8 @@ remote_check_symbols (void) /* 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. */ @@ -3967,6 +3959,8 @@ remote_check_symbols (void) getpkt (&rs->buf, &rs->buf_size, 0); reply = rs->buf; } + + do_cleanups (old_chain); } static struct serial * @@ -4089,13 +4083,6 @@ remote_packet_size (const struct protocol_feature *feature, return; } - 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; } @@ -7645,7 +7632,8 @@ putpkt_binary (const char *buf, int cnt) 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); int ch; int tcount = 0; @@ -7738,6 +7726,7 @@ putpkt_binary (const char *buf, int cnt) case '+': if (remote_debug) fprintf_unfiltered (gdb_stdlog, "Ack\n"); + do_cleanups (old_chain); return 1; case '-': if (remote_debug) @@ -7746,7 +7735,10 @@ putpkt_binary (const char *buf, int cnt) case SERIAL_TIMEOUT: tcount++; if (tcount > 3) - return 0; + { + do_cleanups (old_chain); + return 0; + } break; /* Retransmit buffer. */ case '$': { @@ -7833,6 +7825,8 @@ putpkt_binary (const char *buf, int cnt) } #endif } + + do_cleanups (old_chain); return 0; } -- 1.9.3