+struct gdb_exception_quit : public gdb_exception
+{
+ gdb_exception_quit (const char *fmt, va_list ap)
+ ATTRIBUTE_PRINTF (2, 0)
+ : gdb_exception (RETURN_QUIT, GDB_NO_ERROR, fmt, ap)
+ {
+ }
+
+ explicit gdb_exception_quit (const gdb_exception &ex) noexcept
+ : gdb_exception (ex)
+ {
+ gdb_assert (ex.reason == RETURN_QUIT);
+ }
+};
+
+/* An exception type that inherits from both std::bad_alloc and a gdb
+ exception. This is necessary because operator new can only throw
+ std::bad_alloc, and OTOH, we want exceptions thrown due to memory
+ allocation error to be caught by all the CATCH/RETURN_MASK_ALL
+ spread around the codebase. */
+
+struct gdb_quit_bad_alloc
+ : public gdb_exception_quit,
+ public std::bad_alloc
+{
+ explicit gdb_quit_bad_alloc (const gdb_exception &ex) noexcept
+ : gdb_exception_quit (ex),
+ std::bad_alloc ()
+ {
+ }
+};
+
+/* *INDENT-ON* */
+
+/* Throw an exception (as described by "struct gdb_exception"),
+ landing in the inner most containing exception handler established
+ using TRY/CATCH. */
+extern void throw_exception (const gdb_exception &exception)
+ ATTRIBUTE_NORETURN;
+
+/* Throw an exception by executing a LONG JUMP to the inner most
+ containing exception handler established using TRY_SJLJ. Necessary
+ in some cases where we need to throw GDB exceptions across
+ third-party library code (e.g., readline). */
+extern void throw_exception_sjlj (const struct gdb_exception &exception)