This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] Simplify, quit() by calling fatal()


FYI,

This simplifies quit() so that it uses the same print path as error et.al.

committed,
Andrew
2005-01-19  Andrew Cagney  <cagney@gnu.org>

	* utils.c (quit): Simplify, call fatal.
	* exceptions.c: Include "serial.h"
	(print_flush): Mimic flush code found in utils.c:quit.
	* Makefile.in: Update dependencies.
	
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.692
diff -p -u -r1.692 Makefile.in
--- Makefile.in	16 Jan 2005 21:53:34 -0000	1.692
+++ Makefile.in	19 Jan 2005 22:49:05 -0000
@@ -1898,7 +1898,7 @@ event-top.o: event-top.c $(defs_h) $(top
 	$(exceptions_h) $(gdbcmd_h) $(readline_h) $(readline_history_h)
 exceptions.o: exceptions.c $(defs_h) $(exceptions_h) $(breakpoint_h) \
 	$(target_h) $(inferior_h) $(annotate_h) $(ui_out_h) $(gdb_assert_h) \
-	$(gdb_string_h)
+	$(gdb_string_h) $(serial_h)
 exec.o: exec.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) $(gdbcmd_h) \
 	$(language_h) $(symfile_h) $(objfiles_h) $(completer_h) $(value_h) \
 	$(exec_h) $(readline_h) $(gdb_string_h) $(gdbcore_h) $(gdb_stat_h) \
Index: exceptions.c
===================================================================
RCS file: /cvs/src/src/gdb/exceptions.c,v
retrieving revision 1.16
diff -p -u -r1.16 exceptions.c
--- exceptions.c	19 Jan 2005 21:15:43 -0000	1.16
+++ exceptions.c	19 Jan 2005 22:49:05 -0000
@@ -31,6 +31,7 @@
 #include "ui-out.h"
 #include "gdb_assert.h"
 #include "gdb_string.h"
+#include "serial.h"
 
 const struct exception exception_none = { 0, NO_ERROR, NULL };
 
@@ -262,11 +263,29 @@ deprecated_throw_reason (enum return_rea
 static void
 print_flush (void)
 {
+  struct serial *gdb_stdout_serial;
+
   if (deprecated_error_begin_hook)
     deprecated_error_begin_hook ();
   target_terminal_ours ();
-  wrap_here ("");		/* Force out any buffered output */
+
+  /* We want all output to appear now, before we print the error.  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 ("");
+
+  /* 2.  The stdio buffer.  */
   gdb_flush (gdb_stdout);
+  gdb_flush (gdb_stderr);
+
+  /* 3.  The system-level buffer.  */
+  gdb_stdout_serial = serial_fdopen (1);
+  serial_drain_output (gdb_stdout_serial);
+  serial_un_fdopen (gdb_stdout_serial);
+
   annotate_error_begin ();
 }
 
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.146
diff -p -u -r1.146 utils.c
--- utils.c	19 Jan 2005 21:15:44 -0000	1.146
+++ utils.c	19 Jan 2005 22:49:06 -0000
@@ -880,47 +880,19 @@ print_sys_errmsg (const char *string, in
 void
 quit (void)
 {
-  struct serial *gdb_stdout_serial = serial_fdopen (1);
-
-  target_terminal_ours ();
-
-  /* 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_drain_output (gdb_stdout_serial);
-  serial_un_fdopen (gdb_stdout_serial);
-
-  annotate_error_begin ();
-
-  /* Don't use *_filtered; we don't want to prompt the user to continue.  */
-  if (quit_pre_print)
-    fputs_unfiltered (quit_pre_print, gdb_stderr);
-
 #ifdef __MSDOS__
   /* No steenking SIGINT will ever be coming our way when the
      program is resumed.  Don't lie.  */
-  fprintf_unfiltered (gdb_stderr, "Quit\n");
+  fatal ("Quit");
 #else
   if (job_control
       /* If there is no terminal switching for this target, then we can't
          possibly get screwed by the lack of job control.  */
       || current_target.to_terminal_ours == NULL)
-    fprintf_unfiltered (gdb_stderr, "Quit\n");
+    fatal ("Quit");
   else
-    fprintf_unfiltered (gdb_stderr,
-			"Quit (expect signal SIGINT when the program is resumed)\n");
+    fatal ("Quit (expect signal SIGINT when the program is resumed)");
 #endif
-  deprecated_throw_reason (RETURN_QUIT);
 }
 
 /* Control C comes here */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]