backtrace.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include <util/generic/fwd.h>
  3. #include <util/system/defaults.h>
  4. class IOutputStream;
  5. size_t BackTrace(void** p, size_t len);
  6. struct TResolvedSymbol {
  7. const char* Name;
  8. void* NearestSymbol;
  9. };
  10. TResolvedSymbol ResolveSymbol(void* sym, char* buf, size_t len);
  11. void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtraceSize);
  12. void FormatBackTrace(IOutputStream* out);
  13. void PrintBackTrace();
  14. using TFormatBackTraceFn = void (*)(IOutputStream*, void* const* backtrace, size_t backtraceSize);
  15. TFormatBackTraceFn SetFormatBackTraceFn(TFormatBackTraceFn f);
  16. TFormatBackTraceFn GetFormatBackTraceFn();
  17. using TBackTraceView = TArrayRef<void* const>;
  18. class TBackTrace {
  19. private:
  20. static constexpr size_t CAPACITY = 300;
  21. void* Data[CAPACITY];
  22. size_t Size;
  23. public:
  24. TBackTrace();
  25. void Capture();
  26. void PrintTo(IOutputStream&) const;
  27. TString PrintToString() const;
  28. size_t size() const;
  29. const void* const* data() const;
  30. operator TBackTraceView() const;
  31. static TBackTrace FromCurrentException();
  32. };