-void
-print_any_exception (struct ui_file *file, const char *prefix,
- struct 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);
- }
-}
-
-NORETURN static void
-throw_it (enum return_reason reason, enum errors error, const char *fmt,
- va_list ap) ATTR_NORETURN;
-NORETURN static void
-throw_it (enum return_reason reason, enum errors error, const char *fmt,
- va_list ap)
-{
- struct exception e;
-
- /* Save the message. */
- xfree (last_message);
- last_message = xstrvprintf (fmt, ap);
-
- /* Create the exception. */
- e.reason = reason;
- e.error = error;
- e.message = last_message;
-
- /* Throw the exception. */
- throw_exception (e);
-}
-
-NORETURN void
-throw_verror (enum errors error, const char *fmt, va_list ap)
-{
- throw_it (RETURN_ERROR, error, fmt, ap);
-}
-
-NORETURN void
-throw_vfatal (const char *fmt, va_list ap)
-{
- throw_it (RETURN_QUIT, NO_ERROR, fmt, ap);
-}
-
-NORETURN void
-throw_error (enum errors error, const char *fmt, ...)
-{
- va_list args;
- va_start (args, fmt);
- throw_it (RETURN_ERROR, error, fmt, args);
- va_end (args);
-}
-
-/* Call FUNC() with args FUNC_UIOUT and FUNC_ARGS, catching any
- errors. Set FUNC_CAUGHT to an ``enum return_reason'' if the
- function is aborted (using throw_exception() or zero if the
- function returns normally. Set FUNC_VAL to the value returned by
- the function or 0 if the function was aborted.
-
- 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.
-
- MASK specifies what to catch; it is normally set to
- RETURN_MASK_ALL, if for no other reason than that the code which
- calls catch_errors might not be set up to deal with a quit which
- isn't caught. But if the code can deal with it, it generally
- should be RETURN_MASK_ERROR, unless for some reason it is more
- useful to abort only the portion of the operation inside the
- catch_errors. Note that quit should return to the command line
- fairly quickly, even if some further processing is being done. */
-
-/* MAYBE: cagney/1999-11-05: catch_errors() in conjunction with
- error() et.al. could maintain a set of flags that indicate the the
- current state of each of the longjmp buffers. This would give the
- longjmp code the chance to detect a longjmp botch (before it gets
- to longjmperror()). Prior to 1999-11-05 this wasn't possible as
- code also randomly used a SET_TOP_LEVEL macro that directly
- initialize the longjmp buffers. */
-
-/* MAYBE: cagney/1999-11-05: Should the catch_errors and cleanups code
- be consolidated into a single file instead of being distributed
- between utils.c and top.c? */
-
-int
-catch_exceptions (struct ui_out *uiout,
- catch_exceptions_ftype *func,
- void *func_args,
- return_mask mask)
-{
- return catch_exceptions_with_msg (uiout, func, func_args, NULL, mask);
-}
-
-struct exception
-catch_exception (struct ui_out *uiout,
- catch_exception_ftype *func,
- void *func_args,
- return_mask mask)
-{
- volatile struct exception exception;
- SIGJMP_BUF *catch;
- catch = catcher_init (uiout, NULL, &exception, mask);
- for (SIGSETJMP ((*catch));
- catcher_state_machine (CATCH_ITER);)
- (*func) (uiout, func_args);
- return exception;
-}