LLDB  mainline
FormatCache.h
Go to the documentation of this file.
1 //===-- FormatCache.h ---------------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef lldb_FormatCache_h_
11 #define lldb_FormatCache_h_
12 
13 #include <map>
14 #include <mutex>
15 
17 #include "lldb/lldb-public.h"
18 
19 namespace lldb_private {
20 class FormatCache {
21 private:
22  struct Entry {
23  private:
24  bool m_format_cached : 1;
25  bool m_summary_cached : 1;
26  bool m_synthetic_cached : 1;
27  bool m_validator_cached : 1;
28 
29  lldb::TypeFormatImplSP m_format_sp;
30  lldb::TypeSummaryImplSP m_summary_sp;
31  lldb::SyntheticChildrenSP m_synthetic_sp;
32  lldb::TypeValidatorImplSP m_validator_sp;
33 
34  public:
35  Entry();
36  Entry(lldb::TypeFormatImplSP);
37  Entry(lldb::TypeSummaryImplSP);
38  Entry(lldb::SyntheticChildrenSP);
39  Entry(lldb::TypeValidatorImplSP);
40  Entry(lldb::TypeFormatImplSP, lldb::TypeSummaryImplSP,
41  lldb::SyntheticChildrenSP, lldb::TypeValidatorImplSP);
42 
43  bool IsFormatCached();
44 
45  bool IsSummaryCached();
46 
47  bool IsSyntheticCached();
48 
49  bool IsValidatorCached();
50 
51  lldb::TypeFormatImplSP GetFormat();
52 
53  lldb::TypeSummaryImplSP GetSummary();
54 
55  lldb::SyntheticChildrenSP GetSynthetic();
56 
57  lldb::TypeValidatorImplSP GetValidator();
58 
59  void SetFormat(lldb::TypeFormatImplSP);
60 
61  void SetSummary(lldb::TypeSummaryImplSP);
62 
63  void SetSynthetic(lldb::SyntheticChildrenSP);
64 
65  void SetValidator(lldb::TypeValidatorImplSP);
66  };
67  typedef std::map<ConstString, Entry> CacheMap;
68  CacheMap m_map;
69  std::recursive_mutex m_mutex;
70 
71  uint64_t m_cache_hits;
72  uint64_t m_cache_misses;
73 
74  Entry &GetEntry(ConstString type);
75 
76 public:
77  FormatCache();
78 
79  bool GetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp);
80 
81  bool GetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
82 
83  bool GetSynthetic(ConstString type,
84  lldb::SyntheticChildrenSP &synthetic_sp);
85 
86  bool GetValidator(ConstString type,
87  lldb::TypeValidatorImplSP &summary_sp);
88 
89  void SetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp);
90 
91  void SetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
92 
93  void SetSynthetic(ConstString type,
94  lldb::SyntheticChildrenSP &synthetic_sp);
95 
96  void SetValidator(ConstString type,
97  lldb::TypeValidatorImplSP &synthetic_sp);
98 
99  void Clear();
100 
101  uint64_t GetCacheHits() { return m_cache_hits; }
102 
103  uint64_t GetCacheMisses() { return m_cache_misses; }
104 };
105 } // namespace lldb_private
106 
107 #endif // lldb_FormatCache_h_
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
void SetValidator(ConstString type, lldb::TypeValidatorImplSP &synthetic_sp)
bool GetSynthetic(ConstString type, lldb::SyntheticChildrenSP &synthetic_sp)
bool GetValidator(ConstString type, lldb::TypeValidatorImplSP &summary_sp)
bool GetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp)
void SetSynthetic(ConstString type, lldb::SyntheticChildrenSP &synthetic_sp)
void SetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp)
A uniqued constant string class.
Definition: ConstString.h:38
void SetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp)
bool GetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp)