-/* 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,
- char *errstring,
- return_mask mask)
-{
- return catch_exceptions_with_msg (uiout, func, func_args, errstring,
- 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, 0);
- for (SIGSETJMP ((*catch));
- catcher_state_machine (CATCH_ITER);)
- (*func) (uiout, func_args);
- return exception;
-}
-
-int
-catch_exceptions_with_msg (struct ui_out *uiout,
- catch_exceptions_ftype *func,
- void *func_args,
- char *errstring,
- char **gdberrmsg,
- return_mask mask)
-{
- volatile struct exception exception;
- volatile int val = 0;
- SIGJMP_BUF *catch = catcher_init (uiout, errstring, &exception, mask, 1);
- for (SIGSETJMP ((*catch)); catcher_state_machine (CATCH_ITER);)
- val = (*func) (uiout, func_args);
- 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;