aboutsummaryrefslogtreecommitdiff
path: root/gdb/common/common-exceptions.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/common/common-exceptions.h')
-rw-r--r--gdb/common/common-exceptions.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
index c494de2..6bf7e40 100644
--- a/gdb/common/common-exceptions.h
+++ b/gdb/common/common-exceptions.h
@@ -21,6 +21,7 @@
#define COMMON_EXCEPTIONS_H
#include <setjmp.h>
+#include <new>
/* Reasons for calling throw_exceptions(). NOTE: all reason values
must be less than zero. enum value 0 is reserved for internal use
@@ -283,6 +284,25 @@ struct gdb_exception_RETURN_MASK_QUIT : public gdb_exception_RETURN_MASK_ALL
#endif /* GDB_XCPT_TRY || GDB_XCPT_RAW_TRY */
+/* 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_RETURN_MASK_QUIT,
+ public std::bad_alloc
+{
+ explicit gdb_quit_bad_alloc (gdb_exception ex)
+ : std::bad_alloc ()
+ {
+ gdb_exception *self = this;
+
+ *self = ex;
+ }
+};
+
/* *INDENT-ON* */
/* Throw an exception (as described by "struct gdb_exception"). When