aix-unwind.h (MD_FALLBACK_FRAME_STATE_FOR): Define unconditionally.
authorTony Reix <tony.reix@atos.net>
Wed, 7 Jun 2017 12:35:19 +0000 (12:35 +0000)
committerDavid Edelsohn <dje@gcc.gnu.org>
Wed, 7 Jun 2017 12:35:19 +0000 (08:35 -0400)
2017-06-07  Tony Reix  <tony.reix@atos.net>
            Matthieu Sarter  <matthieu.sarter.external@atos.net>
            David Edelsohn  <dje.gcc@gmail.com>

        * config/rs6000/aix-unwind.h (MD_FALLBACK_FRAME_STATE_FOR): Define
        unconditionally.
        (ucontext_for): Add 64-bit AIX 6.1, 7.1, 7.2 support.  Add 32-bit
        AIX 7.2 support.

Co-Authored-By: David Edelsohn <dje.gcc@gmail.com>
Co-Authored-By: Matthieu Sarter <matthieu.sarter.external@atos.net>
From-SVN: r248968

libgcc/ChangeLog
libgcc/config/rs6000/aix-unwind.h

index 5a2b12b..8560804 100644 (file)
@@ -1,3 +1,12 @@
+2017-06-07  Tony Reix  <tony.reix@atos.net>
+           Matthieu Sarter  <matthieu.sarter.external@atos.net>
+           David Edelsohn  <dje.gcc@gmail.com>
+
+        * config/rs6000/aix-unwind.h (MD_FALLBACK_FRAME_STATE_FOR): Define
+        unconditionally.
+        (ucontext_for): Add 64-bit AIX 6.1, 7.1, 7.2 support.  Add 32-bit
+        AIX 7.2 support.
+
 2017-06-02  Olivier Hainque  <hainque@adacore.com>
 
        * config/vxlib.c (__gthread_once): Add missing value to
index c513a12..2d8cdae 100644 (file)
@@ -64,7 +64,8 @@
 #endif
 
 /* Now on to MD_FALLBACK_FRAME_STATE_FOR.
-   32bit AIX 5.2, 5.3 and 7.1 only at this stage.  */
+   32bit AIX 5.2, 5.3, 6.1, 7.X and
+   64bit AIX 6.1, 7.X only at this stage.  */
 
 #include <stdlib.h>
 #include <stddef.h>
 
 #ifdef __64BIT__
 
-/* 64bit fallback not implemented yet, so MD_FALLBACK_FRAME_STATE_FOR not
-   defined.  Arrange just for the code below to compile.  */
 typedef struct __context64 mstate_t;
 
 #else
 
 typedef struct mstsave mstate_t;
 
-#define MD_FALLBACK_FRAME_STATE_FOR ppc_aix_fallback_frame_state
-
 #endif
 
+#define MD_FALLBACK_FRAME_STATE_FOR ppc_aix_fallback_frame_state
+
 /* If we are compiling on AIX < 5.3, the VMX related datastructs are not
    defined and we take measures to obtain proper runtime behavior if the
    compiled code happens to run on a later version with VMX enabled.  */
@@ -128,10 +127,26 @@ ucontext_for (struct _Unwind_Context *context)
 {
   const unsigned int * ra = context->ra;
 
-  /* AIX 5.2, 5.3 and 7.1, threaded or not, share common patterns
+  /* AIX 5.2, 5.3, 6.1 and 7.X, threaded or not, share common patterns
      and feature variants depending on the configured kernel (unix_mp
      or unix_64).  */
 
+#ifdef __64BIT__
+  if (*(ra - 5) == 0x4c00012c     /* isync             */
+      && *(ra - 4) == 0xe8ec0000  /* ld      r7,0(r12) */
+      && *(ra - 3) == 0xe84c0008  /* ld      r2,8(r12) */
+      && *(ra - 2) == 0x7ce903a6  /* mtctr   r7        */
+      && *(ra - 1) == 0x4e800421  /* bctrl             */
+      && *(ra - 0) == 0x7de27b78) /* mr      r2,r15   <-- context->ra */
+    {
+      /* unix_64 */
+      if (*(ra - 6) == 0x7d000164)  /* mtmsrd  r8 */
+        {
+          /* AIX 6.1, 7.1 and 7.2 */
+          return (ucontext_t *)(context->cfa + 0x70);
+        }
+    }
+#else
   if (*(ra - 5) == 0x4c00012c     /* isync             */
       && *(ra - 4) == 0x80ec0000  /* lwz     r7,0(r12) */
       && *(ra - 3) == 0x804c0004  /* lwz     r2,4(r12) */
@@ -152,10 +167,14 @@ ucontext_for (struct _Unwind_Context *context)
            case 0x835a0570:  /* lwz r26,1392(r26) */
              return (ucontext_t *)(context->cfa + 0x40);
 
-             /* AIX 7.1 */
+             /* AIX 6.1 and 7.1 */
            case 0x2c1a0000:  /* cmpwi   r26,0 */
              return (ucontext_t *)(context->cfa + 0x40);
-               
+
+             /* AIX 7.2 */
+           case 0x3800000a:  /* li   r0,A */
+             return (ucontext_t *)(context->cfa + 0x40);
+
            default:
              return 0;
            }
@@ -174,7 +193,7 @@ ucontext_for (struct _Unwind_Context *context)
          return &frame->ucontext;
        }
     }
-
+#endif
   return 0;
 }