From bb9c3d36f1a4279fec29a3dd54356fd4438f524b Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Thu, 8 May 2008 19:46:56 +0000 Subject: [PATCH] * regcache.c (registers_length): Remove. (set_register_cache): Verify that PBUFSIZ is large enough to hold a full register packet. * regcache.h (registers_length): Remove prototype. * server.h (PBUFSIZ): Define to 16384. --- gdb/gdbserver/ChangeLog | 8 ++++++++ gdb/gdbserver/regcache.c | 10 ++++------ gdb/gdbserver/regcache.h | 4 ---- gdb/gdbserver/server.h | 9 ++++----- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index da5402ce8bf..ab5396443b5 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,11 @@ +2008-05-08 Ulrich Weigand + + * regcache.c (registers_length): Remove. + (set_register_cache): Verify that PBUFSIZ is large enough to hold a + full register packet. + * regcache.h (registers_length): Remove prototype. + * server.h (PBUFSIZ): Define to 16384. + 2008-05-03 Ulrich Weigand * configure.srv (powerpc*-*-linux*): Set srv_regobj to diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c index a42d95ba9f0..a324d43df65 100644 --- a/gdb/gdbserver/regcache.c +++ b/gdb/gdbserver/regcache.c @@ -86,12 +86,6 @@ regcache_invalidate () for_each_inferior (&all_threads, regcache_invalidate_one); } -int -registers_length (void) -{ - return 2 * register_bytes; -} - void * new_register_cache (void) { @@ -147,6 +141,10 @@ set_register_cache (struct reg *regs, int n) register_bytes = offset / 8; + /* Make sure PBUFSIZ is large enough to hold a full register packet. */ + if (2 * register_bytes + 32 > PBUFSIZ) + fatal ("Register packet size exceeds PBUFSIZ."); + /* Re-allocate all pre-existing register caches. */ for_each_inferior (&all_threads, realloc_register_cache); } diff --git a/gdb/gdbserver/regcache.h b/gdb/gdbserver/regcache.h index 641f928f98c..48782ffb84b 100644 --- a/gdb/gdbserver/regcache.h +++ b/gdb/gdbserver/regcache.h @@ -43,10 +43,6 @@ void registers_to_string (char *buf); void registers_from_string (char *buf); -/* Return the size in bytes of a string-encoded register packet. */ - -int registers_length (void); - /* Return a pointer to the description of register ``n''. */ struct reg *find_register_by_number (int n); diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index 92387666edb..9d6c7512d75 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -225,11 +225,10 @@ void warning (const char *string,...) ATTR_FORMAT (printf, 1, 2); is chosen to fill up a packet (the headers account for the 32). */ #define MAXBUFBYTES(N) (((N)-32)/2) -/* Buffer sizes for transferring memory, registers, etc. Round up PBUFSIZ to - hold all the registers, at least. */ -#define PBUFSIZ ((registers_length () + 32 > 2000) \ - ? (registers_length () + 32) \ - : 2000) +/* Buffer sizes for transferring memory, registers, etc. Set to a constant + value to accomodate multiple register formats. This value must be at least + as large as the largest register set supported by gdbserver. */ +#define PBUFSIZ 16384 /* Version information, from version.c. */ extern const char version[]; -- 2.30.2