Backtrace.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #ifndef C10_UTIL_BACKTRACE_H_
  3. #define C10_UTIL_BACKTRACE_H_
  4. #include <cstddef>
  5. #include <memory>
  6. #include <string>
  7. #include <typeinfo>
  8. #include <c10/macros/Macros.h>
  9. #include <c10/util/Lazy.h>
  10. namespace c10 {
  11. // Symbolizing the backtrace can be expensive; pass it around as a lazy string
  12. // so it is symbolized only if actually needed.
  13. using Backtrace = std::shared_ptr<const LazyValue<std::string>>;
  14. // DEPRECATED: Prefer get_lazy_backtrace().
  15. C10_API std::string get_backtrace(
  16. size_t frames_to_skip = 0,
  17. size_t maximum_number_of_frames = 64,
  18. bool skip_python_frames = true);
  19. C10_API Backtrace get_lazy_backtrace(
  20. size_t frames_to_skip = 0,
  21. size_t maximum_number_of_frames = 64,
  22. bool skip_python_frames = true);
  23. } // namespace c10
  24. #endif // C10_UTIL_BACKTRACE_H_
  25. #else
  26. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  27. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)