diff options
author | Andrew Cagney <cagney@redhat.com> | 2005-01-15 05:16:15 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2005-01-15 05:16:15 +0000 |
commit | 071a02259826aab8523c58fc4ebfc382160ea3b9 (patch) | |
tree | 9fd8efb9bb1f0d1dda86636497994c22a8681507 /gdb/exceptions.c | |
parent | bdd12fdeb36597be7c54e8b44dce51b787e4b572 (diff) | |
download | gdb-071a02259826aab8523c58fc4ebfc382160ea3b9.tar.gz |
2005-01-14 Andrew Cagney <cagney@gnu.org>
* exceptions.c (print_and_throw): Delete, replaced by throw_it.
(throw_reason): Leave the exception's message field blank.
(throw_it): New function, create the exception and throw it.
(throw_verror, throw_vfatal, throw_error): Call throw_it.
(print_any_exception): New function.
(catch_errors, catch_exceptions_with_msg): Call
print_any_exception.
(throw_exception): Move code calling annotate_error and
annotate_quit from here ...
(print_exception): ... to here.
Diffstat (limited to 'gdb/exceptions.c')
-rw-r--r-- | gdb/exceptions.c | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/gdb/exceptions.c b/gdb/exceptions.c index f9a93ef3d23..0700812547d 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -249,20 +249,6 @@ throw_exception (struct exception exception) if (sync_execution) do_exec_error_cleanups (ALL_CLEANUPS); - if (annotation_level > 1) - switch (exception.reason) - { - case RETURN_QUIT: - annotate_quit (); - break; - case RETURN_ERROR: - /* Assume that these are all errors. */ - annotate_error (); - break; - default: - internal_error (__FILE__, __LINE__, "Bad switch."); - } - /* Jump to the containing catch_errors() call, communicating REASON to that call via setjmp's return value. Note that REASON can't be zero, by definition in defs.h. */ @@ -286,7 +272,6 @@ throw_reason (enum return_reason reason) break; case RETURN_ERROR: exception.error = GENERIC_ERROR; - exception.message = last_message; break; default: internal_error (__FILE__, __LINE__, "bad switch"); @@ -325,6 +310,20 @@ print_exception (struct ui_file *file, struct exception e) } } fprintf_filtered (file, "\n"); + + /* Now append the annotation. */ + switch (e.reason) + { + case RETURN_QUIT: + annotate_quit (); + break; + case RETURN_ERROR: + /* Assume that these are all errors. */ + annotate_error (); + break; + default: + internal_error (__FILE__, __LINE__, _("Bad switch.")); + } } void @@ -356,13 +355,30 @@ exception_fprintf (struct ui_file *file, struct exception e, } } +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 -print_and_throw (enum return_reason reason, enum errors error, - const char *prefix, const char *fmt, - va_list ap) ATTR_NORETURN; +throw_it (enum return_reason reason, enum errors error, const char *prefix, + const char *fmt, va_list ap) ATTR_NORETURN; NORETURN static void -print_and_throw (enum return_reason reason, enum errors error, - const char *prefix, const char *fmt, va_list ap) +throw_it (enum return_reason reason, enum errors error, const char *prefix, + const char *fmt, va_list ap) { struct exception e; @@ -375,17 +391,6 @@ print_and_throw (enum return_reason reason, enum errors error, e.error = error; e.message = last_message; - /* Print the mesage to stderr, but only if the catcher isn't going - to handle/print it locally. */ - if (current_catcher->print_message) - { - /* Write the message plus any pre_print to gdb_stderr. */ - print_flush (); - if (error_pre_print) - fputs_filtered (error_pre_print, gdb_stderr); - print_exception (gdb_stderr, e); - } - /* Throw the exception. */ throw_exception (e); } @@ -393,13 +398,13 @@ print_and_throw (enum return_reason reason, enum errors error, NORETURN void throw_verror (enum errors error, const char *fmt, va_list ap) { - print_and_throw (RETURN_ERROR, error, error_pre_print, fmt, ap); + throw_it (RETURN_ERROR, error, error_pre_print, fmt, ap); } NORETURN void throw_vfatal (const char *fmt, va_list ap) { - print_and_throw (RETURN_QUIT, NO_ERROR, quit_pre_print, fmt, ap); + throw_it (RETURN_QUIT, NO_ERROR, quit_pre_print, fmt, ap); } NORETURN void @@ -407,7 +412,7 @@ throw_error (enum errors error, const char *fmt, ...) { va_list args; va_start (args, fmt); - print_and_throw (RETURN_ERROR, error, error_pre_print, fmt, args); + throw_it (RETURN_ERROR, error, error_pre_print, fmt, args); va_end (args); } @@ -479,6 +484,7 @@ catch_exceptions_with_msg (struct ui_out *uiout, SIGJMP_BUF *catch = catcher_init (uiout, NULL, &exception, mask, 1); for (SIGSETJMP ((*catch)); catcher_state_machine (CATCH_ITER);) val = (*func) (uiout, func_args); + print_any_exception (gdb_stderr, NULL, exception); gdb_assert (val >= 0); gdb_assert (exception.reason <= 0); if (exception.reason < 0) @@ -510,6 +516,7 @@ catch_errors (catch_errors_ftype *func, void *func_args, char *errstring, also catch "return". */ for (SIGSETJMP ((*catch)); catcher_state_machine (CATCH_ITER);) val = func (func_args); + print_any_exception (gdb_stderr, errstring, exception); if (exception.reason != 0) return 0; return val; |