This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Limit remote-fileio console reads to 16K
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Thu, 12 Nov 2009 16:02:24 -0500
- Subject: [commit] Limit remote-fileio console reads to 16K
This patch was previously posted, and agreed to by Eli and Jim, but I
forgot to commit it:
http://sourceware.org/ml/gdb-patches/2006-06/msg00123.html
Now tested on arm-none-eabi and x86_64-linux, and committed.
--
Daniel Jacobowitz
CodeSourcery
2009-11-12 Daniel Jacobowitz <dan@codesourcery.com>
gdb/
* remote-fileio.c (remote_fileio_func_read): Limit console
reads to 16K.
Index: remote-fileio.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-fileio.c,v
retrieving revision 1.30
diff -u -p -r1.30 remote-fileio.c
--- remote-fileio.c 3 Jan 2009 05:57:53 -0000 1.30
+++ remote-fileio.c 12 Nov 2009 20:56:07 -0000
@@ -741,7 +741,7 @@ remote_fileio_func_read (char *buf)
static char *remaining_buf = NULL;
static int remaining_length = 0;
- buffer = (gdb_byte *) xmalloc (32768);
+ buffer = (gdb_byte *) xmalloc (16384);
if (remaining_buf)
{
remote_fio_no_longjmp = 1;
@@ -763,7 +763,18 @@ remote_fileio_func_read (char *buf)
}
else
{
- ret = ui_file_read (gdb_stdtargin, (char *) buffer, 32767);
+ /* Windows (at least XP and Server 2003) has difficulty
+ with large reads from consoles. If a handle is
+ backed by a real console device, overly large reads
+ from the handle will fail and set errno == ENOMEM.
+ On a Windows Server 2003 system where I tested,
+ reading 26608 bytes from the console was OK, but
+ anything above 26609 bytes would fail. The limit has
+ been observed to vary on different systems. So, we
+ limit this read to something smaller than that - by a
+ safe margin, in case the limit depends on system
+ resources or version. */
+ ret = ui_file_read (gdb_stdtargin, (char *) buffer, 16383);
remote_fio_no_longjmp = 1;
if (ret > 0 && (size_t)ret > length)
{