backtrace.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include <library/cpp/yt/memory/range.h>
  3. namespace NYT::NBacktrace {
  4. ////////////////////////////////////////////////////////////////////////////////
  5. using TBacktrace = TRange<const void*>;
  6. using TBacktraceBuffer = TMutableRange<const void*>;
  7. //! Obtains a backtrace via a given cursor.
  8. /*!
  9. * \param buffer is the buffer where the backtrace is written to
  10. * \param framesToSkip is the number of top frames to skip
  11. * \returns the portion of #buffer that has actually been filled
  12. */
  13. template <class TCursor>
  14. TBacktrace GetBacktrace(
  15. TCursor* cursor,
  16. TBacktraceBuffer buffer,
  17. int framesToSkip);
  18. //! Symbolizes a backtrace invoking a given callback for each frame.
  19. /*!
  20. * \param backtrace Backtrace to symbolize
  21. * \param frameCallback Callback to invoke per each frame
  22. */
  23. void SymbolizeBacktrace(
  24. TBacktrace backtrace,
  25. const std::function<void(TStringBuf)>& frameCallback);
  26. //! Symbolizes a backtrace to a string.
  27. /*!
  28. * \param backtrace Backtrace to symbolize
  29. */
  30. TString SymbolizeBacktrace(TBacktrace backtrace);
  31. ////////////////////////////////////////////////////////////////////////////////
  32. } // namespace NYT::NBacktrace
  33. #define BACKTRACE_INL_H_
  34. #include "backtrace-inl.h"
  35. #undef BACKTRACE_INL_H_