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_DATAFORMATTERS_FORMATCACHE_H
11#define LLDB_DATAFORMATTERS_FORMATCACHE_H
12
13#include <map>
14#include <mutex>
15
17#include "lldb/lldb-public.h"
18
19namespace lldb_private {
21private:
22 struct Entry {
23 private:
27
31
32 public:
33 Entry();
34
35 template<typename ImplSP> bool IsCached();
36 bool IsFormatCached();
37 bool IsSummaryCached();
38 bool IsSyntheticCached();
39
43
47 };
48 std::map<ConstString, Entry> m_entries;
49 std::recursive_mutex m_mutex;
50
51 uint64_t m_cache_hits = 0;
52 uint64_t m_cache_misses = 0;
53
54public:
55 FormatCache() = default;
56
57 template <typename ImplSP> bool Get(ConstString type, ImplSP &format_impl_sp);
58 void Set(ConstString type, lldb::TypeFormatImplSP &format_sp);
59 void Set(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
60 void Set(ConstString type, lldb::SyntheticChildrenSP &synthetic_sp);
61
62 void Clear();
63
64 uint64_t GetCacheHits() { return m_cache_hits; }
65
66 uint64_t GetCacheMisses() { return m_cache_misses; }
67};
68
69} // namespace lldb_private
70
71#endif // LLDB_DATAFORMATTERS_FORMATCACHE_H
A uniqued constant string class.
Definition: ConstString.h:40
std::map< ConstString, Entry > m_entries
Definition: FormatCache.h:48
void Set(ConstString type, lldb::TypeFormatImplSP &format_sp)
Definition: FormatCache.cpp:94
std::recursive_mutex m_mutex
Definition: FormatCache.h:49
bool Get(ConstString type, ImplSP &format_impl_sp)
Definition: FormatCache.cpp:69
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
Definition: lldb-forward.h:475
std::shared_ptr< lldb_private::TypeFormatImpl > TypeFormatImplSP
Definition: lldb-forward.h:472
std::shared_ptr< lldb_private::SyntheticChildren > SyntheticChildrenSP
Definition: lldb-forward.h:445
lldb::SyntheticChildrenSP m_synthetic_sp
Definition: FormatCache.h:30
lldb::TypeSummaryImplSP m_summary_sp
Definition: FormatCache.h:29
void Set(lldb::TypeFormatImplSP)
Definition: FormatCache.cpp:39
void Get(lldb::TypeFormatImplSP &)
Definition: FormatCache.cpp:27
lldb::TypeFormatImplSP m_format_sp
Definition: FormatCache.h:28