RFA: PACKET_OVERHEAD constant added to remote.c
Kevin Buettner
kevinb@cygnus.com
Fri Nov 12 10:42:00 GMT 1999
Hi Andrew,
Jesper Skov alerted me to the fact that we were getting some "Remote
packet too long" messages when attempting to debug using a gdbserver
for i386 linux. The problem was that the memory packet size
computations were not taking into account the packet overhead. This
would've been a one line fix, but I decided to define PACKET_OVERHEAD
instead of adding another hard-coded instance of the constant 32.
Kevin
* remote.c (PACKET_OVERHEAD): Define.
(get_memory_packet_size): Take PACKET_OVERHEAD into account when
computing memory packet size.
(build_remote_packet_sizes): Use PACKET_OVERHEAD instead of
hard-coded constants.
Index: remote.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/remote.c,v
retrieving revision 1.258
diff -u -r1.258 remote.c
--- remote.c 1999/11/08 13:14:17 1.258
+++ remote.c 1999/11/12 17:57:13
@@ -315,6 +315,11 @@
/* compatibility. */
#define PBUFSIZ (remote_packet_size)
+/* Overhead for packet header / footer. NOTE: cagney/1999-10-26: I suspect
+ that 8 (``$NN:G...#NN'') is a better guess, the below has been padded a
+ little. */
+#define PACKET_OVERHEAD 32
+
/* User configurable variables for the number of characters in a
memory read/write packet. MIN (PBUFSIZ, g-packet-size) is the
default. Some targets need smaller values (fifo overruns, et.al.)
@@ -358,7 +363,7 @@
}
else
{
- what_they_get = remote_packet_size;
+ what_they_get = remote_packet_size - PACKET_OVERHEAD;
/* Limit the packet to the size specified by the user. */
if (config->size > 0
&& what_they_get > config->size)
@@ -502,12 +507,9 @@
remote_packet_size = 400;
/* Should REGISTER_BYTES needs more space than the default, adjust
the size accordingly. Remember that each byte is encoded as two
- characters. 32 is the overhead for the packet header /
- footer. NOTE: cagney/1999-10-26: I suspect that 8
- (``$NN:G...#NN'') is a better guess, the below has been padded a
- little. */
- if (REGISTER_BYTES > ((remote_packet_size - 32) / 2))
- remote_packet_size = (REGISTER_BYTES * 2 + 32);
+ characters. */
+ if (REGISTER_BYTES > ((remote_packet_size - PACKET_OVERHEAD) / 2))
+ remote_packet_size = (REGISTER_BYTES * 2 + PACKET_OVERHEAD);
/* This one is filled in when a ``g'' packet is received. */
actual_register_packet_size = 0;
More information about the Gdb-patches
mailing list