mstorsjo created this revision.
Herald added subscribers: kristof.beyls, aprantl, aemerson.

This reduces the differences between the EHABI and DWARF cases.

This allows getting rid of some casts in _LIBUNWIND_TRACE_API log lines, making 
them match what's in UnwindLevel1.c for DWARF.

The only non-obvious detail is in _Unwind_VRS_Get_Internal (called via 
_Unwind_VRS_Get), where a void pointer is assumed to be uint32_t or uintptr_t 
(depending on the caller); this can no longer use unw_word_t directly as before.


https://reviews.llvm.org/D39280

Files:
  include/__libunwind_config.h
  include/libunwind.h
  src/Unwind-EHABI.cpp

Index: src/Unwind-EHABI.cpp
===================================================================
--- src/Unwind-EHABI.cpp
+++ src/Unwind-EHABI.cpp
@@ -14,6 +14,7 @@
 
 #if defined(_LIBUNWIND_ARM_EHABI)
 
+#include <inttypes.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -468,11 +469,11 @@
       unw_word_t pc;
       unw_get_reg(cursor, UNW_REG_IP, &pc);
       _LIBUNWIND_TRACE_UNWINDING(
-          "unwind_phase1(ex_ojb=%p): pc=0x%llX, start_ip=0x%llX, func=%s, "
-          "lsda=0x%llX, personality=0x%llX",
-          static_cast<void *>(exception_object), (long long)pc,
-          (long long)frameInfo.start_ip, functionName,
-          (long long)frameInfo.lsda, (long long)frameInfo.handler);
+          "unwind_phase1(ex_ojb=%p): pc=0x%" PRIX64 ", start_ip=0x%" PRIX64 " func=%s, "
+          "lsda=0x" PRIX64 ", personality=0x" PRIX64 "",
+          static_cast<void *>(exception_object), pc,
+          frameInfo.start_ip, functionName,
+          frameInfo.lsda, frameInfo.handler);
     }
 
     // If there is a personality routine, ask it if it will want to stop at
@@ -584,11 +585,11 @@
           (frameInfo.start_ip + offset > frameInfo.end_ip))
         functionName = ".anonymous.";
       _LIBUNWIND_TRACE_UNWINDING(
-          "unwind_phase2(ex_ojb=%p): start_ip=0x%llX, func=%s, sp=0x%llX, "
-          "lsda=0x%llX, personality=0x%llX",
-          static_cast<void *>(exception_object), (long long)frameInfo.start_ip,
-          functionName, (long long)sp, (long long)frameInfo.lsda,
-          (long long)frameInfo.handler);
+          "unwind_phase2(ex_ojb=%p): start_ip=0x%" PRIX64 " func=%s, sp=0x%" PRIX64 ", "
+          "lsda=0x%" PRIX64 ", personality=0x%" PRIX64 "",
+          static_cast<void *>(exception_object), frameInfo.start_ip,
+          functionName, sp, frameInfo.lsda,
+          frameInfo.handler);
     }
 
     // If there is a personality routine, tell it we are unwinding.
@@ -627,9 +628,9 @@
           unw_get_reg(cursor, UNW_REG_IP, &pc);
           unw_get_reg(cursor, UNW_REG_SP, &sp);
           _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering "
-                                     "user code with ip=0x%llX, sp=0x%llX",
+                                     "user code with ip=0x%" PRIX64 ", sp=0x%" PRIX64 "",
                                      static_cast<void *>(exception_object),
-                                     (long long)pc, (long long)sp);
+                                     pc, sp);
         }
 
         {
@@ -727,8 +728,8 @@
   if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
     result = (uintptr_t)frameInfo.lsda;
   _LIBUNWIND_TRACE_API(
-      "_Unwind_GetLanguageSpecificData(context=%p) => 0x%llx",
-      static_cast<void *>(context), (long long)result);
+      "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIx64 "",
+      static_cast<void *>(context), result);
   return result;
 }
 
@@ -765,7 +766,7 @@
       if (representation != _UVRSD_UINT32 || regno > 15)
         return _UVRSR_FAILED;
       return unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),
-                         *(unw_word_t *)valuep) == UNW_ESUCCESS
+                         *(uintptr_t *)valuep) == UNW_ESUCCESS
                  ? _UVRSR_OK
                  : _UVRSR_FAILED;
     case _UVRSC_VFP:
@@ -789,7 +790,7 @@
       if (representation != _UVRSD_UINT32 || regno > 3)
         return _UVRSR_FAILED;
       return unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
-                         *(unw_word_t *)valuep) == UNW_ESUCCESS
+                         *(uintptr_t *)valuep) == UNW_ESUCCESS
                  ? _UVRSR_OK
                  : _UVRSR_FAILED;
     case _UVRSC_WMMXD:
@@ -814,14 +815,18 @@
                          _Unwind_VRS_DataRepresentation representation,
                          void *valuep) {
   unw_cursor_t *cursor = (unw_cursor_t *)context;
+  unw_word_t word;
+  _Unwind_VRS_Result ret;
   switch (regclass) {
     case _UVRSC_CORE:
       if (representation != _UVRSD_UINT32 || regno > 15)
         return _UVRSR_FAILED;
-      return unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),
-                         (unw_word_t *)valuep) == UNW_ESUCCESS
+      ret = unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),
+                         &word) == UNW_ESUCCESS
                  ? _UVRSR_OK
                  : _UVRSR_FAILED;
+      *(uintptr_t *)valuep = word;
+      return ret;
     case _UVRSC_VFP:
       if (representation != _UVRSD_VFPX && representation != _UVRSD_DOUBLE)
         return _UVRSR_FAILED;
@@ -842,10 +847,12 @@
     case _UVRSC_WMMXC:
       if (representation != _UVRSD_UINT32 || regno > 3)
         return _UVRSR_FAILED;
-      return unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
-                         (unw_word_t *)valuep) == UNW_ESUCCESS
+      ret = unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
+                         &word) == UNW_ESUCCESS
                  ? _UVRSR_OK
                  : _UVRSR_FAILED;
+      *(uintptr_t *)valuep = word;
+      return ret;
     case _UVRSC_WMMXD:
       if (representation != _UVRSD_DOUBLE || regno > 31)
         return _UVRSR_FAILED;
@@ -961,8 +968,8 @@
   uintptr_t result = 0;
   if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
     result = (uintptr_t)frameInfo.start_ip;
-  _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%llX",
-                       static_cast<void *>(context), (long long)result);
+  _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIX64 "",
+                       static_cast<void *>(context), result);
   return result;
 }
 
Index: include/libunwind.h
===================================================================
--- include/libunwind.h
+++ include/libunwind.h
@@ -72,11 +72,10 @@
 typedef struct unw_addr_space *unw_addr_space_t;
 
 typedef int unw_regnum_t;
+typedef uint64_t unw_word_t;
 #if defined(_LIBUNWIND_ARM_EHABI)
-typedef uint32_t unw_word_t;
 typedef uint64_t unw_fpreg_t;
 #else
-typedef uint64_t unw_word_t;
 typedef double unw_fpreg_t;
 #endif
 
Index: include/__libunwind_config.h
===================================================================
--- include/__libunwind_config.h
+++ include/__libunwind_config.h
@@ -40,10 +40,10 @@
 #  define _LIBUNWIND_TARGET_ARM 1
 #  if defined(__ARM_WMMX)
 #    define _LIBUNWIND_CONTEXT_SIZE 61
-#    define _LIBUNWIND_CURSOR_SIZE 68
+#    define _LIBUNWIND_CURSOR_SIZE 72
 #  else
 #    define _LIBUNWIND_CONTEXT_SIZE 42
-#    define _LIBUNWIND_CURSOR_SIZE 49
+#    define _LIBUNWIND_CURSOR_SIZE 53
 #  endif
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 96
 # elif defined(__or1k__)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to