Fix detection of unw_set_cache_size and adapt to upstream changes
authorMilian Wolff <mail@milianw.de>
Sat, 28 Jan 2017 21:49:09 +0000 (22:49 +0100)
committerMilian Wolff <mail@milianw.de>
Sat, 28 Jan 2017 21:51:09 +0000 (22:51 +0100)
unw_set_cache_size is actually a define so we can detect it directly
in C++ without the need for CMake to detect it for us. Using the
define also makes sure we can detect it once for all platforms, the
symbol is mangled by libunwind to support multiple architectures.

cmake/FindLibunwind.cmake
src/track/libheaptrack.cpp
src/util/libunwind_config.h.cmake

index a6d8844..aacf27b 100644 (file)
@@ -15,7 +15,6 @@
 #   LIBUNWIND_HAS_UNW_INIT_LOCAL        - True if unw_init_local() is found (optional).
 #   LIBUNWIND_HAS_UNW_BACKTRACE         - True if unw_backtrace() is found (required).
 #   LIBUNWIND_HAS_UNW_BACKTRACE_SKIP    - True if unw_backtrace_skip() is found (optional).
-#   LIBUNWIND_HAS_UNW_SET_CACHE_SIZE    - True if unw_set_cache_size() is found (optional).
 #   LIBUNWIND_VERSION_STRING            - version number as a string (ex: "5.0.3")
 
 #=============================================================================
@@ -63,8 +62,6 @@ if (LIBUNWIND_LIBRARY)
   check_library_exists(${LIBUNWIND_LIBRARY} unw_init_local "" LIBUNWIND_HAS_UNW_INIT_LOCAL)
   check_library_exists(${LIBUNWIND_LIBRARY} unw_backtrace "" LIBUNWIND_HAS_UNW_BACKTRACE)
   check_library_exists (${LIBUNWIND_LIBRARY} unw_backtrace_skip "" LIBUNWIND_HAS_UNW_BACKTRACE_SKIP)
-  # TODO: find the symbol name on 32bit/arm platforms
-  check_library_exists (${LIBUNWIND_LIBRARY} _ULx86_64_set_cache_size "" LIBUNWIND_HAS_UNW_SET_CACHE_SIZE)
   set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
 endif ()
 
index 077b303..e7ea91b 100644 (file)
@@ -230,8 +230,8 @@ public:
             if (unw_set_caching_policy(unw_local_addr_space, UNW_CACHE_PER_THREAD)) {
                 fprintf(stderr, "WARNING: Failed to enable per-thread libunwind caching.\n");
             }
-            #if LIBUNWIND_HAS_UNW_SET_CACHE_SIZE
-            if (unw_set_cache_size(unw_local_addr_space, 1024)) {
+            #ifdef unw_set_cache_size
+            if (unw_set_cache_size(unw_local_addr_space, 1024, 0)) {
                 fprintf(stderr, "WARNING: Failed to set libunwind cache size.\n");
             }
             #endif
index ed0e681..57fc90a 100644 (file)
@@ -20,8 +20,6 @@
 #ifndef LIBUNWIND_CONFIG_H
 #define LIBUNWIND_CONFIG_H
 
-#cmakedefine01 LIBUNWIND_HAS_UNW_SET_CACHE_SIZE
-
 #cmakedefine01 LIBUNWIND_HAS_UNW_BACKTRACE
 
 #cmakedefine01 LIBUNWIND_HAS_UNW_BACKTRACE_SKIP