memprof_descriptions.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //===-- memprof_descriptions.h ---------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file is a part of MemProfiler, a memory profiler.
  10. //
  11. // MemProf-private header for memprof_descriptions.cpp.
  12. //===----------------------------------------------------------------------===//
  13. #ifndef MEMPROF_DESCRIPTIONS_H
  14. #define MEMPROF_DESCRIPTIONS_H
  15. #include "memprof_allocator.h"
  16. #include "memprof_thread.h"
  17. #include "sanitizer_common/sanitizer_common.h"
  18. #include "sanitizer_common/sanitizer_report_decorator.h"
  19. namespace __memprof {
  20. void DescribeThread(MemprofThreadContext *context);
  21. inline void DescribeThread(MemprofThread *t) {
  22. if (t)
  23. DescribeThread(t->context());
  24. }
  25. class MemprofThreadIdAndName {
  26. public:
  27. explicit MemprofThreadIdAndName(MemprofThreadContext *t);
  28. explicit MemprofThreadIdAndName(u32 tid);
  29. // Contains "T%tid (%name)" or "T%tid" if the name is empty.
  30. const char *c_str() const { return &name[0]; }
  31. private:
  32. void Init(u32 tid, const char *tname);
  33. char name[128];
  34. };
  35. } // namespace __memprof
  36. #endif // MEMPROF_DESCRIPTIONS_H