aboutsummaryrefslogtreecommitdiff
path: root/gdb/exceptions.h
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2005-01-13 00:12:50 +0000
committerAndrew Cagney <cagney@redhat.com>2005-01-13 00:12:50 +0000
commit2a78bfb53ccd6d78e97293502ae0b41ce4d120a5 (patch)
tree2a191c4e4251c9bbe69b06958c6b83360ffe2e9f /gdb/exceptions.h
parentcd0960cf4e3505cf968879816e0c2c6b522a146e (diff)
downloadgdb-2a78bfb53ccd6d78e97293502ae0b41ce4d120a5.zip
gdb-2a78bfb53ccd6d78e97293502ae0b41ce4d120a5.tar.gz
gdb-2a78bfb53ccd6d78e97293502ae0b41ce4d120a5.tar.bz2
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (throw_reason): Rename throw_exception. (enum errors, struct exception): Define. (catch_exception_ftype): Define. (catch_exception, throw_exception): Declare. * exceptions.c (throw_exception): Rewrite. (throw_reason): New function. (struct catcher, catcher_state_machine): Replace "reason" with "exception", delete "gdberrmsg". (catch_exception): New function. (catcher_init): Replace "gdberrmsg" parameter with "exception". (catch_errors, catch_exceptions_with_msg): Re-implement passing exception to catcher_init. * utils.c (error_silent, error_stream_1): Use throw_reason. (internal_verror, quit): Ditto. * breakpoint.c (insert_catchpoint, break_command_1): Ditto. * remote-fileio.c (remote_fileio_ctrl_c_signal_handler): Ditto. * remote.c (remote_open_1, interrupt_query): Ditto.
Diffstat (limited to 'gdb/exceptions.h')
-rw-r--r--gdb/exceptions.h38
1 files changed, 32 insertions, 6 deletions
diff --git a/gdb/exceptions.h b/gdb/exceptions.h
index 5ebde66..b5d8fd5 100644
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -24,7 +24,7 @@
#ifndef EXCEPTIONS_H
#define EXCEPTIONS_H
-/* Reasons for calling throw_exception(). NOTE: all reason values
+/* Reasons for calling throw_exceptions(). 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
@@ -44,17 +44,38 @@ enum return_reason
#define RETURN_MASK_ALL (RETURN_MASK_QUIT | RETURN_MASK_ERROR)
typedef int return_mask;
-/* Throw an exception of type RETURN_REASON. Will execute a LONG JUMP
- to the inner most containing exception handler established using
- catch_exceptions() (or the legacy catch_errors()).
+/* Describe all exceptions. */
+
+enum errors {
+ NO_ERROR,
+ /* Any generic error, the corresponding text is in
+ exception.message. */
+ GENERIC_ERROR,
+ /* Add more errors here. */
+ NR_ERRORS
+};
+
+struct exception
+{
+ enum return_reason reason;
+ enum errors error;
+ char *message;
+};
+
+/* Throw an exception (as described by "struct exception"). Will
+ execute a LONG JUMP to the inner most containing exception handler
+ established using catch_exceptions() (or similar).
Code normally throws an exception using error() et.al. For various
reaons, GDB also contains code that throws an exception directly.
For instance, the remote*.c targets contain CNTRL-C signal handlers
that propogate the QUIT event up the exception chain. ``This could
- be a good thing or a dangerous thing.'' -- the Existential Wombat. */
+ be a good thing or a dangerous thing.'' -- the Existential
+ Wombat. */
+
+extern NORETURN void throw_exception (struct exception exception) ATTR_NORETURN;
+extern NORETURN void throw_reason (enum return_reason reason) ATTR_NORETURN;
-extern NORETURN void throw_exception (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
@@ -87,11 +108,16 @@ 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);
+typedef void (catch_exception_ftype) (struct ui_out *ui_out, void *args);
extern int catch_exceptions_with_msg (struct ui_out *uiout,
catch_exceptions_ftype *func,
void *func_args,
char *errstring, char **gdberrmsg,
return_mask mask);
+extern struct exception catch_exception (struct ui_out *uiout,
+ catch_exception_ftype *func,
+ void *func_args,
+ 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