{
if (exception.reason == RETURN_QUIT)
throw gdb_exception_quit (std::move (exception));
+ else if (exception.reason == RETURN_FORCED_QUIT)
+ throw gdb_exception_forced_quit (std::move (exception));
else if (exception.reason == RETURN_ERROR)
throw gdb_exception_error (std::move (exception));
else
{
if (reason == RETURN_QUIT)
throw gdb_exception_quit (fmt, ap);
+ else if (reason == RETURN_FORCED_QUIT)
+ throw gdb_exception_forced_quit (fmt, ap);
else if (reason == RETURN_ERROR)
throw gdb_exception_error (error, fmt, ap);
else
throw_vquit (fmt, args);
va_end (args);
}
+
+void
+throw_forced_quit (const char *fmt, ...)
+{
+ va_list args;
+
+ va_start (args, fmt);
+ throw_it (RETURN_FORCED_QUIT, GDB_NO_ERROR, fmt, args);
+ va_end (args);
+}
enum return_reason
{
+ /* SIGTERM sent to GDB. */
+ RETURN_FORCED_QUIT = -3,
/* User interrupt. */
RETURN_QUIT = -2,
/* Any other error. */
typedef enum
{
+ RETURN_MASK_FORCED_QUIT = RETURN_MASK (RETURN_FORCED_QUIT),
RETURN_MASK_QUIT = RETURN_MASK (RETURN_QUIT),
RETURN_MASK_ERROR = RETURN_MASK (RETURN_ERROR),
- RETURN_MASK_ALL = (RETURN_MASK_QUIT | RETURN_MASK_ERROR)
+ RETURN_MASK_ALL = (RETURN_MASK_FORCED_QUIT | RETURN_MASK_QUIT | RETURN_MASK_ERROR)
} return_mask;
/* Describe all exceptions. */
}
};
+struct gdb_exception_forced_quit : public gdb_exception
+{
+ gdb_exception_forced_quit (const char *fmt, va_list ap)
+ ATTRIBUTE_PRINTF (2, 0)
+ : gdb_exception (RETURN_FORCED_QUIT, GDB_NO_ERROR, fmt, ap)
+ {
+ }
+
+ explicit gdb_exception_forced_quit (gdb_exception &&ex) noexcept
+ : gdb_exception (std::move (ex))
+ {
+ gdb_assert (ex.reason == RETURN_FORCED_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
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
extern void throw_quit (const char *fmt, ...)
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+extern void throw_forced_quit (const char *fmt, ...)
+ ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
#endif /* COMMON_COMMON_EXCEPTIONS_H */