Commit 5f57ad31 by Arnaud Charlet

init.c (__gnat_initialize): Add a new parameter eh which contains the address of…

init.c (__gnat_initialize): Add a new parameter eh which contains the address of the exception registration.

	* init.c (__gnat_initialize): Add a new parameter eh which contains the
	address of the exception registration. The Win32 version of this
	routine calls __gnat_install_SEH_handler() to initialize the SEH
	(Structured Exception Handling) handler.
	(__gnat_error_handler) [Win32]: Removed. Not needed as we use
	SEH (Structured Exception Handling) now.
	(__gnat_install_handler) [Win32]: Nothing to do now as we use SEH.
	(__gnat_initialize for ppc-vxworks): Adjust comments and the
	preprocessor condition protecting the call to the extra eh setup
	subprogram, which is only available for the ppc target.
	(__gnat_clear_exception_count): replaced reference to
	variable taskIdCurrent by call to taskIdSelf(), cleaner.

	* seh_init.c: New file.

	* Make-lang.in: (GNAT_ADA_OBJS): Add seh_init.o.
	(GNATBIND_OBJS): Idem.

	* misc.c (gnat_parse_file): Update call to __gnat_initialize. This
	routine takes a new parameter (a pointer to the exception registration
	for the SEH (Structured Exception Handling) support.

	* raise.h: (__gnat_install_SEH_handler): New prototype.
	Update copyright notice.

	* s-tassta.adb (Task_Wrapper): Declare the exception registration
	record and initialize it by calling __gnat_install_SEH_handler.

From-SVN: r94816
parent 16e845ef
...@@ -146,7 +146,7 @@ GNAT_ADA_OBJS = ada/ada.o ada/a-charac.o ada/a-chlat1.o ada/a-except.o \ ...@@ -146,7 +146,7 @@ GNAT_ADA_OBJS = ada/ada.o ada/a-charac.o ada/a-chlat1.o ada/a-except.o \
ada/stylesw.o ada/validsw.o ada/system.o ada/table.o ada/targparm.o \ ada/stylesw.o ada/validsw.o ada/system.o ada/table.o ada/targparm.o \
ada/tbuild.o ada/tree_gen.o ada/tree_io.o ada/treepr.o ada/treeprs.o \ ada/tbuild.o ada/tree_gen.o ada/tree_io.o ada/treepr.o ada/treeprs.o \
ada/ttypef.o ada/ttypes.o ada/types.o ada/uintp.o ada/uname.o ada/urealp.o \ ada/ttypef.o ada/ttypes.o ada/types.o ada/uintp.o ada/uname.o ada/urealp.o \
ada/usage.o ada/widechar.o ada/s-crtl.o ada/usage.o ada/widechar.o ada/s-crtl.o ada/seh_init.o
# Object files for gnat executables # Object files for gnat executables
GNAT1_ADA_OBJS = $(GNAT_ADA_OBJS) ada/back_end.o ada/gnat1drv.o GNAT1_ADA_OBJS = $(GNAT_ADA_OBJS) ada/back_end.o ada/gnat1drv.o
...@@ -161,6 +161,7 @@ GNATBIND_OBJS = \ ...@@ -161,6 +161,7 @@ GNATBIND_OBJS = \
ada/cstreams.o \ ada/cstreams.o \
ada/final.o \ ada/final.o \
ada/init.o \ ada/init.o \
ada/seh_init.o \
ada/link.o \ ada/link.o \
ada/raise.o \ ada/raise.o \
ada/tracebak.o \ ada/tracebak.o \
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* * * *
* C Implementation File * * C Implementation File *
* * * *
* Copyright (C) 1992-2005 Free Software Foundation, Inc. * * Copyright (C) 1992-2005, Free Software Foundation, Inc. *
* * * *
* GNAT is free software; you can redistribute it and/or modify it under * * GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- * * terms of the GNU General Public License as published by the Free Soft- *
...@@ -403,7 +403,7 @@ __gnat_install_handler (void) ...@@ -403,7 +403,7 @@ __gnat_install_handler (void)
} }
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
} }
...@@ -418,7 +418,7 @@ extern void __gnat_install_handler (void); ...@@ -418,7 +418,7 @@ extern void __gnat_install_handler (void);
/* For RTEMS, each bsp will provide a custom __gnat_install_handler (). */ /* For RTEMS, each bsp will provide a custom __gnat_install_handler (). */
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
__gnat_install_handler (); __gnat_install_handler ();
} }
...@@ -543,7 +543,7 @@ __gnat_install_handler (void) ...@@ -543,7 +543,7 @@ __gnat_install_handler (void)
} }
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
} }
...@@ -657,7 +657,7 @@ __gnat_install_handler (void) ...@@ -657,7 +657,7 @@ __gnat_install_handler (void)
} }
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
} }
...@@ -806,7 +806,7 @@ __gnat_install_handler (void) ...@@ -806,7 +806,7 @@ __gnat_install_handler (void)
} }
void void
__gnat_initialize (void) __gnat_initialize (void *eh ATTRIBUTE_UNUSED)
{ {
} }
...@@ -817,142 +817,27 @@ __gnat_initialize (void) ...@@ -817,142 +817,27 @@ __gnat_initialize (void)
#elif defined (__MINGW32__) #elif defined (__MINGW32__)
#include <windows.h> #include <windows.h>
static LONG WINAPI __gnat_error_handler (PEXCEPTION_POINTERS);
/* __gnat_initialize (mingw32). */
static LONG WINAPI
__gnat_error_handler (PEXCEPTION_POINTERS info)
{
struct Exception_Data *exception;
const char *msg;
switch (info->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
/* If the failing address isn't maximally-aligned or if the page
before the faulting page is not accessible, this is a program error.
*/
if ((info->ExceptionRecord->ExceptionInformation[1] & 3) != 0
|| IsBadCodePtr
((void *)(info->ExceptionRecord->ExceptionInformation[1] + 4096)))
{
exception = &program_error;
msg = "EXCEPTION_ACCESS_VIOLATION";
}
else
{
/* otherwise it is a stack overflow */
exception = &storage_error;
msg = "stack overflow (or erroneous memory access)";
}
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
exception = &constraint_error;
msg = "EXCEPTION_ARRAY_BOUNDS_EXCEEDED";
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
exception = &constraint_error;
msg = "EXCEPTION_DATATYPE_MISALIGNMENT";
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
exception = &constraint_error;
msg = "EXCEPTION_FLT_DENORMAL_OPERAND";
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
exception = &constraint_error;
msg = "EXCEPTION_FLT_DENORMAL_OPERAND";
break;
case EXCEPTION_FLT_INVALID_OPERATION:
exception = &constraint_error;
msg = "EXCEPTION_FLT_INVALID_OPERATION";
break;
case EXCEPTION_FLT_OVERFLOW:
exception = &constraint_error;
msg = "EXCEPTION_FLT_OVERFLOW";
break;
case EXCEPTION_FLT_STACK_CHECK:
exception = &program_error;
msg = "EXCEPTION_FLT_STACK_CHECK";
break;
case EXCEPTION_FLT_UNDERFLOW:
exception = &constraint_error;
msg = "EXCEPTION_FLT_UNDERFLOW";
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
exception = &constraint_error;
msg = "EXCEPTION_INT_DIVIDE_BY_ZERO";
break;
case EXCEPTION_INT_OVERFLOW:
exception = &constraint_error;
msg = "EXCEPTION_INT_OVERFLOW";
break;
case EXCEPTION_INVALID_DISPOSITION:
exception = &program_error;
msg = "EXCEPTION_INVALID_DISPOSITION";
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
exception = &program_error;
msg = "EXCEPTION_NONCONTINUABLE_EXCEPTION";
break;
case EXCEPTION_PRIV_INSTRUCTION:
exception = &program_error;
msg = "EXCEPTION_PRIV_INSTRUCTION";
break;
case EXCEPTION_SINGLE_STEP:
exception = &program_error;
msg = "EXCEPTION_SINGLE_STEP";
break;
case EXCEPTION_STACK_OVERFLOW:
exception = &storage_error;
msg = "EXCEPTION_STACK_OVERFLOW";
break;
default:
exception = &program_error;
msg = "unhandled signal";
}
Raise_From_Signal_Handler (exception, msg);
return 0; /* This is never reached, avoid compiler warning */
}
void void
__gnat_install_handler (void) __gnat_install_handler (void)
{ {
SetUnhandledExceptionFilter (__gnat_error_handler);
__gnat_handler_installed = 1;
} }
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
/* Initialize floating-point coprocessor. This call is needed because /* Initialize floating-point coprocessor. This call is needed because
the MS libraries default to 64-bit precision instead of 80-bit the MS libraries default to 64-bit precision instead of 80-bit
precision, and we require the full precision for proper operation, precision, and we require the full precision for proper operation,
given that we have set Max_Digits etc with this in mind */ given that we have set Max_Digits etc with this in mind */
__gnat_init_float (); __gnat_init_float ();
/* initialize a lock for a process handle list - see a-adaint.c for the /* Initialize a lock for a process handle list - see a-adaint.c for the
implementation of __gnat_portable_no_block_spawn, __gnat_portable_wait */ implementation of __gnat_portable_no_block_spawn, __gnat_portable_wait */
__gnat_plist_init(); __gnat_plist_init();
/* Install the Structured Exception handler. */
if (eh)
__gnat_install_SEH_handler (eh);
} }
/***************************************/ /***************************************/
...@@ -1023,7 +908,7 @@ __gnat_install_handler (void) ...@@ -1023,7 +908,7 @@ __gnat_install_handler (void)
} }
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
__gnat_init_float (); __gnat_init_float ();
} }
...@@ -1035,7 +920,7 @@ __gnat_initialize (void) ...@@ -1035,7 +920,7 @@ __gnat_initialize (void)
#elif defined (__Lynx__) #elif defined (__Lynx__)
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
__gnat_init_float (); __gnat_init_float ();
} }
...@@ -1057,7 +942,7 @@ __gnat_install_handler (void) ...@@ -1057,7 +942,7 @@ __gnat_install_handler (void)
#elif defined (__EMX__) /* OS/2 dependent initialization */ #elif defined (__EMX__) /* OS/2 dependent initialization */
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
} }
...@@ -1224,7 +1109,7 @@ __gnat_install_handler (void) ...@@ -1224,7 +1109,7 @@ __gnat_install_handler (void)
} }
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
} }
...@@ -1332,7 +1217,7 @@ __gnat_install_handler (void) ...@@ -1332,7 +1217,7 @@ __gnat_install_handler (void)
} }
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
} }
...@@ -1564,7 +1449,7 @@ __gnat_install_handler (void) ...@@ -1564,7 +1449,7 @@ __gnat_install_handler (void)
} }
void void
__gnat_initialize(void) __gnat_initialize(void *eh)
{ {
} }
...@@ -1636,7 +1521,7 @@ __gnat_install_handler () ...@@ -1636,7 +1521,7 @@ __gnat_install_handler ()
} }
void void
__gnat_initialize () __gnat_initialize (void *eh)
{ {
__gnat_install_handler (); __gnat_install_handler ();
...@@ -1694,7 +1579,9 @@ void ...@@ -1694,7 +1579,9 @@ void
__gnat_clear_exception_count (void) __gnat_clear_exception_count (void)
{ {
#ifdef VTHREADS #ifdef VTHREADS
taskIdCurrent->vThreads.excCnt = 0; WIND_TCB *currentTask = (WIND_TCB *) taskIdSelf();
currentTask->vThreads.excCnt = 0;
#endif #endif
} }
...@@ -1824,7 +1711,7 @@ __gnat_init_float (void) ...@@ -1824,7 +1711,7 @@ __gnat_init_float (void)
} }
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
__gnat_init_float (); __gnat_init_float ();
...@@ -1832,20 +1719,20 @@ __gnat_initialize (void) ...@@ -1832,20 +1719,20 @@ __gnat_initialize (void)
the frame tables. the frame tables.
For applications loaded as a set of "modules", the crtstuff objects For applications loaded as a set of "modules", the crtstuff objects
linked in (crtbegin/endS) are tailored to provide this service a-la C++ linked in (crtbegin/end) are tailored to provide this service a-la C++
static constructor fashion, typically triggered by the VxWorks loader. constructor fashion, typically triggered by the VxWorks loader. This is
This is achieved by way of a special variable declaration in the crt achieved by way of a special variable declaration in the crt object, the
object, the name of which has been deduced by analyzing the output of the name of which has been deduced by analyzing the output of the "munching"
"munching" step documented for C++. The de-registration call is handled step documented for C++. The de-registration is handled symetrically,
symetrically, a-la C++ destructor fashion and typically triggered by the a-la C++ destructor fashion and typically triggered by the dynamic
dynamic unloader. Note that since the tables shall be registered against unloader. Note that since the tables shall be registered against a
a common datastructure, libgcc should be one of the modules (vs beeing common datastructure, libgcc should be one of the modules (vs beeing
partially linked against all the others at build time) and shall be partially linked against all the others at build time) and shall be
loaded first. loaded first.
For applications linked with the kernel, the scheme above would lead to For applications linked with the kernel, the scheme above would lead to
duplicated symbols because the VxWorks kernel build "munches" by default. duplicated symbols because the VxWorks kernel build "munches" by default.
To prevent those conflicts, we link against crtbegin/end objects that To prevent those conflicts, we link against crtbegin/endS objects that
don't include the special variable and directly call the appropriate don't include the special variable and directly call the appropriate
function here. We'll never unload that, so there is no de-registration to function here. We'll never unload that, so there is no de-registration to
worry about. worry about.
...@@ -1856,15 +1743,15 @@ __gnat_initialize (void) ...@@ -1856,15 +1743,15 @@ __gnat_initialize (void)
We can differentiate by looking at the __module_has_ctors value provided We can differentiate by looking at the __module_has_ctors value provided
by each class of crt objects. As of today, selecting the crt set with the by each class of crt objects. As of today, selecting the crt set with the
static ctors/dtors capabilities (first scheme above) is triggered by ctors/dtors capabilities (first scheme above) is triggered by adding
adding "-static" to the gcc *link* command line options. Without this, "-dynamic" to the gcc *link* command line options. Selecting the other
the other set of crt objects is fetched. set of crt objects is achieved by "-static" instead.
This is a first approach, tightly synchronized with a number of GCC This is a first approach, tightly synchronized with a number of GCC
configuration and crtstuff changes. We need to ensure that those changes configuration and crtstuff changes. We need to ensure that those changes
are there to activate this circuitry. */ are there to activate this circuitry. */
#if DWARF2_UNWIND_INFO && defined (_ARCH_PPC) #if (__GNUC__ >= 3) && (defined (_ARCH_PPC) || defined (__ppc))
{ {
/* The scheme described above is only useful for the actual ZCX case, and /* The scheme described above is only useful for the actual ZCX case, and
we don't want any reference to the crt provided symbols otherwise. We we don't want any reference to the crt provided symbols otherwise. We
...@@ -1947,7 +1834,7 @@ __gnat_install_handler(void) ...@@ -1947,7 +1834,7 @@ __gnat_install_handler(void)
} }
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
__gnat_install_handler (); __gnat_install_handler ();
__gnat_init_float (); __gnat_init_float ();
...@@ -1963,7 +1850,7 @@ __gnat_initialize (void) ...@@ -1963,7 +1850,7 @@ __gnat_initialize (void)
/***************************************/ /***************************************/
void void
__gnat_initialize (void) __gnat_initialize (void *eh)
{ {
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* * * *
* C Implementation File * * C Implementation File *
* * * *
* Copyright (C) 1992-2004 Free Software Foundation, Inc. * * Copyright (C) 1992-2005, Free Software Foundation, Inc. *
* * * *
* GNAT is free software; you can redistribute it and/or modify it under * * GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- * * terms of the GNU General Public License as published by the Free Soft- *
...@@ -217,7 +217,7 @@ extern char **gnat_argv; ...@@ -217,7 +217,7 @@ extern char **gnat_argv;
/* Declare functions we use as part of startup. */ /* Declare functions we use as part of startup. */
extern void __gnat_initialize (void); extern void __gnat_initialize (void *);
extern void adainit (void); extern void adainit (void);
extern void _ada_gnat1drv (void); extern void _ada_gnat1drv (void);
...@@ -227,7 +227,7 @@ static void ...@@ -227,7 +227,7 @@ static void
gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED) gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
{ {
/* call the target specific initializations */ /* call the target specific initializations */
__gnat_initialize(); __gnat_initialize (NULL);
/* Call the front-end elaboration procedures */ /* Call the front-end elaboration procedures */
adainit (); adainit ();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* * * *
* C Header File * * C Header File *
* * * *
* Copyright (C) 1992-2004, Free Software Foundation, Inc. * * Copyright (C) 1992-2005, Free Software Foundation, Inc. *
* * * *
* GNAT is free software; you can redistribute it and/or modify it under * * GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- * * terms of the GNU General Public License as published by the Free Soft- *
...@@ -66,8 +66,9 @@ extern void __gnat_set_globals (int, int, ...@@ -66,8 +66,9 @@ extern void __gnat_set_globals (int, int,
char, char, char, char, char, char, char, char,
char *, char *, char *, char *,
int, int, int, int, int); int, int, int, int, int);
extern void __gnat_initialize (void); extern void __gnat_initialize (void *);
extern void __gnat_init_float (void); extern void __gnat_init_float (void);
extern void __gnat_install_handler (void); extern void __gnat_install_handler (void);
extern void __gnat_install_SEH_handler (void *);
extern int gnat_exit_status; extern int gnat_exit_status;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2004, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNARL is free software; you can redistribute it and/or modify it under -- -- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -910,6 +910,13 @@ package body System.Tasking.Stages is ...@@ -910,6 +910,13 @@ package body System.Tasking.Stages is
Secondary_Stack_Address : System.Address := Secondary_Stack'Address; Secondary_Stack_Address : System.Address := Secondary_Stack'Address;
SEH_Table : aliased SSE.Storage_Array (1 .. 8);
-- Structured Exception Registration table (2 words)
procedure Install_SEH_Handler (Addr : System.Address);
pragma Import (C, Install_SEH_Handler, "__gnat_install_SEH_handler");
-- Install the SEH (Structured Exception Handling) handler
begin begin
pragma Assert (Self_ID.Deferral_Level = 1); pragma Assert (Self_ID.Deferral_Level = 1);
...@@ -930,6 +937,11 @@ package body System.Tasking.Stages is ...@@ -930,6 +937,11 @@ package body System.Tasking.Stages is
Enter_Task (Self_ID); Enter_Task (Self_ID);
-- We setup the SEH (Structured Exception Handling) handler if supported
-- on the target.
Install_SEH_Handler (SEH_Table'Address);
-- We lock RTS_Lock to wait for activator to finish activating -- We lock RTS_Lock to wait for activator to finish activating
-- the rest of the chain, so that everyone in the chain comes out -- the rest of the chain, so that everyone in the chain comes out
-- in priority order. -- in priority order.
......
/****************************************************************************
* *
* GNAT COMPILER COMPONENTS *
* *
* S E H - I N I T *
* *
* C Implementation File *
* *
* Copyright (C) 2005, Free Software Foundation, Inc. *
* *
* GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- *
* ware Foundation; either version 2, or (at your option) any later ver- *
* sion. GNAT is distributed in the hope that it will be useful, but WITH- *
* OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
* for more details. You should have received a copy of the GNU General *
* Public License distributed with GNAT; see file COPYING. If not, write *
* to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, *
* MA 02111-1307, USA. *
* *
* As a special exception, if you link this file with other files to *
* produce an executable, this file does not by itself cause the resulting *
* executable to be covered by the GNU General Public License. This except- *
* ion does not however invalidate any other reasons why the executable *
* file might be covered by the GNU Public License. *
* *
* GNAT was originally developed by the GNAT team at New York University. *
* Extensive contributions were provided by Ada Core Technologies Inc. *
* *
****************************************************************************/
/* This unit contains support for SEH (Structured Exception Handling).
Right now the only implementation is for Win32. */
#ifdef IN_RTS
#include "tconfig.h"
#include "tsystem.h"
#include <sys/stat.h>
/* We don't have libiberty, so us malloc. */
#define xmalloc(S) malloc (S)
#else
#include "config.h"
#include "system.h"
#endif
#include "raise.h"
/* Addresses of exception data blocks for predefined exceptions. */
extern struct Exception_Data constraint_error;
extern struct Exception_Data numeric_error;
extern struct Exception_Data program_error;
extern struct Exception_Data storage_error;
extern struct Exception_Data tasking_error;
extern struct Exception_Data _abort_signal;
#define Raise_From_Signal_Handler \
ada__exceptions__raise_from_signal_handler
extern void Raise_From_Signal_Handler (struct Exception_Data *, const char *);
#ifdef _WIN32
#include <windows.h>
#include <excpt.h>
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,
void *DispatcherContext)
{
struct Exception_Data *exception;
const char *msg;
switch (ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
/* If the failing address isn't maximally-aligned or if the page
before the faulting page is not accessible, this is a program error.
*/
if ((ExceptionRecord->ExceptionInformation[1] & 3) != 0
|| IsBadCodePtr
((void *)(ExceptionRecord->ExceptionInformation[1] + 4096)))
{
exception = &program_error;
msg = "EXCEPTION_ACCESS_VIOLATION";
}
else
{
/* otherwise it is a stack overflow */
exception = &storage_error;
msg = "stack overflow (or erroneous memory access)";
}
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
exception = &constraint_error;
msg = "EXCEPTION_ARRAY_BOUNDS_EXCEEDED";
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
exception = &constraint_error;
msg = "EXCEPTION_DATATYPE_MISALIGNMENT";
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
exception = &constraint_error;
msg = "EXCEPTION_FLT_DENORMAL_OPERAND";
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
exception = &constraint_error;
msg = "EXCEPTION_FLT_DENORMAL_OPERAND";
break;
case EXCEPTION_FLT_INVALID_OPERATION:
exception = &constraint_error;
msg = "EXCEPTION_FLT_INVALID_OPERATION";
break;
case EXCEPTION_FLT_OVERFLOW:
exception = &constraint_error;
msg = "EXCEPTION_FLT_OVERFLOW";
break;
case EXCEPTION_FLT_STACK_CHECK:
exception = &program_error;
msg = "EXCEPTION_FLT_STACK_CHECK";
break;
case EXCEPTION_FLT_UNDERFLOW:
exception = &constraint_error;
msg = "EXCEPTION_FLT_UNDERFLOW";
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
exception = &constraint_error;
msg = "EXCEPTION_INT_DIVIDE_BY_ZERO";
break;
case EXCEPTION_INT_OVERFLOW:
exception = &constraint_error;
msg = "EXCEPTION_INT_OVERFLOW";
break;
case EXCEPTION_INVALID_DISPOSITION:
exception = &program_error;
msg = "EXCEPTION_INVALID_DISPOSITION";
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
exception = &program_error;
msg = "EXCEPTION_NONCONTINUABLE_EXCEPTION";
break;
case EXCEPTION_PRIV_INSTRUCTION:
exception = &program_error;
msg = "EXCEPTION_PRIV_INSTRUCTION";
break;
case EXCEPTION_SINGLE_STEP:
exception = &program_error;
msg = "EXCEPTION_SINGLE_STEP";
break;
case EXCEPTION_STACK_OVERFLOW:
exception = &storage_error;
msg = "EXCEPTION_STACK_OVERFLOW";
break;
default:
exception = &program_error;
msg = "unhandled signal";
}
/* This call is important as it avoids locking the second time we catch a
signal. Note that this routine is documented as internal to Windows and
should not be used. */
_global_unwind2 (EstablisherFrame);
/* Call equivalent to RtlUnwind (EstablisherFrame, NULL, NULL, 0); */
Raise_From_Signal_Handler (exception, msg);
return 0; /* This is never reached, avoid compiler warning */
}
/* Install the Win32 SEH exception handler. Note that the caller must have
allocated 8 bytes on the stack and pass the pointer to this stack
space. This is needed as the SEH exception handler must be on the stack of
the thread.
int buf[2];
__gnat_install_SEH_handler ((void*)buf);
main();
This call must be done before calling the main procedure or the thread
entry. The stack space must exists during all the main run. */
void
__gnat_install_SEH_handler (void *ER)
{
int *ptr;
/* put current handler in ptr */
asm ("mov %%fs:(0),%%ecx" : : : "%ecx");
asm ("mov %%ecx,%0" : "=m" (ptr));
((int *)ER)[0] = (int)ptr; /* previous handler */
((int *)ER)[1] = (int)__gnat_SEH_error_handler; /* new handler */
/* ptr is the new handler, set fs:(0) with this value */
ptr = (int *)ER;
asm ("mov %0,%%ecx" : : "m" (ptr) : "%ecx");
asm ("mov %ecx,%fs:(0)");
}
#else /* _WIN32 */
/* For all non Windows targets we provide a dummy SEH install handler. */
void __gnat_install_SEH_handler (void *eh ATTRIBUTE_UNUSED)
{
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment