On 12 Nov 2011, at 07:44, Eric Botcazou wrote:

This has been filed as radar #10302855, but we need a work-around
until that is resolved (possibly forever on older systems).

OK for trunk?
(what opinion about 4.6?)

Did you apply it to the 4.6 branch? I think that this would be appropriate.

ada:

        PR target/50678
        * init.c (Darwin/__gnat_error_handler): Transpose rbx and rdx in the
        handler.

Sorry, I overlooked something here: there is a specific procedure to make this kind of adjustments. The reason is that the adjustment needs to be made in the tasking case as well and __gnat_error_handler isn't used for this case.

So HAVE_GNAT_ADJUST_CONTEXT_FOR_RAISE must be defined in the Darwin- specific section and __gnat_adjust_context_for_raise implemented (with the standard
prototype) and __gnat_error_handler changed to call it instead.

Would you mind adjusting the fix that way?  Thanks in advance.

the following is reg-strapping on x86-64-darwin10,
OK for trunk (and 4.6) if it succeeds (with a ChangeLog, of course) ?
Iain

Index: gcc/ada/init.c
===================================================================
--- gcc/ada/init.c      (revision 181448)
+++ gcc/ada/init.c      (working copy)
@@ -2282,11 +2282,12 @@ __gnat_is_stack_guard (mach_vm_address_t addr)
   return 0;
 }

-static void
-__gnat_error_handler (int sig, siginfo_t *si, void *ucontext ATTRIBUTE_UNUSED)
+#define HAVE_GNAT_ADJUST_CONTEXT_FOR_RAISE
+
+void
+__gnat_adjust_context_for_raise (int signo ATTRIBUTE_UNUSED,
+                                void *ucontext ATTRIBUTE_UNUSED)
 {
-  struct Exception_Data *exception;
-  const char *msg;
 #if defined (__x86_64__)
/* Work around radar #10302855/pr50678, where the unwinders (libunwind or libgcc_s depending on the system revision) and the DWARF unwind data for
@@ -2294,10 +2295,23 @@ __gnat_is_stack_guard (mach_vm_address_t addr)
      and rdx to be transposed)..  */
   ucontext_t *uc = (ucontext_t *)ucontext ;
   unsigned long t = uc->uc_mcontext->__ss.__rbx;
+
   uc->uc_mcontext->__ss.__rbx = uc->uc_mcontext->__ss.__rdx;
   uc->uc_mcontext->__ss.__rdx = t;
 #endif
+}

+static void
+__gnat_error_handler (int sig, siginfo_t *si, void *ucontext ATTRIBUTE_UNUSED)
+{
+  struct Exception_Data *exception;
+  const char *msg;
+
+#if defined (__x86_64__)
+  /* Work around #10302855/pr50678 on x86-64 Darwin.  */
+  __gnat_adjust_context_for_raise (sig, ucontext);
+#endif
+
   switch (sig)
     {
     case SIGSEGV:

Reply via email to