Make warning usable earlier
[deliverable/binutils-gdb.git] / gdb / exceptions.c
index b7cf9a2cd8fba6b8921b72881f753ce43a154f33..063d2b15664fee1b2d61a324317297df80448a5c 100644 (file)
@@ -1,6 +1,6 @@
 /* Exception (throw catch) mechanism, for GDB, the GNU debugger.
 
-   Copyright (C) 1986, 1988-2012 Free Software Foundation, Inc.
+   Copyright (C) 1986-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -24,8 +24,6 @@
 #include "inferior.h"
 #include "annotate.h"
 #include "ui-out.h"
-#include "gdb_assert.h"
-#include "gdb_string.h"
 #include "serial.h"
 #include "gdbthread.h"
 
@@ -86,7 +84,7 @@ EXCEPTIONS_SIGJMP_BUF *
 exceptions_state_mc_init (volatile struct gdb_exception *exception,
                          return_mask mask)
 {
-  struct catcher *new_catcher = XZALLOC (struct catcher);
+  struct catcher *new_catcher = XCNEW (struct catcher);
 
   /* Start with no exception, save it's address.  */
   exception->reason = 0;
@@ -234,28 +232,6 @@ throw_exception (struct gdb_exception exception)
   EXCEPTIONS_SIGLONGJMP (current_catcher->buf, exception.reason);
 }
 
-void
-deprecated_throw_reason (enum return_reason reason)
-{
-  struct gdb_exception exception;
-
-  memset (&exception, 0, sizeof exception);
-
-  exception.reason = reason;
-  switch (reason)
-    {
-    case RETURN_QUIT:
-      break;
-    case RETURN_ERROR:
-      exception.error = GENERIC_ERROR;
-      break;
-    default:
-      internal_error (__FILE__, __LINE__, _("bad switch"));
-    }
-  
-  throw_exception (exception);
-}
-
 static void
 print_flush (void)
 {
@@ -263,7 +239,9 @@ print_flush (void)
 
   if (deprecated_error_begin_hook)
     deprecated_error_begin_hook ();
-  target_terminal_ours ();
+
+  if (target_supports_terminal_ours ())
+    target_terminal_ours ();
 
   /* 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
@@ -271,7 +249,8 @@ print_flush (void)
      too):  */
 
   /* 1.  The _filtered buffer.  */
-  wrap_here ("");
+  if (filtered_printing_initialized ())
+    wrap_here ("");
 
   /* 2.  The stdio buffer.  */
   gdb_flush (gdb_stdout);
@@ -353,24 +332,6 @@ exception_fprintf (struct ui_file *file, struct gdb_exception e,
     }
 }
 
-static void
-print_any_exception (struct ui_file *file, const char *prefix,
-                    struct gdb_exception e)
-{
-  if (e.reason < 0 && e.message != NULL)
-    {
-      target_terminal_ours ();
-      wrap_here ("");          /* Force out any buffered output.  */
-      gdb_flush (gdb_stdout);
-      annotate_error_begin ();
-
-      /* Print the prefix.  */
-      if (prefix != NULL && prefix[0] != '\0')
-       fputs_filtered (prefix, file);
-      print_exception (file, e);
-    }
-}
-
 /* A stack of exception messages.
    This is needed to handle nested calls to throw_it: we don't want to
    xfree space for a message before it's used.
@@ -430,7 +391,7 @@ throw_verror (enum errors error, const char *fmt, va_list ap)
 }
 
 void
-throw_vfatal (const char *fmt, va_list ap)
+throw_vquit (const char *fmt, va_list ap)
 {
   throw_it (RETURN_QUIT, GDB_NO_ERROR, fmt, ap);
 }
@@ -441,7 +402,17 @@ throw_error (enum errors error, const char *fmt, ...)
   va_list args;
 
   va_start (args, fmt);
-  throw_it (RETURN_ERROR, error, fmt, args);
+  throw_verror (error, fmt, args);
+  va_end (args);
+}
+
+void
+throw_quit (const char *fmt, ...)
+{
+  va_list args;
+
+  va_start (args, fmt);
+  throw_vquit (fmt, args);
   va_end (args);
 }
 
@@ -508,7 +479,7 @@ catch_exceptions_with_msg (struct ui_out *func_uiout,
       throw_exception (exception);
     }
 
-  print_any_exception (gdb_stderr, NULL, exception);
+  exception_print (gdb_stderr, exception);
   gdb_assert (val >= 0);
   gdb_assert (exception.reason <= 0);
   if (exception.reason < 0)
@@ -556,24 +527,8 @@ catch_errors (catch_errors_ftype *func, void *func_args, char *errstring,
       throw_exception (exception);
     }
 
-  print_any_exception (gdb_stderr, errstring, exception);
+  exception_fprintf (gdb_stderr, exception, "%s", errstring);
   if (exception.reason != 0)
     return 0;
   return val;
 }
-
-int
-catch_command_errors (catch_command_errors_ftype * command,
-                     char *arg, int from_tty, return_mask mask)
-{
-  volatile struct gdb_exception e;
-
-  TRY_CATCH (e, mask)
-    {
-      command (arg, from_tty);
-    }
-  print_any_exception (gdb_stderr, NULL, e);
-  if (e.reason < 0)
-    return 0;
-  return 1;
-}
This page took 0.032424 seconds and 4 git commands to generate.