|
From: <sv...@va...> - 2013-07-25 22:37:14
|
philippe 2013-07-25 23:37:02 +0100 (Thu, 25 Jul 2013)
New Revision: 13472
Log:
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.
Modified files:
trunk/coregrind/m_gdbserver/remote-utils.c
trunk/coregrind/m_gdbserver/server.c
Modified: trunk/coregrind/m_gdbserver/remote-utils.c (+2 -1)
===================================================================
--- trunk/coregrind/m_gdbserver/remote-utils.c 2013-07-25 21:40:17 +01:00 (rev 13471)
+++ trunk/coregrind/m_gdbserver/remote-utils.c 2013-07-25 23:37:02 +01:00 (rev 13472)
@@ -695,7 +695,8 @@
char *p;
int cc;
- buf2 = malloc (PBUFSIZ);
+ buf2 = malloc (PBUFSIZ+POVERHSIZ);
+ // should malloc PBUFSIZ, but bypass GDB bug (see gdbserver_init in server.c)
/* Copy the packet into buffer BUF2, encapsulating it
and giving it a checksum. */
Modified: trunk/coregrind/m_gdbserver/server.c (+7 -2)
===================================================================
--- trunk/coregrind/m_gdbserver/server.c 2013-07-25 21:40:17 +01:00 (rev 13471)
+++ trunk/coregrind/m_gdbserver/server.c 2013-07-25 23:37:02 +01:00 (rev 13472)
@@ -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)
|