Introduce event_location_up
[deliverable/binutils-gdb.git] / gdb / exceptions.c
index 8ba86fc62fd51c538d2c08179073bed5c5f27d5d..f9a80a0b3fabff4faf5078c2d0eeb1385964bdf0 100644 (file)
@@ -1,6 +1,6 @@
 /* Exception (throw catch) mechanism, for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2016 Free Software Foundation, Inc.
+   Copyright (C) 1986-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "ui-out.h"
 #include "serial.h"
 #include "gdbthread.h"
-
-void
-prepare_to_throw_exception (void)
-{
-  clear_quit_flag ();
-  immediate_quit = 0;
-}
+#include "top.h"
 
 static void
 print_flush (void)
 {
+  struct ui *ui = current_ui;
   struct serial *gdb_stdout_serial;
+  struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
 
   if (deprecated_error_begin_hook)
     deprecated_error_begin_hook ();
 
   if (target_supports_terminal_ours ())
-    target_terminal_ours ();
+    {
+      make_cleanup_restore_target_terminal ();
+      target_terminal_ours_for_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
@@ -59,7 +58,7 @@ print_flush (void)
   gdb_flush (gdb_stderr);
 
   /* 3.  The system-level buffer.  */
-  gdb_stdout_serial = serial_fdopen (1);
+  gdb_stdout_serial = serial_fdopen (fileno (ui->outstream));
   if (gdb_stdout_serial)
     {
       serial_drain_output (gdb_stdout_serial);
@@ -67,6 +66,8 @@ print_flush (void)
     }
 
   annotate_error_begin ();
+
+  do_cleanups (old_chain);
 }
 
 static void
@@ -143,12 +144,7 @@ exception_fprintf (struct ui_file *file, struct gdb_exception e,
    returned by catch_exceptions().  It is an internal_error() for
    FUNC() to return a negative value.
 
-   See exceptions.h for further usage details.
-
-   Must not be called with immediate_quit in effect (bad things might
-   happen, say we got a signal in the middle of a memcpy to quit_return).
-   This is an OK restriction; with very few exceptions immediate_quit can
-   be replaced by judicious use of QUIT.  */
+   See exceptions.h for further usage details.  */
 
 /* MAYBE: cagney/1999-11-05: catch_errors() in conjunction with
    error() et al. could maintain a set of flags that indicate the
@@ -225,8 +221,8 @@ catch_exceptions_with_msg (struct ui_out *func_uiout,
 /* This function is superseded by catch_exceptions().  */
 
 int
-catch_errors (catch_errors_ftype *func, void *func_args, char *errstring,
-             return_mask mask)
+catch_errors (catch_errors_ftype *func, void *func_args,
+             const char *errstring, return_mask mask)
 {
   struct gdb_exception exception = exception_none;
   volatile int val = 0;
@@ -260,3 +256,21 @@ catch_errors (catch_errors_ftype *func, void *func_args, char *errstring,
     return 0;
   return val;
 }
+
+/* See exceptions.h.  */
+
+int
+exception_print_same (struct gdb_exception e1, struct gdb_exception e2)
+{
+  const char *msg1 = e1.message;
+  const char *msg2 = e2.message;
+
+  if (msg1 == NULL)
+    msg1 = "";
+  if (msg2 == NULL)
+    msg2 = "";
+
+  return (e1.reason == e2.reason
+         && e1.error == e2.error
+         && strcmp (msg1, msg2) == 0);
+}
This page took 0.053953 seconds and 4 git commands to generate.