/* Exception (throw catch) mechanism, for GDB, the GNU debugger.
- Copyright (C) 1986, 1988-2012 Free Software Foundation, Inc.
+ Copyright (C) 1986-2014 Free Software Foundation, Inc.
This file is part of GDB.
#include "inferior.h"
#include "annotate.h"
#include "ui-out.h"
-#include "gdb_assert.h"
-#include "gdb_string.h"
#include "serial.h"
#include "gdbthread.h"
exceptions_state_mc_init (volatile struct gdb_exception *exception,
return_mask mask)
{
- struct catcher *new_catcher = XZALLOC (struct catcher);
+ struct catcher *new_catcher = XCNEW (struct catcher);
/* Start with no exception, save it's address. */
exception->reason = 0;
EXCEPTIONS_SIGLONGJMP (current_catcher->buf, exception.reason);
}
-void
-deprecated_throw_reason (enum return_reason reason)
-{
- struct gdb_exception exception;
-
- memset (&exception, 0, sizeof exception);
-
- exception.reason = reason;
- switch (reason)
- {
- case RETURN_QUIT:
- break;
- case RETURN_ERROR:
- exception.error = GENERIC_ERROR;
- break;
- default:
- internal_error (__FILE__, __LINE__, _("bad switch"));
- }
-
- throw_exception (exception);
-}
-
static void
print_flush (void)
{
if (deprecated_error_begin_hook)
deprecated_error_begin_hook ();
- target_terminal_ours ();
+
+ if (target_supports_terminal_ours ())
+ target_terminal_ours ();
/* We want all output to appear now, before we print the error. We
have 3 levels of buffering we have to flush (it's possible that
too): */
/* 1. The _filtered buffer. */
- wrap_here ("");
+ if (filtered_printing_initialized ())
+ wrap_here ("");
/* 2. The stdio buffer. */
gdb_flush (gdb_stdout);
}
}
-static void
-print_any_exception (struct ui_file *file, const char *prefix,
- struct gdb_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);
- }
-}
-
/* A stack of exception messages.
This is needed to handle nested calls to throw_it: we don't want to
xfree space for a message before it's used.
}
void
-throw_vfatal (const char *fmt, va_list ap)
+throw_vquit (const char *fmt, va_list ap)
{
throw_it (RETURN_QUIT, GDB_NO_ERROR, fmt, ap);
}
va_list args;
va_start (args, fmt);
- throw_it (RETURN_ERROR, error, fmt, args);
+ throw_verror (error, fmt, args);
+ va_end (args);
+}
+
+void
+throw_quit (const char *fmt, ...)
+{
+ va_list args;
+
+ va_start (args, fmt);
+ throw_vquit (fmt, args);
va_end (args);
}
throw_exception (exception);
}
- print_any_exception (gdb_stderr, NULL, exception);
+ exception_print (gdb_stderr, exception);
gdb_assert (val >= 0);
gdb_assert (exception.reason <= 0);
if (exception.reason < 0)
throw_exception (exception);
}
- print_any_exception (gdb_stderr, errstring, exception);
+ exception_fprintf (gdb_stderr, exception, "%s", errstring);
if (exception.reason != 0)
return 0;
return val;
}
-
-int
-catch_command_errors (catch_command_errors_ftype * command,
- char *arg, int from_tty, return_mask mask)
-{
- volatile struct gdb_exception e;
-
- TRY_CATCH (e, mask)
- {
- command (arg, from_tty);
- }
- print_any_exception (gdb_stderr, NULL, e);
- if (e.reason < 0)
- return 0;
- return 1;
-}