Prelimit number of bytes to read in "vFile:pread:"
authorGary Benson <gbenson@redhat.com>
Wed, 19 Aug 2015 13:00:50 +0000 (14:00 +0100)
committerGary Benson <gbenson@redhat.com>
Wed, 19 Aug 2015 13:00:50 +0000 (14:00 +0100)
commit5e83dd6fb19ba25a89e321a0eb1373b3d3fc3930
treee302fd18a02f906ad5d15947646005f4574e7ca0
parente7852eab7024220ae5c0cc0e86274b14bd775acf
Prelimit number of bytes to read in "vFile:pread:"

While handling "vFile:pread:" packets, gdbserver would read the
number of bytes requested regardless of whether this would fit
into the reply packet.  gdbserver would then return a packet's
worth of data and discard the remainder.  When accessing large
binaries GDB (via BFD) routinely makes large "vFile:pread:"
requests, resulting in gdbserver allocating large unnecessary
buffers and reading some portions of the file many times over.

This commit causes gdbserver to limit the number of bytes to be
read to a sensible maximum prior to allocating buffers and reading
data.

gdb/gdbserver/ChangeLog:

* hostio.c (handle_pread): Do not attempt to read more data
than hostio_reply_with_data can fit in a packet.
gdb/gdbserver/ChangeLog
gdb/gdbserver/hostio.c