[PATCH] D51530: [libunwind] Fix existing code for SEH on ARM to compile correctly

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 31 07:57:57 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL341217: Fix existing code for SEH on ARM to compile correctly (authored by mstorsjo, committed by ).
Herald added subscribers: llvm-commits, christof.

Changed prior to commit:
  https://reviews.llvm.org/D51530?vs=163487&id=163534#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51530

Files:
  libunwind/trunk/include/__libunwind_config.h
  libunwind/trunk/src/Unwind-seh.cpp
  libunwind/trunk/src/UnwindCursor.hpp


Index: libunwind/trunk/src/Unwind-seh.cpp
===================================================================
--- libunwind/trunk/src/Unwind-seh.cpp
+++ libunwind/trunk/src/Unwind-seh.cpp
@@ -164,17 +164,22 @@
     // This should never happen in phase 1.
     if (!IS_UNWINDING(ms_exc->ExceptionFlags))
       _LIBUNWIND_ABORT("Personality installed context during phase 1!");
-    exc->private_[2] = disp->TargetIp;
 #ifdef __x86_64__
+    exc->private_[2] = disp->TargetIp;
     unw_get_reg(&cursor, UNW_X86_64_RAX, &retval);
     unw_get_reg(&cursor, UNW_X86_64_RDX, &exc->private_[3]);
 #elif defined(__arm__)
+    exc->private_[2] = disp->TargetPc;
     unw_get_reg(&cursor, UNW_ARM_R0, &retval);
     unw_get_reg(&cursor, UNW_ARM_R1, &exc->private_[3]);
 #endif
     unw_get_reg(&cursor, UNW_REG_IP, &target);
     ms_exc->ExceptionCode = STATUS_GCC_UNWIND;
+#ifdef __x86_64__
     ms_exc->ExceptionInformation[2] = disp->TargetIp;
+#elif defined(__arm__)
+    ms_exc->ExceptionInformation[2] = disp->TargetPc;
+#endif
     ms_exc->ExceptionInformation[3] = exc->private_[3];
     // Give NTRTL some scratch space to keep track of the collided unwind.
     // Don't use the one that was passed in; we don't want to overwrite the
Index: libunwind/trunk/src/UnwindCursor.hpp
===================================================================
--- libunwind/trunk/src/UnwindCursor.hpp
+++ libunwind/trunk/src/UnwindCursor.hpp
@@ -606,14 +606,14 @@
   _msContext.R12 = r.getRegister(UNW_ARM_R12);
   _msContext.Sp = r.getRegister(UNW_ARM_SP);
   _msContext.Lr = r.getRegister(UNW_ARM_LR);
-  _msContext.Pc = r.getRegister(UNW_ARM_PC);
-  for (int r = UNW_ARM_D0; r <= UNW_ARM_D31; ++r) {
+  _msContext.Pc = r.getRegister(UNW_ARM_IP);
+  for (int i = UNW_ARM_D0; i <= UNW_ARM_D31; ++i) {
     union {
       uint64_t w;
       double d;
     } d;
-    d.d = r.getFloatRegister(r);
-    _msContext.D[r - UNW_ARM_D0] = d.w;
+    d.d = r.getFloatRegister(i);
+    _msContext.D[i - UNW_ARM_D0] = d.w;
   }
 #endif
 }
@@ -682,7 +682,7 @@
   case UNW_ARM_SP: return _msContext.Sp;
   case UNW_ARM_LR: return _msContext.Lr;
   case UNW_REG_IP:
-  case UNW_ARM_PC: return _msContext.Pc;
+  case UNW_ARM_IP: return _msContext.Pc;
 #endif
   }
   _LIBUNWIND_ABORT("unsupported register");
@@ -728,7 +728,7 @@
   case UNW_ARM_SP: _msContext.Sp = value; break;
   case UNW_ARM_LR: _msContext.Lr = value; break;
   case UNW_REG_IP:
-  case UNW_ARM_PC: _msContext.Pc = value; break;
+  case UNW_ARM_IP: _msContext.Pc = value; break;
 #endif
   default:
     _LIBUNWIND_ABORT("unsupported register");
@@ -842,7 +842,7 @@
   case UNW_ARM_SP: return "sp";
   case UNW_ARM_LR: return "lr";
   case UNW_REG_IP:
-  case UNW_ARM_PC: return "pc";
+  case UNW_ARM_IP: return "pc";
   case UNW_ARM_S0: return "s0";
   case UNW_ARM_S1: return "s1";
   case UNW_ARM_S2: return "s2";
Index: libunwind/trunk/include/__libunwind_config.h
===================================================================
--- libunwind/trunk/include/__libunwind_config.h
+++ libunwind/trunk/include/__libunwind_config.h
@@ -63,7 +63,7 @@
 #  define _LIBUNWIND_TARGET_ARM 1
 #  if defined(__SEH__)
 #    define _LIBUNWIND_CONTEXT_SIZE 42
-#    define _LIBUNWIND_CURSOR_SIZE 85
+#    define _LIBUNWIND_CURSOR_SIZE 80
 #  elif defined(__ARM_WMMX)
 #    define _LIBUNWIND_CONTEXT_SIZE 61
 #    define _LIBUNWIND_CURSOR_SIZE 68


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51530.163534.patch
Type: text/x-patch
Size: 3379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180831/f9a26804/attachment-0001.bin>


More information about the cfe-commits mailing list