diff gcc/ada/raise-gcc.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
line wrap: on
line diff
--- a/gcc/ada/raise-gcc.c	Thu Oct 25 07:37:49 2018 +0900
+++ b/gcc/ada/raise-gcc.c	Thu Feb 13 11:34:05 2020 +0900
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *             Copyright (C) 1992-2018, Free Software Foundation, Inc.      *
+ *             Copyright (C) 1992-2019, 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- *
@@ -39,11 +39,11 @@
   /* Don't use fancy_abort.  */
 # undef abort
 #else
-# ifndef CERT
+# if !defined(CERT) && !defined(STANDALONE)
 #  include "tconfig.h"
 #  include "tsystem.h"
 # else
-#  define ATTRIBUTE_UNUSED __attribute__((unused))
+#  include "runtime.h"
 #  define HAVE_GETIPINFO 1
 # endif
 #endif
@@ -115,6 +115,10 @@
 /* Called in case of error during propagation.  */
 extern void __gnat_raise_abort (void) __attribute__ ((noreturn));
 #define abort() __gnat_raise_abort()
+
+#elif defined(STANDALONE)
+#include <stdlib.h>
+#define inhibit_libc
 #endif
 
 #include "unwind-pe.h"
@@ -885,7 +889,7 @@
    argument, and PROPAGATED_EXCEPTION a pointer to the currently propagated
    occurrence, return true if the latter matches the former, that is, if
    PROPAGATED_EXCEPTION is caught by the handling code controlled by CHOICE.
-   This takes care of the special Non_Ada_Error case on VMS.  */
+*/
 
 #define Is_Handled_By_Others  __gnat_is_handled_by_others
 #define Language_For          __gnat_language_for
@@ -902,11 +906,6 @@
 #define Foreign_Exception system__exceptions__foreign_exception
 extern struct Exception_Data Foreign_Exception;
 
-#ifdef VMS
-#define Non_Ada_Error system__aux_dec__non_ada_error
-extern struct Exception_Data Non_Ada_Error;
-#endif
-
 /* Return true iff the exception class of EXCEPT is EC.  */
 
 static int
@@ -947,23 +946,6 @@
       if (choice == E || (choice == GNAT_OTHERS && Is_Handled_By_Others (E)))
 	return handler;
 
-#ifdef VMS
-      /* In addition, on OpenVMS, Non_Ada_Error matches VMS exceptions, and we
-         may have different exception data pointers that should match for the
-         same condition code, if both an export and an import have been
-         registered.  The import code for both the choice and the propagated
-         occurrence are expected to have been masked off regarding severity
-         bits already (at registration time for the former and from within the
-         low level exception vector for the latter).  */
-      if ((Language_For (E) == 'V'
-	   && choice != GNAT_OTHERS
-	   && ((Language_For (choice) == 'V'
-		&& Foreign_Data_For (choice) != 0
-		&& Foreign_Data_For (choice) == Foreign_Data_For (E))
-	       || choice == (_Unwind_Ptr)&Non_Ada_Error)))
-	return handler;
-#endif
-
       /* Otherwise, it doesn't match an Ada choice.  */
       return nothing;
     }
@@ -1154,10 +1136,18 @@
 #define PERSONALITY_FUNCTION    __gnat_personality_v0
 #endif
 
+#if defined (__ARM_EABI_UNWINDER__) \
+    && (defined (IN_RTS) || GCC_VERSION > 9000)
+#define TARGET_ATTRIBUTE __attribute__((target ("general-regs-only")))
+#else
+#define TARGET_ATTRIBUTE
+#endif
+
 /* Code executed to continue unwinding.  With the ARM unwinder, the
    personality routine must unwind one frame (per EHABI 7.3 4.).  */
 
 static _Unwind_Reason_Code
+TARGET_ATTRIBUTE
 continue_unwind (struct _Unwind_Exception* ue_header ATTRIBUTE_UNUSED,
 		 struct _Unwind_Context* uw_context ATTRIBUTE_UNUSED)
 {
@@ -1172,6 +1162,7 @@
    between all unwinders.  */
 
 static _Unwind_Reason_Code
+TARGET_ATTRIBUTE
 personality_body (_Unwind_Action uw_phases,
 		  _Unwind_Exception *uw_exception,
 		  _Unwind_Context *uw_context)
@@ -1220,6 +1211,16 @@
 	}
       else
 	{
+#ifdef __ARM_EABI_UNWINDER__
+	  /* Though we do not use this field ourselves, initializing
+	     it is required by the ARM EH ABI before a personality
+	     function in phase1 returns _URC_HANDLER_FOUND, so that
+	     any personality function can use it in phase2 to test
+	     whether the handler frame was reached.  */
+	  uw_exception->barrier_cache.sp
+	    = _Unwind_GetGR (uw_context, UNWIND_STACK_REG);
+#endif
+
 #ifndef CERT
 	  /* Trigger the appropriate notification routines before the second
 	     phase starts, when the stack is still intact.  First install what
@@ -1258,36 +1259,8 @@
 }
 
 #ifndef __ARM_EABI_UNWINDER__
-/* Major tweak for ia64-vms : the CHF propagation phase calls this personality
-   routine with sigargs/mechargs arguments and has very specific expectations
-   on possible return values.
-
-   We handle this with a number of specific tricks:
-
-   1. We tweak the personality routine prototype to have the "version" and
-      "phases" two first arguments be void * instead of int and _Unwind_Action
-      as nominally expected in the GCC context.
-
-      This allows us to access the full range of bits passed in every case and
-      has no impact on the callers side since each argument remains assigned
-      the same single 64bit slot.
-
-   2. We retrieve the corresponding int and _Unwind_Action values within the
-      routine for regular use with truncating conversions. This is a noop when
-      called from the libgcc unwinder.
-
-   3. We assume we're called by the VMS CHF when unexpected bits are set in
-      both those values. The incoming arguments are then real sigargs and
-      mechargs pointers, which we then redirect to __gnat_handle_vms_condition
-      for proper processing.
-*/
-#if defined (VMS) && defined (__IA64)
-typedef void * version_arg_t;
-typedef void * phases_arg_t;
-#else
 typedef int version_arg_t;
 typedef _Unwind_Action phases_arg_t;
-#endif
 
 PERSONALITY_STORAGE _Unwind_Reason_Code
 PERSONALITY_FUNCTION (version_arg_t, phases_arg_t,
@@ -1308,28 +1281,9 @@
   int uw_version = (int) version_arg;
   _Unwind_Action uw_phases = (_Unwind_Action) phases_arg;
 
-  /* Check that we're called from the ABI context we expect, with a major
-     possible variation on VMS for IA64.  */
+  /* Check that we're called from the ABI context we expect.  */
   if (uw_version != 1)
-    {
-#if defined (VMS) && defined (__IA64)
-
-      /* Assume we're called with sigargs/mechargs arguments if really
-	 unexpected bits are set in our first two formals.  Redirect to the
-	 GNAT condition handling code in this case.  */
-
-      extern long __gnat_handle_vms_condition (void *, void *);
-
-      unsigned int version_unexpected_bits_mask = 0xffffff00U;
-      unsigned int phases_unexpected_bits_mask  = 0xffffff00U;
-
-      if ((unsigned int)uw_version & version_unexpected_bits_mask
-	  && (unsigned int)uw_phases & phases_unexpected_bits_mask)
-	return __gnat_handle_vms_condition (version_arg, phases_arg);
-#endif
-
-      return _URC_FATAL_PHASE1_ERROR;
-    }
+    return _URC_FATAL_PHASE1_ERROR;
 
   return personality_body (uw_phases, uw_exception, uw_context);
 }
@@ -1342,6 +1296,7 @@
 		      struct _Unwind_Context* uw_context);
 
 PERSONALITY_STORAGE _Unwind_Reason_Code
+TARGET_ATTRIBUTE
 PERSONALITY_FUNCTION (_Unwind_State state,
 		      struct _Unwind_Exception* uw_exception,
 		      struct _Unwind_Context* uw_context)
@@ -1654,6 +1609,19 @@
 			   __gnat_personality_imp);
 }
 
+/* Define __gnat_personality_v0 for convenience */
+
+PERSONALITY_STORAGE _Unwind_Reason_Code
+__gnat_personality_v0 (version_arg_t version_arg,
+		       phases_arg_t phases_arg,
+		       _Unwind_Exception_Class uw_exception_class,
+		       _Unwind_Exception *uw_exception,
+		       _Unwind_Context *uw_context)
+{
+  return PERSONALITY_FUNCTION
+    (version_arg, phases_arg, uw_exception_class, uw_exception, uw_context);
+}
+
 #endif /* SEH */
 
 #if !defined (__USING_SJLJ_EXCEPTIONS__)