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