aboutsummaryrefslogtreecommitdiff
path: root/gdb/defs.h
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2001-09-07 21:33:08 +0000
committerAndrew Cagney <cagney@redhat.com>2001-09-07 21:33:08 +0000
commitf9c696d277e3c63524ddd995edac66fa6770395b (patch)
treea39041c72dfa9863d7f747f08c7450927ea98fd6 /gdb/defs.h
parenta2e2dd80557cd2493d1d6c454b86dd010da3d0d4 (diff)
downloadgdb-f9c696d277e3c63524ddd995edac66fa6770395b.zip
gdb-f9c696d277e3c63524ddd995edac66fa6770395b.tar.gz
gdb-f9c696d277e3c63524ddd995edac66fa6770395b.tar.bz2
* defs.h (enum return_reason): Renumber so that all values are
negative. (RETURN_MASK): Negate reason. (catch_exception_ftype): Declare. (catch_exceptions): Declare. * top.c (catcher): New function, based on catch_errors. Add in parameter func_uiout and out parameters func_val, func_caught and func_cleanup. Change type of func to catch_exceptions_ftype. Save/restore uiout. (struct catch_errors_args): Define. (do_catch_errors): New function. (catch_errors): Rewrite, use do_catch_errors and catcher. (catch_exceptions): New function, use catcher.
Diffstat (limited to 'gdb/defs.h')
-rw-r--r--gdb/defs.h43
1 files changed, 37 insertions, 6 deletions
diff --git a/gdb/defs.h b/gdb/defs.h
index 7d717c7..a0d6d03 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -1084,21 +1084,23 @@ extern NORETURN void internal_error (const char *file, int line,
extern NORETURN void nomem (long) ATTR_NORETURN;
-/* Reasons for calling return_to_top_level. Note: enum value 0 is
- reserved for internal use as the return value from an initial
- setjmp(). */
+/* Reasons for calling return_to_top_level. NOTE: all reason values
+ must be less than zero. enum value 0 is reserved for internal use
+ as the return value from an initial setjmp(). The function
+ catch_exceptions() reserves values >= 0 as legal results from its
+ wrapped function. */
enum return_reason
{
/* User interrupt. */
- RETURN_QUIT = 1,
+ RETURN_QUIT = -2,
/* Any other error. */
RETURN_ERROR
};
#define ALL_CLEANUPS ((struct cleanup *)0)
-#define RETURN_MASK(reason) (1 << (int)(reason))
+#define RETURN_MASK(reason) (1 << (int)(-reason))
#define RETURN_MASK_QUIT RETURN_MASK (RETURN_QUIT)
#define RETURN_MASK_ERROR RETURN_MASK (RETURN_ERROR)
#define RETURN_MASK_ALL (RETURN_MASK_QUIT | RETURN_MASK_ERROR)
@@ -1106,12 +1108,41 @@ typedef int return_mask;
extern NORETURN void return_to_top_level (enum return_reason) ATTR_NORETURN;
+/* Call FUNC(UIOUT, FUNC_ARGS) but wrapped within an exception
+ handler. If an exception (enum return_reason) is thrown using
+ return_to_top_level() than all cleanups installed since
+ catch_exceptions() was entered are invoked, the (-ve) exception
+ value is then returned by catch_exceptions. If FUNC() returns
+ normally (with a postive or zero return value) then that value is
+ returned by catch_exceptions(). It is an internal_error() for
+ FUNC() to return a negative value.
+
+ For the period of the FUNC() call: UIOUT is installed as the output
+ builder; ERRSTRING is installed as the error/quit message; and a
+ new cleanup_chain is established. The old values are restored
+ before catch_exceptions() returns.
+
+ FIXME; cagney/2001-08-13: The need to override the global UIOUT
+ builder variable should just go away.
+
+ This function superseeds catch_errors().
+
+ This function uses SETJMP() and LONGJUMP(). */
+
+struct ui_out;
+typedef int (catch_exceptions_ftype) (struct ui_out *ui_out, void *args);
+extern int catch_exceptions (struct ui_out *uiout,
+ catch_exceptions_ftype *func, void *func_args,
+ char *errstring, return_mask mask);
+
/* If CATCH_ERRORS_FTYPE throws an error, catch_errors() returns zero
otherwize the result from CATCH_ERRORS_FTYPE is returned. It is
probably useful for CATCH_ERRORS_FTYPE to always return a non-zero
value. It's unfortunate that, catch_errors() does not return an
indication of the exact exception that it caught - quit_flag might
- help. */
+ help.
+
+ This function is superseeded by catch_exceptions(). */
typedef int (catch_errors_ftype) (PTR);
extern int catch_errors (catch_errors_ftype *, PTR, char *, return_mask);