aboutsummaryrefslogtreecommitdiff
path: root/gdb/common/common-exceptions.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-11-17 15:17:46 +0000
committerPedro Alves <palves@redhat.com>2015-11-17 15:23:15 +0000
commiteec461d0a8e7ae14c7fe8f0196ab8d0e30285d83 (patch)
tree5daba190a7a9e2e54b413e69ffefdb18cd7f315d /gdb/common/common-exceptions.c
parent91ee7171d0886731900ab0238ce3795241d877a4 (diff)
downloadgdb-eec461d0a8e7ae14c7fe8f0196ab8d0e30285d83.zip
gdb-eec461d0a8e7ae14c7fe8f0196ab8d0e30285d83.tar.gz
gdb-eec461d0a8e7ae14c7fe8f0196ab8d0e30285d83.tar.bz2
[C++] Always use setjmp/longjmp for exceptions
We currently throw exceptions from signal handlers (e.g., for Quit/ctrl-c). But throwing C++ exceptions from signal handlers is undefined. (That doesn't restore signal masks, like siglongjmp does, and, because asynchronous signals can arrive at any instruction, we'd have to build _everything_ with -fasync-unwind-tables to make it reliable.) It happens to work on x86_64 GNU/Linux at least, but it's likely broken on other ports. Until we stop throwing from signal handlers, use setjmp/longjmp based exceptions in C++ mode as well. gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * common/common-exceptions.h (GDB_XCPT_SJMP, GDB_XCPT_TRY) (GDB_XCPT_RAW_TRY, GDB_XCPT): Define. Replace __cplusplus checks with GDB_XCPT checks throughout. * common/common-exceptions.c: Replace __cplusplus checks with GDB_XCPT checks throughout.
Diffstat (limited to 'gdb/common/common-exceptions.c')
-rw-r--r--gdb/common/common-exceptions.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gdb/common/common-exceptions.c b/gdb/common/common-exceptions.c
index ce476a2..231bab5 100644
--- a/gdb/common/common-exceptions.c
+++ b/gdb/common/common-exceptions.c
@@ -22,7 +22,7 @@
const struct gdb_exception exception_none = { (enum return_reason) 0, GDB_NO_ERROR, NULL };
-#ifndef __cplusplus
+#if GDB_XCPT == GDB_XCPT_SJMP
/* Possible catcher states. */
enum catcher_state {
@@ -213,7 +213,7 @@ exceptions_state_mc_action_iter_1 (void)
return exceptions_state_mc (CATCH_ITER_1);
}
-#else /* !__cplusplus */
+#else /* !GDB_XCPT_SJMP */
/* How many nested TRY blocks we have. See exception_messages and
throw_it. */
@@ -261,7 +261,7 @@ gdb_exception_sliced_copy (struct gdb_exception *to, const struct gdb_exception
*to = *from;
}
-#endif /* !__cplusplus */
+#endif /* !GDB_XCPT_SJMP */
/* Return EXCEPTION to the nearest containing catch_errors(). */
@@ -272,7 +272,7 @@ throw_exception (struct gdb_exception exception)
do_cleanups (all_cleanups ());
-#ifndef __cplusplus
+#if GDB_XCPT == GDB_XCPT_SJMP
/* 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. */
@@ -320,7 +320,7 @@ throw_it (enum return_reason reason, enum errors error, const char *fmt,
{
struct gdb_exception e;
char *new_message;
-#ifndef __cplusplus
+#if GDB_XCPT == GDB_XCPT_SJMP
int depth = catcher_list_size ();
#else
int depth = try_scope_depth;