stacktrace_config.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #elif defined(__EMSCRIPTEN__)
  35. #define ABSL_STACKTRACE_INL_HEADER \
  36. "absl/debugging/internal/stacktrace_emscripten-inl.inc"
  37. #elif defined(__linux__) && !defined(__ANDROID__)
  38. #if defined(NO_FRAME_POINTER) && \
  39. (defined(__i386__) || defined(__x86_64__) || defined(__aarch64__))
  40. // Note: The libunwind-based implementation is not available to open-source
  41. // users.
  42. #define ABSL_STACKTRACE_INL_HEADER \
  43. "absl/debugging/internal/stacktrace_libunwind-inl.inc"
  44. #define STACKTRACE_USES_LIBUNWIND 1
  45. #elif defined(NO_FRAME_POINTER) && defined(__has_include)
  46. #if __has_include(<execinfo.h>)
  47. // Note: When using glibc this may require -funwind-tables to function properly.
  48. #define ABSL_STACKTRACE_INL_HEADER \
  49. "absl/debugging/internal/stacktrace_generic-inl.inc"
  50. #endif // __has_include(<execinfo.h>)
  51. #elif defined(__i386__) || defined(__x86_64__)
  52. #define ABSL_STACKTRACE_INL_HEADER \
  53. "absl/debugging/internal/stacktrace_x86-inl.inc"
  54. #elif defined(__ppc__) || defined(__PPC__)
  55. #define ABSL_STACKTRACE_INL_HEADER \
  56. "absl/debugging/internal/stacktrace_powerpc-inl.inc"
  57. #elif defined(__aarch64__)
  58. #define ABSL_STACKTRACE_INL_HEADER \
  59. "absl/debugging/internal/stacktrace_aarch64-inl.inc"
  60. #elif defined(__riscv)
  61. #define ABSL_STACKTRACE_INL_HEADER \
  62. "absl/debugging/internal/stacktrace_riscv-inl.inc"
  63. #elif defined(__has_include)
  64. #if __has_include(<execinfo.h>)
  65. // Note: When using glibc this may require -funwind-tables to function properly.
  66. #define ABSL_STACKTRACE_INL_HEADER \
  67. "absl/debugging/internal/stacktrace_generic-inl.inc"
  68. #endif // __has_include(<execinfo.h>)
  69. #endif // defined(__has_include)
  70. #endif // defined(__linux__) && !defined(__ANDROID__)
  71. // Fallback to the empty implementation.
  72. #if !defined(ABSL_STACKTRACE_INL_HEADER)
  73. #define ABSL_STACKTRACE_INL_HEADER \
  74. "absl/debugging/internal/stacktrace_unimplemented-inl.inc"
  75. #endif
  76. #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_CONFIG_H_