[libcxx-commits] [PATCH] D126869: [libunwind] Don't store a predecremented PC when using SEH

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 6 13:28:26 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG08d30c602bcf: [libunwind] Don't store a predecremented PC when using SEH (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126869/new/

https://reviews.llvm.org/D126869

Files:
  libunwind/src/Unwind-seh.cpp
  libunwind/src/UnwindCursor.hpp


Index: libunwind/src/UnwindCursor.hpp
===================================================================
--- libunwind/src/UnwindCursor.hpp
+++ libunwind/src/UnwindCursor.hpp
@@ -518,6 +518,14 @@
   pint_t getLastPC() const { return _dispContext.ControlPc; }
   void setLastPC(pint_t pc) { _dispContext.ControlPc = pc; }
   RUNTIME_FUNCTION *lookUpSEHUnwindInfo(pint_t pc, pint_t *base) {
+#ifdef __arm__
+    // Remove the thumb bit; FunctionEntry ranges don't include the thumb bit.
+    pc &= ~1U;
+#endif
+    // If pc points exactly at the end of the range, we might resolve the
+    // next function instead. Decrement pc by 1 to fit inside the current
+    // function.
+    pc -= 1;
     _dispContext.FunctionEntry = RtlLookupFunctionEntry(pc,
                                                         &_dispContext.ImageBase,
                                                         _dispContext.HistoryTable);
Index: libunwind/src/Unwind-seh.cpp
===================================================================
--- libunwind/src/Unwind-seh.cpp
+++ libunwind/src/Unwind-seh.cpp
@@ -104,7 +104,7 @@
   if (!ctx) {
     __unw_init_seh(&cursor, disp->ContextRecord);
     __unw_seh_set_disp_ctx(&cursor, disp);
-    __unw_set_reg(&cursor, UNW_REG_IP, disp->ControlPc - 1);
+    __unw_set_reg(&cursor, UNW_REG_IP, disp->ControlPc);
     ctx = (struct _Unwind_Context *)&cursor;
 
     if (!IS_UNWINDING(ms_exc->ExceptionFlags)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126869.434587.patch
Type: text/x-patch
Size: 1438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220606/2bead99c/attachment.bin>


More information about the libcxx-commits mailing list