stacktrace_config.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. * Defines ABSL_STACKTRACE_INL_HEADER to the *-inl.h containing
  16. * actual unwinder implementation.
  17. * This header is "private" to stacktrace.cc.
  18. * DO NOT include it into any other files.
  19. */
  20. #ifndef ABSL_DEBUGGING_INTERNAL_STACKTRACE_CONFIG_H_
  21. #define ABSL_DEBUGGING_INTERNAL_STACKTRACE_CONFIG_H_
  22. #include "absl/base/config.h"
  23. #if defined(ABSL_STACKTRACE_INL_HEADER)
  24. #error ABSL_STACKTRACE_INL_HEADER cannot be directly set
  25. #elif defined(_WIN32)
  26. #define ABSL_STACKTRACE_INL_HEADER \
  27. "absl/debugging/internal/stacktrace_win32-inl.inc"
  28. #elif defined(__APPLE__)
  29. #ifdef ABSL_HAVE_THREAD_LOCAL
  30. // Thread local support required for UnwindImpl.
  31. #define ABSL_STACKTRACE_INL_HEADER \
  32. "absl/debugging/internal/stacktrace_generic-inl.inc"
  33. #endif // defined(ABSL_HAVE_THREAD_LOCAL)
  34. // Emscripten stacktraces rely on JS. Do not use them in standalone mode.
  35. #elif defined(__EMSCRIPTEN__) && !defined(STANDALONE_WASM)
  36. #define ABSL_STACKTRACE_INL_HEADER \
  37. "absl/debugging/internal/stacktrace_emscripten-inl.inc"
  38. #elif defined(__ANDROID__) && __ANDROID_API__ >= 33
  39. // Use the generic implementation for Android 33+ (Android T+). This is the
  40. // first version of Android for which <execinfo.h> implements backtrace().
  41. #define ABSL_STACKTRACE_INL_HEADER \
  42. "absl/debugging/internal/stacktrace_generic-inl.inc"
  43. #elif defined(__linux__) && !defined(__ANDROID__)
  44. #if defined(NO_FRAME_POINTER) && \
  45. (defined(__i386__) || defined(__x86_64__) || defined(__aarch64__))
  46. // Note: The libunwind-based implementation is not available to open-source
  47. // users.
  48. #define ABSL_STACKTRACE_INL_HEADER \
  49. "absl/debugging/internal/stacktrace_libunwind-inl.inc"
  50. #define STACKTRACE_USES_LIBUNWIND 1
  51. #elif defined(NO_FRAME_POINTER) && defined(__has_include)
  52. #if __has_include(<execinfo.h>)
  53. // Note: When using glibc this may require -funwind-tables to function properly.
  54. #define ABSL_STACKTRACE_INL_HEADER \
  55. "absl/debugging/internal/stacktrace_generic-inl.inc"
  56. #endif // __has_include(<execinfo.h>)
  57. #elif defined(__i386__) || defined(__x86_64__)
  58. #define ABSL_STACKTRACE_INL_HEADER \
  59. "absl/debugging/internal/stacktrace_x86-inl.inc"
  60. #elif defined(__ppc__) || defined(__PPC__)
  61. #define ABSL_STACKTRACE_INL_HEADER \
  62. "absl/debugging/internal/stacktrace_powerpc-inl.inc"
  63. #elif defined(__aarch64__)
  64. #define ABSL_STACKTRACE_INL_HEADER \
  65. "absl/debugging/internal/stacktrace_aarch64-inl.inc"
  66. #elif defined(__riscv)
  67. #define ABSL_STACKTRACE_INL_HEADER \
  68. "absl/debugging/internal/stacktrace_riscv-inl.inc"
  69. #elif defined(__has_include)
  70. #if __has_include(<execinfo.h>)
  71. // Note: When using glibc this may require -funwind-tables to function properly.
  72. #define ABSL_STACKTRACE_INL_HEADER \
  73. "absl/debugging/internal/stacktrace_generic-inl.inc"
  74. #endif // __has_include(<execinfo.h>)
  75. #endif // defined(__has_include)
  76. #endif // defined(__linux__) && !defined(__ANDROID__)
  77. // Fallback to the empty implementation.
  78. #if !defined(ABSL_STACKTRACE_INL_HEADER)
  79. #define ABSL_STACKTRACE_INL_HEADER \
  80. "absl/debugging/internal/stacktrace_unimplemented-inl.inc"
  81. #endif
  82. #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_CONFIG_H_