* cgen-types.h (SETDI): Delete, unused.
[deliverable/binutils-gdb.git] / gdb / remote-fileio.c
index 1683e996818724d040730f4cbf5228a0e4fb730d..d7215fe605b00e9e2d41c063d59e901bd8290599 100644 (file)
@@ -1,6 +1,6 @@
 /* Remote File-I/O communications
 
-   Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009
+   Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -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)
                {
@@ -1405,28 +1416,44 @@ remote_fileio_reset (void)
     }
 }
 
+/* Handle a file I/O request. BUF points to the packet containing the
+   request. CTRLC_PENDING_P should be nonzero if the target has not
+   acknowledged the Ctrl-C sent asynchronously earlier.  */
+
 void
-remote_fileio_request (char *buf)
+remote_fileio_request (char *buf, int ctrlc_pending_p)
 {
   int ex;
 
   remote_fileio_sig_init ();
 
-  remote_fio_ctrl_c_flag = 0;
-  remote_fio_no_longjmp = 0;
-
-  ex = catch_exceptions (uiout, do_remote_fileio_request, (void *)buf,
-                        RETURN_MASK_ALL);
-  switch (ex)
+  if (ctrlc_pending_p)
     {
-      case RETURN_ERROR:
-       remote_fileio_reply (-1, FILEIO_ENOSYS);
-        break;
-      case RETURN_QUIT:
-        remote_fileio_reply (-1, FILEIO_EINTR);
-       break;
-      default:
-        break;
+      /* If the target hasn't responded to the Ctrl-C sent
+        asynchronously earlier, take this opportunity to send the
+        Ctrl-C synchronously.  */
+      remote_fio_ctrl_c_flag = 1;
+      remote_fio_no_longjmp = 0;
+      remote_fileio_reply (-1, FILEIO_EINTR);
+    }
+  else
+    {
+      remote_fio_ctrl_c_flag = 0;
+      remote_fio_no_longjmp = 0;
+
+      ex = catch_exceptions (uiout, do_remote_fileio_request, (void *)buf,
+                            RETURN_MASK_ALL);
+      switch (ex)
+       {
+       case RETURN_ERROR:
+         remote_fileio_reply (-1, FILEIO_ENOSYS);
+         break;
+       case RETURN_QUIT:
+         remote_fileio_reply (-1, FILEIO_EINTR);
+         break;
+       default:
+         break;
+       }
     }
 
   remote_fileio_sig_exit ();
This page took 0.024353 seconds and 4 git commands to generate.