Bypass GDB bug which asks to read packet slightly too big
GDB sometimes asks slightly too big read packets
(no taking into account the packet overhead).
Bypass the problem by allocating slightly more than needed
if GDB would only ask the correct maximum size.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13472 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_gdbserver/server.c b/coregrind/m_gdbserver/server.c
index d530330..5e79fd0 100644
--- a/coregrind/m_gdbserver/server.c
+++ b/coregrind/m_gdbserver/server.c
@@ -799,9 +799,14 @@
    // After a fork, gdbserver_init can be called again.
    // We do not have to re-malloc the buffers in such a case.
    if (own_buf == NULL)
-      own_buf = malloc (PBUFSIZ);
+      own_buf = malloc (PBUFSIZ+POVERHSIZ);
    if (mem_buf == NULL)
-      mem_buf = malloc (PBUFSIZ);
+      mem_buf = malloc (PBUFSIZ+POVERHSIZ);
+   // Note: normally, we should only malloc PBUFSIZ. However,
+   // GDB has a bug, and in some cases, sends e.g. 'm' packets
+   // asking for slightly more than the PacketSize given at
+   // connection initialisation. So, we bypass the GDB bug
+   // by allocating slightly more.
 }
 
 void gdbserver_terminate (void)