]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/DataFormatters/DataVisualization.cpp
Upgrade Unbound to 1.6.1. More to follow.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / DataFormatters / DataVisualization.cpp
1 //===-- DataVisualization.cpp ---------------------------------------*- 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 #include "lldb/DataFormatters/DataVisualization.h"
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17
18 using namespace lldb;
19 using namespace lldb_private;
20
21 static FormatManager &GetFormatManager() {
22   static FormatManager g_format_manager;
23   return g_format_manager;
24 }
25
26 void DataVisualization::ForceUpdate() { GetFormatManager().Changed(); }
27
28 uint32_t DataVisualization::GetCurrentRevision() {
29   return GetFormatManager().GetCurrentRevision();
30 }
31
32 bool DataVisualization::ShouldPrintAsOneLiner(ValueObject &valobj) {
33   return GetFormatManager().ShouldPrintAsOneLiner(valobj);
34 }
35
36 lldb::TypeFormatImplSP
37 DataVisualization::GetFormat(ValueObject &valobj,
38                              lldb::DynamicValueType use_dynamic) {
39   return GetFormatManager().GetFormat(valobj, use_dynamic);
40 }
41
42 lldb::TypeFormatImplSP
43 DataVisualization::GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp) {
44   return GetFormatManager().GetFormatForType(type_sp);
45 }
46
47 lldb::TypeSummaryImplSP
48 DataVisualization::GetSummaryFormat(ValueObject &valobj,
49                                     lldb::DynamicValueType use_dynamic) {
50   return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
51 }
52
53 lldb::TypeSummaryImplSP
54 DataVisualization::GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp) {
55   return GetFormatManager().GetSummaryForType(type_sp);
56 }
57
58 #ifndef LLDB_DISABLE_PYTHON
59 lldb::SyntheticChildrenSP
60 DataVisualization::GetSyntheticChildren(ValueObject &valobj,
61                                         lldb::DynamicValueType use_dynamic) {
62   return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
63 }
64 #endif
65
66 #ifndef LLDB_DISABLE_PYTHON
67 lldb::SyntheticChildrenSP DataVisualization::GetSyntheticChildrenForType(
68     lldb::TypeNameSpecifierImplSP type_sp) {
69   return GetFormatManager().GetSyntheticChildrenForType(type_sp);
70 }
71 #endif
72
73 lldb::TypeFilterImplSP
74 DataVisualization::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) {
75   return GetFormatManager().GetFilterForType(type_sp);
76 }
77
78 #ifndef LLDB_DISABLE_PYTHON
79 lldb::ScriptedSyntheticChildrenSP
80 DataVisualization::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
81   return GetFormatManager().GetSyntheticForType(type_sp);
82 }
83 #endif
84
85 lldb::TypeValidatorImplSP
86 DataVisualization::GetValidator(ValueObject &valobj,
87                                 lldb::DynamicValueType use_dynamic) {
88   return GetFormatManager().GetValidator(valobj, use_dynamic);
89 }
90
91 lldb::TypeValidatorImplSP
92 DataVisualization::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) {
93   return GetFormatManager().GetValidatorForType(type_sp);
94 }
95
96 bool DataVisualization::AnyMatches(
97     ConstString type_name, TypeCategoryImpl::FormatCategoryItems items,
98     bool only_enabled, const char **matching_category,
99     TypeCategoryImpl::FormatCategoryItems *matching_type) {
100   return GetFormatManager().AnyMatches(type_name, items, only_enabled,
101                                        matching_category, matching_type);
102 }
103
104 bool DataVisualization::Categories::GetCategory(const ConstString &category,
105                                                 lldb::TypeCategoryImplSP &entry,
106                                                 bool allow_create) {
107   entry = GetFormatManager().GetCategory(category, allow_create);
108   return (entry.get() != NULL);
109 }
110
111 bool DataVisualization::Categories::GetCategory(
112     lldb::LanguageType language, lldb::TypeCategoryImplSP &entry) {
113   if (LanguageCategory *lang_category =
114           GetFormatManager().GetCategoryForLanguage(language))
115     entry = lang_category->GetCategory();
116   return (entry.get() != nullptr);
117 }
118
119 void DataVisualization::Categories::Add(const ConstString &category) {
120   GetFormatManager().GetCategory(category);
121 }
122
123 bool DataVisualization::Categories::Delete(const ConstString &category) {
124   GetFormatManager().DisableCategory(category);
125   return GetFormatManager().DeleteCategory(category);
126 }
127
128 void DataVisualization::Categories::Clear() {
129   GetFormatManager().ClearCategories();
130 }
131
132 void DataVisualization::Categories::Clear(const ConstString &category) {
133   GetFormatManager().GetCategory(category)->Clear(
134       eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
135 }
136
137 void DataVisualization::Categories::Enable(const ConstString &category,
138                                            TypeCategoryMap::Position pos) {
139   if (GetFormatManager().GetCategory(category)->IsEnabled())
140     GetFormatManager().DisableCategory(category);
141   GetFormatManager().EnableCategory(
142       category, pos, std::initializer_list<lldb::LanguageType>());
143 }
144
145 void DataVisualization::Categories::Enable(lldb::LanguageType lang_type) {
146   if (LanguageCategory *lang_category =
147           GetFormatManager().GetCategoryForLanguage(lang_type))
148     lang_category->Enable();
149 }
150
151 void DataVisualization::Categories::Disable(const ConstString &category) {
152   if (GetFormatManager().GetCategory(category)->IsEnabled() == true)
153     GetFormatManager().DisableCategory(category);
154 }
155
156 void DataVisualization::Categories::Disable(lldb::LanguageType lang_type) {
157   if (LanguageCategory *lang_category =
158           GetFormatManager().GetCategoryForLanguage(lang_type))
159     lang_category->Disable();
160 }
161
162 void DataVisualization::Categories::Enable(
163     const lldb::TypeCategoryImplSP &category, TypeCategoryMap::Position pos) {
164   if (category.get()) {
165     if (category->IsEnabled())
166       GetFormatManager().DisableCategory(category);
167     GetFormatManager().EnableCategory(category, pos);
168   }
169 }
170
171 void DataVisualization::Categories::Disable(
172     const lldb::TypeCategoryImplSP &category) {
173   if (category.get() && category->IsEnabled() == true)
174     GetFormatManager().DisableCategory(category);
175 }
176
177 void DataVisualization::Categories::EnableStar() {
178   GetFormatManager().EnableAllCategories();
179 }
180
181 void DataVisualization::Categories::DisableStar() {
182   GetFormatManager().DisableAllCategories();
183 }
184
185 void DataVisualization::Categories::ForEach(
186     TypeCategoryMap::ForEachCallback callback) {
187   GetFormatManager().ForEachCategory(callback);
188 }
189
190 uint32_t DataVisualization::Categories::GetCount() {
191   return GetFormatManager().GetCategoriesCount();
192 }
193
194 lldb::TypeCategoryImplSP
195 DataVisualization::Categories::GetCategoryAtIndex(size_t index) {
196   return GetFormatManager().GetCategoryAtIndex(index);
197 }
198
199 bool DataVisualization::NamedSummaryFormats::GetSummaryFormat(
200     const ConstString &type, lldb::TypeSummaryImplSP &entry) {
201   return GetFormatManager().GetNamedSummaryContainer().Get(type, entry);
202 }
203
204 void DataVisualization::NamedSummaryFormats::Add(
205     const ConstString &type, const lldb::TypeSummaryImplSP &entry) {
206   GetFormatManager().GetNamedSummaryContainer().Add(
207       FormatManager::GetValidTypeName(type), entry);
208 }
209
210 bool DataVisualization::NamedSummaryFormats::Delete(const ConstString &type) {
211   return GetFormatManager().GetNamedSummaryContainer().Delete(type);
212 }
213
214 void DataVisualization::NamedSummaryFormats::Clear() {
215   GetFormatManager().GetNamedSummaryContainer().Clear();
216 }
217
218 void DataVisualization::NamedSummaryFormats::ForEach(
219     std::function<bool(ConstString, const lldb::TypeSummaryImplSP &)>
220         callback) {
221   GetFormatManager().GetNamedSummaryContainer().ForEach(callback);
222 }
223
224 uint32_t DataVisualization::NamedSummaryFormats::GetCount() {
225   return GetFormatManager().GetNamedSummaryContainer().GetCount();
226 }