aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/seh_init.c
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2012-07-16 14:51:41 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2012-07-16 14:51:41 +0200
commite187fa72fb4806da5b93af1d346446b9fc7f0993 (patch)
tree519b73a3579b0657a1ff1d6be8e64614831db7cd /gcc/ada/seh_init.c
parent59a6c9d56580c806c493a50c8902fd2177074399 (diff)
downloadgcc-e187fa72fb4806da5b93af1d346446b9fc7f0993.zip
gcc-e187fa72fb4806da5b93af1d346446b9fc7f0993.tar.gz
gcc-e187fa72fb4806da5b93af1d346446b9fc7f0993.tar.bz2
[multiple changes]
2012-07-16 Robert Dewar <dewar@adacore.com> * freeze.adb, g-debpoo.adb, exp_ch3.adb: Minor reformatting. 2012-07-16 Thomas Quinot <quinot@adacore.com> * s-oscons-tmplt.c: Add definitions of E2BIG and EILSEQ. 2012-07-16 Tristan Gingold <gingold@adacore.com> * a-exexpr.adb (Propagate_Continue): New function replacing Raise_Current_Excep. (Allocate_Occurrence): New function. (Propagate_Exception): Add Excep parameter, remove call to Call_Chain. * a-exexpr-gcc.adb (GNAT_GCC_Exception): Occurrence component is now aliased. (To_GCC_Exception): Convert from Address. (Allocate_Occurrence): Allocate an Unwind exception occurrence. (Setup_Current_Excep): Fill the machine occurrence in case of foreign exception. (Propagate_Exception): Add Excep parameter, remove call to Call_Chain. * a-except.adb (Set_Exception_C_Msg, Set_Exception_Msg): add Excep parameter. (Raise_Exception, Raise_Exception_Always, Raise_Exception_No_Defer): Adjust calls to the above procedures. (Raise_From_Signal_Handler, Raise_With_Location_And_Msg) (Rcheck_PE_Finalize_Raised_Exception): Likewise. * a-except-2005.adb (Set_Exception_C_Msg, Set_Exception_Msg): add Excep parameter. (Propagate_Exception): Likewise. (Allocate_Occurrence): New function. (Raise_Current_Excep): Removed. (Complete_Occurrence): New function to save the call chain. (Complete_And_Propagate_Occurrence): New procedure. (Create_Occurrence_From_Signal_Handler): New function to build an occurrence without propagating it. (Create_Machine_Occurrence_From_Signal_Handler): Likewise, but return the machine occurrence. (Raise_From_Signal_Handler): Use Create_Occurrence_From_Signal_Handler. (Raise_Exception, Raise_Exception_Always, Raise_Exception_No_Defer): Adjust calls to the above procedures. Allocate the occurrence at the beginning. (Raise_With_Location_And_Msg, Raise_With_Msg) (Rcheck_PE_Finalize_Raised_Exceptionm Reraise): Likewise. (Reraise_Occurrence): Use Reraise_Occurrence_Always. (Reraise_Occurrence_Always): Use Reraise_Occurrence_No_Defer. (Reraise_Occurrence_No_Defer): Preserve machine occurrence. (Save_Occurrence): Do not save machine occurrence. * a-except-2005.ads (Exception_Occurrence): Add Machine_Occurrence component. (Null_Occurrence): Consider it. * a-exexda.adb (Set_Exception_C_Msg, Set_Exception_Msg): add Excep parameter. 2012-07-16 Tristan Gingold <gingold@adacore.com> * seh_init.c (__gnat_map_SEH): New function extracted from __gnat_SEH_error_handler. * raise-gcc.c: __gnat_personality_seh0: Directly transforms Windows system exception into GCC one when possible, in order to save stack room (particularly useful when Storage_Error will be propagated). From-SVN: r189530
Diffstat (limited to 'gcc/ada/seh_init.c')
-rw-r--r--gcc/ada/seh_init.c119
1 files changed, 61 insertions, 58 deletions
diff --git a/gcc/ada/seh_init.c b/gcc/ada/seh_init.c
index 84c5d3b..2f7fee4 100644
--- a/gcc/ada/seh_init.c
+++ b/gcc/ada/seh_init.c
@@ -68,20 +68,21 @@ extern void Raise_From_Signal_Handler (struct Exception_Data *, const char *);
#include <windows.h>
#include <excpt.h>
+/* Prototypes. */
extern void _global_unwind2 (void *);
EXCEPTION_DISPOSITION __gnat_SEH_error_handler
(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
-EXCEPTION_DISPOSITION
-__gnat_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord,
- void *EstablisherFrame,
- struct _CONTEXT* ContextRecord ATTRIBUTE_UNUSED,
- void *DispatcherContext ATTRIBUTE_UNUSED)
-{
- struct Exception_Data *exception;
- const char *msg;
+struct Exception_Data *
+__gnat_map_SEH (EXCEPTION_RECORD* ExceptionRecord, const char **msg);
+/* Convert an SEH exception to an Ada one. Return the exception ID
+ and set MSG with the corresponding message. */
+
+struct Exception_Data *
+__gnat_map_SEH (EXCEPTION_RECORD* ExceptionRecord, const char **msg)
+{
switch (ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
@@ -92,93 +93,95 @@ __gnat_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord,
|| IsBadCodePtr
((void *)(ExceptionRecord->ExceptionInformation[1] + 4096)))
{
- exception = &program_error;
- msg = "EXCEPTION_ACCESS_VIOLATION";
+ *msg = "EXCEPTION_ACCESS_VIOLATION";
+ return &program_error;
}
else
{
/* otherwise it is a stack overflow */
- exception = &storage_error;
- msg = "stack overflow or erroneous memory access";
+ *msg = "stack overflow or erroneous memory access";
+ return &storage_error;
}
- break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
- exception = &constraint_error;
- msg = "EXCEPTION_ARRAY_BOUNDS_EXCEEDED";
- break;
+ *msg = "EXCEPTION_ARRAY_BOUNDS_EXCEEDED";
+ return &constraint_error;
case EXCEPTION_DATATYPE_MISALIGNMENT:
- exception = &constraint_error;
- msg = "EXCEPTION_DATATYPE_MISALIGNMENT";
- break;
+ *msg = "EXCEPTION_DATATYPE_MISALIGNMENT";
+ return &constraint_error;
case EXCEPTION_FLT_DENORMAL_OPERAND:
- exception = &constraint_error;
- msg = "EXCEPTION_FLT_DENORMAL_OPERAND";
- break;
+ *msg = "EXCEPTION_FLT_DENORMAL_OPERAND";
+ return &constraint_error;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
- exception = &constraint_error;
- msg = "EXCEPTION_FLT_DENORMAL_OPERAND";
- break;
+ *msg = "EXCEPTION_FLT_DENORMAL_OPERAND";
+ return &constraint_error;
case EXCEPTION_FLT_INVALID_OPERATION:
- exception = &constraint_error;
- msg = "EXCEPTION_FLT_INVALID_OPERATION";
- break;
+ *msg = "EXCEPTION_FLT_INVALID_OPERATION";
+ return &constraint_error;
case EXCEPTION_FLT_OVERFLOW:
- exception = &constraint_error;
- msg = "EXCEPTION_FLT_OVERFLOW";
- break;
+ *msg = "EXCEPTION_FLT_OVERFLOW";
+ return &constraint_error;
case EXCEPTION_FLT_STACK_CHECK:
- exception = &program_error;
- msg = "EXCEPTION_FLT_STACK_CHECK";
- break;
+ *msg = "EXCEPTION_FLT_STACK_CHECK";
+ return &program_error;
case EXCEPTION_FLT_UNDERFLOW:
- exception = &constraint_error;
- msg = "EXCEPTION_FLT_UNDERFLOW";
- break;
+ *msg = "EXCEPTION_FLT_UNDERFLOW";
+ return &constraint_error;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
- exception = &constraint_error;
- msg = "EXCEPTION_INT_DIVIDE_BY_ZERO";
- break;
+ *msg = "EXCEPTION_INT_DIVIDE_BY_ZERO";
+ return &constraint_error;
case EXCEPTION_INT_OVERFLOW:
- exception = &constraint_error;
- msg = "EXCEPTION_INT_OVERFLOW";
- break;
+ *msg = "EXCEPTION_INT_OVERFLOW";
+ return &constraint_error;
case EXCEPTION_INVALID_DISPOSITION:
- exception = &program_error;
- msg = "EXCEPTION_INVALID_DISPOSITION";
- break;
+ *msg = "EXCEPTION_INVALID_DISPOSITION";
+ return &program_error;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
- exception = &program_error;
- msg = "EXCEPTION_NONCONTINUABLE_EXCEPTION";
- break;
+ *msg = "EXCEPTION_NONCONTINUABLE_EXCEPTION";
+ return &program_error;
case EXCEPTION_PRIV_INSTRUCTION:
- exception = &program_error;
- msg = "EXCEPTION_PRIV_INSTRUCTION";
- break;
+ *msg = "EXCEPTION_PRIV_INSTRUCTION";
+ return &program_error;
case EXCEPTION_SINGLE_STEP:
- exception = &program_error;
- msg = "EXCEPTION_SINGLE_STEP";
- break;
+ *msg = "EXCEPTION_SINGLE_STEP";
+ return &program_error;
case EXCEPTION_STACK_OVERFLOW:
- exception = &storage_error;
- msg = "EXCEPTION_STACK_OVERFLOW";
- break;
+ *msg = "EXCEPTION_STACK_OVERFLOW";
+ return &storage_error;
default:
+ *msg = NULL;
+ return NULL;
+ }
+}
+
+EXCEPTION_DISPOSITION
+__gnat_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord,
+ void *EstablisherFrame,
+ struct _CONTEXT* ContextRecord ATTRIBUTE_UNUSED,
+ void *DispatcherContext ATTRIBUTE_UNUSED)
+{
+ struct Exception_Data *exception;
+ const char *msg;
+
+ exception = __gnat_map_SEH (ExceptionRecord, &msg);
+
+ if (exception == NULL)
+ {
#if defined (_WIN64) && defined (__SEH__)
/* On Windows x64, do not transform other exception as they could
be caught by user (when SEH is used to propagate exceptions). */