Martin Storsjo : ntdll: Fix the arm64 use of libunwind for macOS.

Alexandre Julliard julliard at winehq.org
Tue Aug 18 16:34:24 CDT 2020


Module: wine
Branch: master
Commit: 7f8224411c39242fe751524816b1349002066c72
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=7f8224411c39242fe751524816b1349002066c72

Author: Martin Storsjo <martin at martin.st>
Date:   Fri Aug 14 14:54:16 2020 +0300

ntdll: Fix the arm64 use of libunwind for macOS.

MacOS uses the LLVM libunwind, which doesn't expose quite as much
internals of the cursor as GNU libunwind, and uses slightly different
names for the arch specific register enums (for get/set registers).

Signed-off-by: Martin Storsjo <martin at martin.st>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/signal_arm64.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c
index b4fe46f25a..cbb6a019e5 100644
--- a/dlls/ntdll/unix/signal_arm64.c
+++ b/dlls/ntdll/unix/signal_arm64.c
@@ -156,11 +156,27 @@ NTSTATUS CDECL unwind_builtin_dll( ULONG type, DISPATCHER_CONTEXT *dispatch, CON
     unw_proc_info_t info;
     int rc;
 
+#ifdef __APPLE__
+    rc = unw_getcontext( &unw_context );
+    if (rc == UNW_ESUCCESS)
+        rc = unw_init_local( &cursor, &unw_context );
+    if (rc == UNW_ESUCCESS)
+    {
+        int i;
+        for (i = 0; i <= 28; i++)
+            unw_set_reg( &cursor, UNW_ARM64_X0 + i, context->u.X[i] );
+        unw_set_reg( &cursor, UNW_ARM64_FP, context->u.s.Fp );
+        unw_set_reg( &cursor, UNW_ARM64_LR, context->u.s.Lr );
+        unw_set_reg( &cursor, UNW_ARM64_SP, context->Sp );
+        unw_set_reg( &cursor, UNW_REG_IP,   context->Pc );
+    }
+#else
     memcpy( unw_context.uc_mcontext.regs, context->u.X, sizeof(context->u.X) );
     unw_context.uc_mcontext.sp = context->Sp;
     unw_context.uc_mcontext.pc = context->Pc;
 
     rc = unw_init_local( &cursor, &unw_context );
+#endif
     if (rc != UNW_ESUCCESS)
     {
         WARN( "setup failed: %d\n", rc );
@@ -198,6 +214,16 @@ NTSTATUS CDECL unwind_builtin_dll( ULONG type, DISPATCHER_CONTEXT *dispatch, CON
     dispatch->LanguageHandler  = (void *)info.handler;
     dispatch->HandlerData      = (void *)info.lsda;
     dispatch->EstablisherFrame = context->Sp;
+#ifdef __APPLE__
+    {
+        int i;
+        for (i = 0; i <= 28; i++)
+            unw_get_reg( &cursor, UNW_ARM64_X0 + i, (unw_word_t *)&context->u.X[i] );
+    }
+    unw_get_reg( &cursor, UNW_ARM64_FP,    (unw_word_t *)&context->u.s.Fp );
+    unw_get_reg( &cursor, UNW_ARM64_X30,   (unw_word_t *)&context->u.s.Lr );
+    unw_get_reg( &cursor, UNW_ARM64_SP,    (unw_word_t *)&context->Sp );
+#else
     unw_get_reg( &cursor, UNW_AARCH64_X0,  (unw_word_t *)&context->u.s.X0 );
     unw_get_reg( &cursor, UNW_AARCH64_X1,  (unw_word_t *)&context->u.s.X1 );
     unw_get_reg( &cursor, UNW_AARCH64_X2,  (unw_word_t *)&context->u.s.X2 );
@@ -230,6 +256,7 @@ NTSTATUS CDECL unwind_builtin_dll( ULONG type, DISPATCHER_CONTEXT *dispatch, CON
     unw_get_reg( &cursor, UNW_AARCH64_X29, (unw_word_t *)&context->u.s.Fp );
     unw_get_reg( &cursor, UNW_AARCH64_X30, (unw_word_t *)&context->u.s.Lr );
     unw_get_reg( &cursor, UNW_AARCH64_SP,  (unw_word_t *)&context->Sp );
+#endif
     unw_get_reg( &cursor, UNW_REG_IP,      (unw_word_t *)&context->Pc );
     context->ContextFlags |= CONTEXT_UNWOUND_TO_CALL;
 




More information about the wine-cvs mailing list