diff --git a/config.h.meson b/config.h.meson index bb24e00d..d2f7589a 100644 --- a/config.h.meson +++ b/config.h.meson @@ -14,8 +14,6 @@ #mesondefine GETTEXT_PACKAGE -#mesondefine HAVE_EXECINFO_H - #mesondefine HAVE_LIBSYSTEMD #mesondefine HAVE_PERF_CLOCKID diff --git a/meson.build b/meson.build index 3334f210..a1fcf0ea 100644 --- a/meson.build +++ b/meson.build @@ -92,7 +92,6 @@ if get_option('default_library') != 'static' endif endif -config_h.set('HAVE_EXECINFO_H', cc.has_header('execinfo.h')) config_h.set('HAVE_REALLOCARRAY', cc.has_function('reallocarray')) config_h.set('HAVE_STRLCPY', cc.has_function('strlcpy')) config_h.set('LOCALEDIR', 'PACKAGE_LOCALE_DIR') @@ -107,16 +106,13 @@ config_h.set10('HAVE_POLKIT_AGENT', polkit_agent_dep.found()) polkit_dep = dependency('polkit-gobject-1', version: polkit_req_version, required: false) config_h.set10('HAVE_POLKIT', polkit_dep.found()) -if get_option('libunwind') - # Force libunwind usage if it's specified to avoid back compiles - # and backtrace() showing up in builds +if get_option('libsysprof') libunwind_dep = dependency('libunwind-generic', required: true) config_h.set('ENABLE_LIBUNWIND', libunwind_dep.found()) config_h.set('HAVE_UNW_SET_CACHE_SIZE', - (libunwind_dep.found() and - cc.has_header_symbol('libunwind.h', - 'unw_set_cache_size', - dependencies: [libunwind_dep]))) + cc.has_header_symbol('libunwind.h', + 'unw_set_cache_size', + dependencies: [libunwind_dep])) endif # Development build setup diff --git a/meson_options.txt b/meson_options.txt index 970022f2..6abda003 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -29,9 +29,6 @@ option('systemdunitdir', type: 'string', # If Yelp documentation should be installed option('help', type: 'boolean') -# Disable use of libunwind -option('libunwind', type: 'boolean') - # Build libsysprof (required by tools, tests, sysprof, etc) option('libsysprof', type: 'boolean') diff --git a/src/preload/backtrace-helper.h b/src/preload/backtrace-helper.h index 88dc194c..43a36175 100644 --- a/src/preload/backtrace-helper.h +++ b/src/preload/backtrace-helper.h @@ -20,23 +20,16 @@ #pragma once -#ifdef HAVE_EXECINFO_H -# include -#endif -#ifdef ENABLE_LIBUNWIND -# define UNW_LOCAL_ONLY -# include -#endif +#define UNW_LOCAL_ONLY +#include static void backtrace_init (void) { -#ifdef ENABLE_LIBUNWIND unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_PER_THREAD); -# ifdef HAVE_UNW_SET_CACHE_SIZE +#ifdef HAVE_UNW_SET_CACHE_SIZE unw_set_cache_size (unw_local_addr_space, 1024, 0); #endif -#endif } static int @@ -44,36 +37,20 @@ backtrace_func (SysprofCaptureAddress *addrs, guint n_addrs, G_GNUC_UNUSED gpointer user_data) { -#if defined(ENABLE_LIBUNWIND) -# if GLIB_SIZEOF_VOID_P == 8 +#if GLIB_SIZEOF_VOID_P == 8 /* We know that collector will overwrite fields *AFTER* it * has called the backtrace function allowing us to cheat * and subtract an offset from addrs to avoid having to * copy frame pointers around. */ return unw_backtrace ((void **)addrs - 2, n_addrs) - 2; -# else +#else static const int skip = 2; void **stack = alloca (n_addrs * sizeof (gpointer)); int n = unw_backtrace (stack, n_addrs); for (guint i = skip; i < n; i++) addrs[i-skip] = GPOINTER_TO_SIZE (stack[i]); return MAX (0, n - skip); -# endif -#elif defined(HAVE_EXECINFO_H) -# if GLIB_SIZEOF_VOID_P == 8 - /* See note on unw_backtrace() */ - return backtrace ((void **)addrs - 2, n_addrs) - 2; -# else /* GLIB_SIZEOF_VOID_P != 8 */ - static const int skip = 2; - void **stack = alloca (n_addrs * sizeof (gpointer)); - int n = backtrace (stack, n_addrs); - for (guint i = skip; i < n; i++) - addrs[i-skip] = GPOINTER_TO_SIZE (stack[i]); - return MAX (0, n - skip); -# endif /* GLIB_SIZEOF_VOID_P */ -#else - return 0; #endif } diff --git a/src/preload/meson.build b/src/preload/meson.build index 602bb531..31662ada 100644 --- a/src/preload/meson.build +++ b/src/preload/meson.build @@ -3,14 +3,10 @@ libdl_dep = dependency('dl', required: false) preload_deps = [ dependency('glib-2.0'), libsysprof_capture_dep, + libunwind_dep, libdl_dep, ] -if get_option('libunwind') - preload_deps += [libunwind_dep] -endif - - libsysprof_memory_preload = shared_library('sysprof-memory-@0@'.format(libsysprof_api_version), ['sysprof-memory-collector.c'], dependencies: preload_deps,