[libunwind] r337312 - The semantics of DW_CFA_GNU_args_size have changed subtile over the

Joerg Sonnenberger via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 17 12:00:51 PDT 2018


Author: joerg
Date: Tue Jul 17 12:00:51 2018
New Revision: 337312

URL: http://llvm.org/viewvc/llvm-project?rev=337312&view=rev
Log:
The semantics of DW_CFA_GNU_args_size have changed subtile over the
years. Adopt the new convention that it is call-site specific and that
it should be applied before moving the IP by personality routines, but
not during normal unwinding.

Differential Revision: https://reviews.llvm.org/D38680

Modified:
    libunwind/trunk/src/UnwindCursor.hpp
    libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=337312&r1=337311&r2=337312&view=diff
==============================================================================
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Tue Jul 17 12:00:51 2018
@@ -1411,8 +1411,6 @@ int UnwindCursor<A, R>::step() {
     this->setInfoBasedOnIPRegister(true);
     if (_unwindInfoMissing)
       return UNW_STEP_END;
-    if (_info.gp)
-      setReg(UNW_REG_SP, getReg(UNW_REG_SP) + _info.gp);
   }
 
   return result;

Modified: libunwind/trunk/src/libunwind.cpp
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/libunwind.cpp?rev=337312&r1=337311&r2=337312&view=diff
==============================================================================
--- libunwind/trunk/src/libunwind.cpp (original)
+++ libunwind/trunk/src/libunwind.cpp Tue Jul 17 12:00:51 2018
@@ -188,8 +188,20 @@ _LIBUNWIND_EXPORT int unw_set_reg(unw_cu
     co->setReg(regNum, (pint_t)value);
     // specical case altering IP to re-find info (being called by personality
     // function)
-    if (regNum == UNW_REG_IP)
+    if (regNum == UNW_REG_IP) {
+      unw_proc_info_t info;
+      // First, get the FDE for the old location and then update it.
+      co->getInfo(&info);
       co->setInfoBasedOnIPRegister(false);
+      // If the original call expects stack adjustment, perform this now.
+      // Normal frame unwinding would have included the offset already in the
+      // CFA computation.
+      // Note: for PA-RISC and other platforms where the stack grows up,
+      // this should actually be - info.gp. LLVM doesn't currently support
+      // any such platforms and Clang doesn't export a macro for them.
+      if (info.gp)
+        co->setReg(UNW_REG_SP, co->getReg(UNW_REG_SP) + info.gp);
+    }
     return UNW_ESUCCESS;
   }
   return UNW_EBADREG;




More information about the cfe-commits mailing list