File indexing completed on 2026-05-10 08:42:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef LLDB_DATAFORMATTERS_FORMATCACHE_H
0011 #define LLDB_DATAFORMATTERS_FORMATCACHE_H
0012
0013 #include <map>
0014 #include <mutex>
0015
0016 #include "lldb/Utility/ConstString.h"
0017 #include "lldb/lldb-public.h"
0018
0019 namespace lldb_private {
0020 class FormatCache {
0021 private:
0022 struct Entry {
0023 private:
0024 bool m_format_cached : 1;
0025 bool m_summary_cached : 1;
0026 bool m_synthetic_cached : 1;
0027
0028 lldb::TypeFormatImplSP m_format_sp;
0029 lldb::TypeSummaryImplSP m_summary_sp;
0030 lldb::SyntheticChildrenSP m_synthetic_sp;
0031
0032 public:
0033 Entry();
0034
0035 template<typename ImplSP> bool IsCached();
0036 bool IsFormatCached();
0037 bool IsSummaryCached();
0038 bool IsSyntheticCached();
0039
0040 void Get(lldb::TypeFormatImplSP &);
0041 void Get(lldb::TypeSummaryImplSP &);
0042 void Get(lldb::SyntheticChildrenSP &);
0043
0044 void Set(lldb::TypeFormatImplSP);
0045 void Set(lldb::TypeSummaryImplSP);
0046 void Set(lldb::SyntheticChildrenSP);
0047 };
0048 std::map<ConstString, Entry> m_entries;
0049 std::recursive_mutex m_mutex;
0050
0051 uint64_t m_cache_hits = 0;
0052 uint64_t m_cache_misses = 0;
0053
0054 public:
0055 FormatCache() = default;
0056
0057 template <typename ImplSP> bool Get(ConstString type, ImplSP &format_impl_sp);
0058 void Set(ConstString type, lldb::TypeFormatImplSP &format_sp);
0059 void Set(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
0060 void Set(ConstString type, lldb::SyntheticChildrenSP &synthetic_sp);
0061
0062 void Clear();
0063
0064 uint64_t GetCacheHits() { return m_cache_hits; }
0065
0066 uint64_t GetCacheMisses() { return m_cache_misses; }
0067 };
0068
0069 }
0070
0071 #endif