* config/m68k/monitor.mt (TDEPFILE): Add remote-es.o.
[deliverable/binutils-gdb.git] / gdb / utils.c
index 3ee6986124955d39e9730ab3a4798b59dee5be72..08c2353c598b5f3342a165578fa17ce0f576cc6d 100644 (file)
@@ -402,6 +402,9 @@ print_sys_errmsg (string, errcode)
   strcat (combined, ": ");
   strcat (combined, err);
 
+  /* We want anything which was printed on stdout to come out first, before
+     this message.  */
+  gdb_flush (gdb_stdout);
   fprintf_unfiltered (gdb_stderr, "%s.\n", combined);
 }
 
@@ -413,10 +416,21 @@ quit ()
   serial_t gdb_stdout_serial = serial_fdopen (1);
 
   target_terminal_ours ();
-  wrap_here ((char *)0);               /* Force out any pending output */
 
-  SERIAL_FLUSH_OUTPUT (gdb_stdout_serial);
+  /* We want all output to appear now, before we print "Quit".  We
+     have 3 levels of buffering we have to flush (it's possible that
+     some of these should be changed to flush the lower-level ones
+     too):  */
+
+  /* 1.  The _filtered buffer.  */
+  wrap_here ((char *)0);
 
+  /* 2.  The stdio buffer.  */
+  gdb_flush (gdb_stdout);
+  gdb_flush (gdb_stderr);
+
+  /* 3.  The system-level buffer.  */
+  SERIAL_FLUSH_OUTPUT (gdb_stdout_serial);
   SERIAL_UN_FDOPEN (gdb_stdout_serial);
 
   /* Don't use *_filtered; we don't want to prompt the user to continue.  */
@@ -446,16 +460,49 @@ pollquit()
   if (kbhit ())
     {
       int k = getkey ();
-      if (k == 1)
+      if (k == 1) {
        quit_flag = 1;
-      else if (k == 2)
+       quit();
+      }
+      else if (k == 2) {
        immediate_quit = 1;
-      quit ();
+       quit ();
+      }
+      else 
+       {
+         /* We just ignore it */
+         fprintf_unfiltered (gdb_stderr, "CTRL-A to quit, CTRL-B to quit harder\n");
+       }
     }
 }
 
-#endif
 
+#endif
+#ifdef __GO32__
+void notice_quit()
+{
+  if (kbhit ())
+    {
+      int k = getkey ();
+      if (k == 1) {
+       quit_flag = 1;
+      }
+      else if (k == 2)
+       {
+         immediate_quit = 1;
+       }
+      else 
+       {
+         fprintf_unfiltered (gdb_stderr, "CTRL-A to quit, CTRL-B to quit harder\n");
+       }
+    }
+}
+#else
+void notice_quit()
+{
+  /* Done by signals */
+}
+#endif
 /* Control C comes here */
 
 void
@@ -464,10 +511,10 @@ request_quit (signo)
 {
   quit_flag = 1;
 
-#ifdef USG
-  /* Restore the signal handler.  */
+  /* Restore the signal handler.  Harmless with BSD-style signals, needed
+     for System V-style signals.  So just always do it, rather than worrying
+     about USG defines and stuff like that.  */
   signal (signo, request_quit);
-#endif
 
   if (immediate_quit)
     quit ();
@@ -1075,16 +1122,6 @@ gdb_fopen (name, mode)
   return fopen (name, mode);
 }
 
-/* Like fputs but pause after every screenful, and can wrap at points
-   other than the final character of a line.
-   Unlike fputs, fputs_filtered does not return a value.
-   It is OK for LINEBUFFER to be NULL, in which case just don't print
-   anything.
-
-   Note that a longjmp to top level may occur in this routine
-   (since prompt_for_continue may do so) so this routine should not be
-   called when cleanups are not in place.  */
-
 void
 gdb_flush (stream)
      FILE *stream;
@@ -1092,6 +1129,19 @@ gdb_flush (stream)
   fflush (stream);
 }
 
+/* Like fputs but if FILTER is true, pause after every screenful.
+
+   Regardless of FILTER can wrap at points other than the final
+   character of a line.
+
+   Unlike fputs, fputs_maybe_filtered does not return a value.
+   It is OK for LINEBUFFER to be NULL, in which case just don't print
+   anything.
+
+   Note that a longjmp to top level may occur in this routine (only if
+   FILTER is true) (since prompt_for_continue may do so) so this
+   routine should not be called when cleanups are not in place.  */
+
 static void
 fputs_maybe_filtered (linebuffer, stream, filter)
      const char *linebuffer;
@@ -1209,7 +1259,18 @@ fputs_unfiltered (linebuffer, stream)
      const char *linebuffer;
      FILE *stream;
 {
+#if 0
+
+  /* This gets the wrap_buffer buffering wrong when called from
+     gdb_readline (GDB was sometimes failing to print the prompt
+     before reading input).  Even at other times, it seems kind of
+     misguided, especially now that printf_unfiltered doesn't use
+     printf_maybe_filtered.  */
+
   fputs_maybe_filtered (linebuffer, stream, 0);
+#else
+  fputs (linebuffer, stream);
+#endif
 }
 
 void
@@ -1301,7 +1362,7 @@ vfprintf_unfiltered (stream, format, args)
      char *format;
      va_list args;
 {
-  vfprintf_maybe_filtered (stream, format, args, 0);
+  vfprintf (stream, format, args);
 }
 
 void
@@ -1317,7 +1378,7 @@ vprintf_unfiltered (format, args)
      char *format;
      va_list args;
 {
-  vfprintf_maybe_filtered (gdb_stdout, format, args, 0);
+  vfprintf (gdb_stdout, format, args);
 }
 
 /* VARARGS */
This page took 0.025438 seconds and 4 git commands to generate.