- struct gdb_exception exception = exception_none;
- volatile int val = 0;
- struct ui_out *saved_uiout;
-
- /* Save and override the global ``struct ui_out'' builder. */
- saved_uiout = current_uiout;
- current_uiout = func_uiout;
-
- TRY
- {
- val = (*func) (current_uiout, func_args);
- }
- CATCH (ex, RETURN_MASK_ALL)
- {
- exception = ex;
- }
- END_CATCH
-
- /* Restore the global builder. */
- current_uiout = saved_uiout;
-
- if (exception.reason < 0 && (mask & RETURN_MASK (exception.reason)) == 0)
- {
- /* The caller didn't request that the event be caught.
- Rethrow. */
- throw_exception (exception);
- }
-
- exception_print (gdb_stderr, exception);
- gdb_assert (val >= 0);
- gdb_assert (exception.reason <= 0);
- if (exception.reason < 0)
- {
- /* If caller wants a copy of the low-level error message, make
- one. This is used in the case of a silent error whereby the
- caller may optionally want to issue the message. */
- if (gdberrmsg != NULL)
- {
- if (exception.message != NULL)
- *gdberrmsg = xstrdup (exception.message);
- else
- *gdberrmsg = NULL;
- }
- return exception.reason;
- }
- return val;
-}
-
-/* This function is superseded by catch_exceptions(). */
-
-int
-catch_errors (catch_errors_ftype *func, void *func_args, char *errstring,
- return_mask mask)
-{
- struct gdb_exception exception = exception_none;
- volatile int val = 0;
- struct ui_out *saved_uiout;
-
- /* Save the global ``struct ui_out'' builder. */
- saved_uiout = current_uiout;
-
- TRY
- {
- val = func (func_args);
- }
- CATCH (ex, RETURN_MASK_ALL)
- {
- exception = ex;
- }
- END_CATCH
-
- /* Restore the global builder. */
- current_uiout = saved_uiout;
-
- if (exception.reason < 0 && (mask & RETURN_MASK (exception.reason)) == 0)
- {
- /* The caller didn't request that the event be caught.
- Rethrow. */
- throw_exception (exception);
- }