Normalize TRY_CATCH exception handling block
[binutils-gdb.git] / gdb / exceptions.c
index 0ca4c5653d8af7dfcdd048cdef5ae0bc7504a6d9..64a653afa02c431dc1a326fc6dcb98315e5f2982 100644 (file)
@@ -174,7 +174,8 @@ catch_exceptions_with_msg (struct ui_out *func_uiout,
                           char **gdberrmsg,
                           return_mask mask)
 {
-  volatile struct gdb_exception exception;
+  volatile struct gdb_exception ex;
+  struct gdb_exception exception = exception_none;
   volatile int val = 0;
   struct ui_out *saved_uiout;
 
@@ -182,10 +183,14 @@ catch_exceptions_with_msg (struct ui_out *func_uiout,
   saved_uiout = current_uiout;
   current_uiout = func_uiout;
 
-  TRY_CATCH (exception, RETURN_MASK_ALL)
+  TRY_CATCH (ex, RETURN_MASK_ALL)
     {
       val = (*func) (current_uiout, func_args);
     }
+  if (ex.reason < 0)
+    {
+      exception = ex;
+    }
 
   /* Restore the global builder.  */
   current_uiout = saved_uiout;