* remote-fileio.c (remote_fileio_func_read): Limit console
authorDaniel Jacobowitz <drow@false.org>
Thu, 12 Nov 2009 21:01:00 +0000 (21:01 +0000)
committerDaniel Jacobowitz <drow@false.org>
Thu, 12 Nov 2009 21:01:00 +0000 (21:01 +0000)
reads to 16K.

gdb/ChangeLog
gdb/remote-fileio.c

index 424383d308a0136ac329934b9c993a41888aed0f..275955c5cae9197d14c5a2976ad872d9682e8e4b 100644 (file)
@@ -1,3 +1,8 @@
+2009-11-12  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * remote-fileio.c (remote_fileio_func_read): Limit console
+       reads to 16K.
+
 2009-11-12  Daniel Jacobowitz  <dan@codesourcery.com>
            Paul Brook  <paul@codesourcery.com>
 
index 1683e996818724d040730f4cbf5228a0e4fb730d..31ee2443cbfa3a5ad6422c21d9005a414b8fe574 100644 (file)
@@ -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)
                {
This page took 0.032349 seconds and 4 git commands to generate.