stacktrace_config.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 Y_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 Y_ABSL_DEBUGGING_INTERNAL_STACKTRACE_CONFIG_H_
  21. #define Y_ABSL_DEBUGGING_INTERNAL_STACKTRACE_CONFIG_H_
  22. #include "y_absl/base/config.h"
  23. #if defined(Y_ABSL_STACKTRACE_INL_HEADER)
  24. #error Y_ABSL_STACKTRACE_INL_HEADER cannot be directly set
  25. #elif defined(_WIN32)
  26. #define Y_ABSL_STACKTRACE_INL_HEADER \
  27. "y_absl/debugging/internal/stacktrace_win32-inl.inc"
  28. #elif defined(__APPLE__)
  29. #ifdef Y_ABSL_HAVE_THREAD_LOCAL
  30. // Thread local support required for UnwindImpl.
  31. #define Y_ABSL_STACKTRACE_INL_HEADER \
  32. "y_absl/debugging/internal/stacktrace_generic-inl.inc"
  33. #endif // defined(Y_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 Y_ABSL_STACKTRACE_INL_HEADER \
  37. "y_absl/debugging/internal/stacktrace_emscripten-inl.inc"
  38. #elif defined(__linux__) && !defined(__ANDROID__)
  39. #if defined(NO_FRAME_POINTER) && \
  40. (defined(__i386__) || defined(__x86_64__) || defined(__aarch64__))
  41. // Note: The libunwind-based implementation is not available to open-source
  42. // users.
  43. #define Y_ABSL_STACKTRACE_INL_HEADER \
  44. "y_absl/debugging/internal/stacktrace_libunwind-inl.inc"
  45. #define STACKTRACE_USES_LIBUNWIND 1
  46. #elif defined(NO_FRAME_POINTER) && defined(__has_include)
  47. #if __has_include(<execinfo.h>)
  48. // Note: When using glibc this may require -funwind-tables to function properly.
  49. #define Y_ABSL_STACKTRACE_INL_HEADER \
  50. "y_absl/debugging/internal/stacktrace_generic-inl.inc"
  51. #endif // __has_include(<execinfo.h>)
  52. #elif defined(__i386__) || defined(__x86_64__)
  53. #define Y_ABSL_STACKTRACE_INL_HEADER \
  54. "y_absl/debugging/internal/stacktrace_x86-inl.inc"
  55. #elif defined(__ppc__) || defined(__PPC__)
  56. #define Y_ABSL_STACKTRACE_INL_HEADER \
  57. "y_absl/debugging/internal/stacktrace_powerpc-inl.inc"
  58. #elif defined(__aarch64__)
  59. #define Y_ABSL_STACKTRACE_INL_HEADER \
  60. "y_absl/debugging/internal/stacktrace_aarch64-inl.inc"
  61. #elif defined(__riscv)
  62. #define Y_ABSL_STACKTRACE_INL_HEADER \
  63. "y_absl/debugging/internal/stacktrace_riscv-inl.inc"
  64. #elif defined(__has_include)
  65. #if __has_include(<execinfo.h>)
  66. // Note: When using glibc this may require -funwind-tables to function properly.
  67. #define Y_ABSL_STACKTRACE_INL_HEADER \
  68. "y_absl/debugging/internal/stacktrace_generic-inl.inc"
  69. #endif // __has_include(<execinfo.h>)
  70. #endif // defined(__has_include)
  71. #endif // defined(__linux__) && !defined(__ANDROID__)
  72. // Fallback to the empty implementation.
  73. #if !defined(Y_ABSL_STACKTRACE_INL_HEADER)
  74. #define Y_ABSL_STACKTRACE_INL_HEADER \
  75. "y_absl/debugging/internal/stacktrace_unimplemented-inl.inc"
  76. #endif
  77. #endif // Y_ABSL_DEBUGGING_INTERNAL_STACKTRACE_CONFIG_H_