1 //===-- FormatCache.h ---------------------------------------------*- C++
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
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_FormatCache_h_
11 #define lldb_FormatCache_h_
16 #include "lldb/Utility/ConstString.h"
17 #include "lldb/lldb-public.h"
19 namespace lldb_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;
29 lldb::TypeFormatImplSP m_format_sp;
30 lldb::TypeSummaryImplSP m_summary_sp;
31 lldb::SyntheticChildrenSP m_synthetic_sp;
32 lldb::TypeValidatorImplSP m_validator_sp;
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);
43 bool IsFormatCached();
45 bool IsSummaryCached();
47 bool IsSyntheticCached();
49 bool IsValidatorCached();
51 lldb::TypeFormatImplSP GetFormat();
53 lldb::TypeSummaryImplSP GetSummary();
55 lldb::SyntheticChildrenSP GetSynthetic();
57 lldb::TypeValidatorImplSP GetValidator();
59 void SetFormat(lldb::TypeFormatImplSP);
61 void SetSummary(lldb::TypeSummaryImplSP);
63 void SetSynthetic(lldb::SyntheticChildrenSP);
65 void SetValidator(lldb::TypeValidatorImplSP);
67 typedef std::map<ConstString, Entry> CacheMap;
69 std::recursive_mutex m_mutex;
71 uint64_t m_cache_hits;
72 uint64_t m_cache_misses;
74 Entry &GetEntry(ConstString type);
79 bool GetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp);
81 bool GetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
83 bool GetSynthetic(ConstString type,
84 lldb::SyntheticChildrenSP &synthetic_sp);
86 bool GetValidator(ConstString type,
87 lldb::TypeValidatorImplSP &summary_sp);
89 void SetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp);
91 void SetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
93 void SetSynthetic(ConstString type,
94 lldb::SyntheticChildrenSP &synthetic_sp);
96 void SetValidator(ConstString type,
97 lldb::TypeValidatorImplSP &synthetic_sp);
101 uint64_t GetCacheHits() { return m_cache_hits; }
103 uint64_t GetCacheMisses() { return m_cache_misses; }
105 } // namespace lldb_private
107 #endif // lldb_FormatCache_h_