]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/DataFormatters/FormatCache.h
MFV r324198: 8081 Compiler warnings in zdb
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / DataFormatters / FormatCache.h
1 //===-- FormatCache.h ---------------------------------------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef lldb_FormatCache_h_
12 #define lldb_FormatCache_h_
13
14 // C Includes
15 // C++ Includes
16 #include <map>
17 #include <mutex>
18
19 // Other libraries and framework includes
20 // Project includes
21 #include "lldb/Utility/ConstString.h"
22 #include "lldb/lldb-public.h"
23
24 namespace lldb_private {
25 class FormatCache {
26 private:
27   struct Entry {
28   private:
29     bool m_format_cached : 1;
30     bool m_summary_cached : 1;
31     bool m_synthetic_cached : 1;
32     bool m_validator_cached : 1;
33
34     lldb::TypeFormatImplSP m_format_sp;
35     lldb::TypeSummaryImplSP m_summary_sp;
36     lldb::SyntheticChildrenSP m_synthetic_sp;
37     lldb::TypeValidatorImplSP m_validator_sp;
38
39   public:
40     Entry();
41     Entry(lldb::TypeFormatImplSP);
42     Entry(lldb::TypeSummaryImplSP);
43     Entry(lldb::SyntheticChildrenSP);
44     Entry(lldb::TypeValidatorImplSP);
45     Entry(lldb::TypeFormatImplSP, lldb::TypeSummaryImplSP,
46           lldb::SyntheticChildrenSP, lldb::TypeValidatorImplSP);
47
48     bool IsFormatCached();
49
50     bool IsSummaryCached();
51
52     bool IsSyntheticCached();
53
54     bool IsValidatorCached();
55
56     lldb::TypeFormatImplSP GetFormat();
57
58     lldb::TypeSummaryImplSP GetSummary();
59
60     lldb::SyntheticChildrenSP GetSynthetic();
61
62     lldb::TypeValidatorImplSP GetValidator();
63
64     void SetFormat(lldb::TypeFormatImplSP);
65
66     void SetSummary(lldb::TypeSummaryImplSP);
67
68     void SetSynthetic(lldb::SyntheticChildrenSP);
69
70     void SetValidator(lldb::TypeValidatorImplSP);
71   };
72   typedef std::map<ConstString, Entry> CacheMap;
73   CacheMap m_map;
74   std::recursive_mutex m_mutex;
75
76   uint64_t m_cache_hits;
77   uint64_t m_cache_misses;
78
79   Entry &GetEntry(const ConstString &type);
80
81 public:
82   FormatCache();
83
84   bool GetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
85
86   bool GetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
87
88   bool GetSynthetic(const ConstString &type,
89                     lldb::SyntheticChildrenSP &synthetic_sp);
90
91   bool GetValidator(const ConstString &type,
92                     lldb::TypeValidatorImplSP &summary_sp);
93
94   void SetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
95
96   void SetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
97
98   void SetSynthetic(const ConstString &type,
99                     lldb::SyntheticChildrenSP &synthetic_sp);
100
101   void SetValidator(const ConstString &type,
102                     lldb::TypeValidatorImplSP &synthetic_sp);
103
104   void Clear();
105
106   uint64_t GetCacheHits() { return m_cache_hits; }
107
108   uint64_t GetCacheMisses() { return m_cache_misses; }
109 };
110 } // namespace lldb_private
111
112 #endif // lldb_FormatCache_h_