1 /* 2 * Copyright 2017 The Abseil Authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 16 * Defines ABSL_STACKTRACE_INL_HEADER to the *-inl.h containing 17 * actual unwinder implementation. 18 * This header is "private" to stacktrace.cc. 19 * DO NOT include it into any other files. 20 */ 21 #ifndef ABSL_DEBUGGING_INTERNAL_STACKTRACE_CONFIG_H_ 22 #define ABSL_DEBUGGING_INTERNAL_STACKTRACE_CONFIG_H_ 23 24 #if defined(ABSL_STACKTRACE_INL_HEADER) 25 #error ABSL_STACKTRACE_INL_HEADER cannot be directly set 26 27 #elif defined(_WIN32) 28 #define ABSL_STACKTRACE_INL_HEADER \ 29 "absl/debugging/internal/stacktrace_win32-inl.inc" 30 31 #elif defined(__APPLE__) 32 // Thread local support required for UnwindImpl. 33 // Notes: 34 // * Xcode's clang did not support `thread_local` until version 8, and 35 // even then not for all iOS < 9.0. 36 // * Xcode 9.3 started disallowing `thread_local` for 32-bit iOS simulator 37 // targeting iOS 9.x. 38 // * Xcode 10 moves the deployment target check for iOS < 9.0 to link time 39 // making __has_feature unreliable there. 40 // 41 // Otherwise, `__has_feature` is only supported by Clang so it has be inside 42 // `defined(__APPLE__)` check. 43 #if __has_feature(cxx_thread_local) && \ 44 !(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0) 45 #define ABSL_STACKTRACE_INL_HEADER \ 46 "absl/debugging/internal/stacktrace_generic-inl.inc" 47 #endif 48 49 #elif defined(__linux__) && !defined(__ANDROID__) 50 51 #if defined(NO_FRAME_POINTER) && \ 52 (defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)) 53 // Note: The libunwind-based implementation is not available to open-source 54 // users. 55 #define ABSL_STACKTRACE_INL_HEADER \ 56 "absl/debugging/internal/stacktrace_libunwind-inl.inc" 57 #define STACKTRACE_USES_LIBUNWIND 1 58 #elif defined(NO_FRAME_POINTER) && defined(__has_include) 59 #if __has_include(<execinfo.h>) 60 // Note: When using glibc this may require -funwind-tables to function properly. 61 #define ABSL_STACKTRACE_INL_HEADER \ 62 "absl/debugging/internal/stacktrace_generic-inl.inc" 63 #endif 64 #elif defined(__i386__) || defined(__x86_64__) 65 #define ABSL_STACKTRACE_INL_HEADER \ 66 "absl/debugging/internal/stacktrace_x86-inl.inc" 67 #elif defined(__ppc__) || defined(__PPC__) 68 #define ABSL_STACKTRACE_INL_HEADER \ 69 "absl/debugging/internal/stacktrace_powerpc-inl.inc" 70 #elif defined(__aarch64__) 71 #define ABSL_STACKTRACE_INL_HEADER \ 72 "absl/debugging/internal/stacktrace_aarch64-inl.inc" 73 #elif defined(__has_include) 74 #if __has_include(<execinfo.h>) 75 // Note: When using glibc this may require -funwind-tables to function properly. 76 #define ABSL_STACKTRACE_INL_HEADER \ 77 "absl/debugging/internal/stacktrace_generic-inl.inc" 78 #endif 79 #endif 80 81 #endif 82 83 // Fallback to the empty implementation. 84 #if !defined(ABSL_STACKTRACE_INL_HEADER) 85 #define ABSL_STACKTRACE_INL_HEADER \ 86 "absl/debugging/internal/stacktrace_unimplemented-inl.inc" 87 #endif 88 89 #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_CONFIG_H_ 90