]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2005-01-14 Andrew Cagney <cagney@gnu.org>
authorAndrew Cagney <cagney@redhat.com>
Sat, 15 Jan 2005 04:31:10 +0000 (04:31 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sat, 15 Jan 2005 04:31:10 +0000 (04:31 +0000)
* exceptions.c (exception_fprintf, exception_print): Move printing
of \n from here ...
(print_exception): ... to here.
(print_flush): New function.
(exception_print, exception_fprintf): Replace duplicated flush and
wrap code with call to print_flush.
(print_and_throw): Simplify, by using xstrvprintf, print_flush,
and print_exception.
(do_write): Delete.

gdb/ChangeLog
gdb/exceptions.c

index 4dae334336668f02ee4371290f9e05ad04f13931..ad6bdf71756e3a1bf3b7397c750af724bfd45296 100644 (file)
@@ -1,5 +1,15 @@
 2005-01-14  Andrew Cagney  <cagney@gnu.org>
 
+       * exceptions.c (exception_fprintf, exception_print): Move printing
+       of \n from here ...
+       (print_exception): ... to here.
+       (print_flush): New function.
+       (exception_print, exception_fprintf): Replace duplicated flush and
+       wrap code with call to print_flush.
+       (print_and_throw): Simplify, by using xstrvprintf, print_flush,
+       and print_exception.
+       (do_write): Delete.
+
        * remote-sds.c (interrupt_query): Call throw_reason instead of
        throw_exception.
        * remote-mips.c (mips_error, mips_kill): Ditto
index 7d4ce500e7f0c5388914ba63f1d5c8fbb3f1b1c8..f9a93ef3d23a30c2e6d931ccecc5fa2c10a3fba4 100644 (file)
@@ -296,12 +296,16 @@ throw_reason (enum return_reason reason)
 }
 
 static void
-do_write (void *data, const char *buffer, long length_buffer)
+print_flush (void)
 {
-  ui_file_write (data, buffer, length_buffer);
+  if (deprecated_error_begin_hook)
+    deprecated_error_begin_hook ();
+  target_terminal_ours ();
+  wrap_here ("");              /* Force out any buffered output */
+  gdb_flush (gdb_stdout);
+  annotate_error_begin ();
 }
 
-
 static void
 print_exception (struct ui_file *file, struct exception e)
 {
@@ -320,6 +324,7 @@ print_exception (struct ui_file *file, struct exception e)
          ui_file_write (file, start, end - start);
        }
     }                                      
+  fprintf_filtered (file, "\n");
 }
 
 void
@@ -327,12 +332,8 @@ exception_print (struct ui_file *file, struct exception e)
 {
   if (e.reason < 0 && e.message != NULL)
     {
-      target_terminal_ours ();
-      wrap_here ("");          /* Force out any buffered output */
-      gdb_flush (file);
-      annotate_error_begin ();
+      print_flush ();
       print_exception (file, e);
-      fprintf_filtered (file, "\n");
     }
 }
 
@@ -343,10 +344,8 @@ exception_fprintf (struct ui_file *file, struct exception e,
   if (e.reason < 0 && e.message != NULL)
     {
       va_list args;
-      target_terminal_ours ();
-      wrap_here ("");          /* Force out any buffered output */
-      gdb_flush (file);
-      annotate_error_begin ();
+
+      print_flush ();
 
       /* Print the prefix.  */
       va_start (args, prefix);
@@ -354,7 +353,6 @@ exception_fprintf (struct ui_file *file, struct exception e,
       va_end (args);
 
       print_exception (file, e);
-      fprintf_filtered (file, "\n");
     }
 }
 
@@ -366,47 +364,29 @@ NORETURN static void
 print_and_throw (enum return_reason reason, enum errors error,
                 const char *prefix, const char *fmt, va_list ap)
 {
-  /* FIXME: cagney/2005-01-13: While xstrvprintf is simpler it alters
-     GDB's output.  Instead of the message being printed
-     line-at-a-time the message comes out all at once.  The problem is
-     that the MI testsuite is checks for line-at-a-time messages and
-     changing this behavior means updating the testsuite.  */
-
   struct exception e;
-  struct ui_file *tmp_stream;
-  long len;
-
-  /* Convert the message into a print stream.  */
-  tmp_stream = mem_fileopen ();
-  make_cleanup_ui_file_delete (tmp_stream);
-  vfprintf_unfiltered (tmp_stream, fmt, ap);
 
   /* Save the message.  */
   xfree (last_message);
-  last_message = ui_file_xstrdup (tmp_stream, &len);
+  last_message = xstrvprintf (fmt, ap);
+
+  /* Create the exception.  */
+  e.reason = reason;
+  e.error = error;
+  e.message = last_message;
 
   /* Print the mesage to stderr, but only if the catcher isn't going
      to handle/print it locally.  */
   if (current_catcher->print_message)
     {
-      if (deprecated_error_begin_hook)
-       deprecated_error_begin_hook ();
-
       /* Write the message plus any pre_print to gdb_stderr.  */
-      target_terminal_ours ();
-      wrap_here ("");          /* Force out any buffered output */
-      gdb_flush (gdb_stdout);
-      annotate_error_begin ();
+      print_flush ();
       if (error_pre_print)
        fputs_filtered (error_pre_print, gdb_stderr);
-      ui_file_put (tmp_stream, do_write, gdb_stderr);
-      fprintf_filtered (gdb_stderr, "\n");
+      print_exception (gdb_stderr, e);
     }
 
   /* Throw the exception.  */
-  e.reason = reason;
-  e.error = error;
-  e.message = last_message;
   throw_exception (e);
 }