]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/DataFormatters/DataVisualization.cpp
Merge ^/head r294599 through r294776.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / DataFormatters / DataVisualization.cpp
1 //===-- DataVisualization.cpp ---------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "lldb/DataFormatters/DataVisualization.h"
11
12 // C Includes
13 // C++ Includes
14 // Other libraries and framework includes
15 // Project includes
16
17 using namespace lldb;
18 using namespace lldb_private;
19
20 static FormatManager&
21 GetFormatManager()
22 {
23     static FormatManager g_format_manager;
24     return g_format_manager;
25 }
26
27 void
28 DataVisualization::ForceUpdate ()
29 {
30     GetFormatManager().Changed();
31 }
32
33 uint32_t
34 DataVisualization::GetCurrentRevision ()
35 {
36     return GetFormatManager().GetCurrentRevision();
37 }
38
39 bool
40 DataVisualization::ShouldPrintAsOneLiner (ValueObject& valobj)
41 {
42     return GetFormatManager().ShouldPrintAsOneLiner(valobj);
43 }
44
45 lldb::TypeFormatImplSP
46 DataVisualization::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
47 {
48     return GetFormatManager().GetFormat(valobj, use_dynamic);
49 }
50
51 lldb::TypeFormatImplSP
52 DataVisualization::GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp)
53 {
54     return GetFormatManager().GetFormatForType(type_sp);
55 }
56
57 lldb::TypeSummaryImplSP
58 DataVisualization::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
59 {
60     return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
61 }
62
63 lldb::TypeSummaryImplSP
64 DataVisualization::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
65 {
66     return GetFormatManager().GetSummaryForType(type_sp);
67 }
68
69 #ifndef LLDB_DISABLE_PYTHON
70 lldb::SyntheticChildrenSP
71 DataVisualization::GetSyntheticChildren (ValueObject& valobj,
72                                          lldb::DynamicValueType use_dynamic)
73 {
74     return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
75 }
76 #endif
77
78 #ifndef LLDB_DISABLE_PYTHON
79 lldb::SyntheticChildrenSP
80 DataVisualization::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp)
81 {
82     return GetFormatManager().GetSyntheticChildrenForType(type_sp);
83 }
84 #endif
85
86 lldb::TypeFilterImplSP
87 DataVisualization::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
88 {
89     return GetFormatManager().GetFilterForType(type_sp);
90 }
91
92 #ifndef LLDB_DISABLE_PYTHON
93 lldb::ScriptedSyntheticChildrenSP
94 DataVisualization::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
95 {
96     return GetFormatManager().GetSyntheticForType(type_sp);
97 }
98 #endif
99
100 lldb::TypeValidatorImplSP
101 DataVisualization::GetValidator (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
102 {
103     return GetFormatManager().GetValidator(valobj, use_dynamic);
104 }
105
106 lldb::TypeValidatorImplSP
107 DataVisualization::GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp)
108 {
109     return GetFormatManager().GetValidatorForType(type_sp);
110 }
111
112 bool
113 DataVisualization::AnyMatches (ConstString type_name,
114                                TypeCategoryImpl::FormatCategoryItems items,
115                                bool only_enabled,
116                                const char** matching_category,
117                                TypeCategoryImpl::FormatCategoryItems* matching_type)
118 {
119     return GetFormatManager().AnyMatches(type_name,
120                                          items,
121                                          only_enabled,
122                                          matching_category,
123                                          matching_type);
124 }
125
126 bool
127 DataVisualization::Categories::GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry,
128                                             bool allow_create)
129 {
130     entry = GetFormatManager().GetCategory(category, allow_create);
131     return (entry.get() != NULL);
132 }
133
134 bool
135 DataVisualization::Categories::GetCategory (lldb::LanguageType language, lldb::TypeCategoryImplSP &entry)
136 {
137     if (LanguageCategory *lang_category = GetFormatManager().GetCategoryForLanguage(language))
138         entry = lang_category->GetCategory();
139     return (entry.get() != nullptr);
140 }
141
142 void
143 DataVisualization::Categories::Add (const ConstString &category)
144 {
145     GetFormatManager().GetCategory(category);
146 }
147
148 bool
149 DataVisualization::Categories::Delete (const ConstString &category)
150 {
151     GetFormatManager().DisableCategory(category);
152     return GetFormatManager().DeleteCategory(category);
153 }
154
155 void
156 DataVisualization::Categories::Clear ()
157 {
158     GetFormatManager().ClearCategories();
159 }
160
161 void
162 DataVisualization::Categories::Clear (const ConstString &category)
163 {
164     GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
165 }
166
167 void
168 DataVisualization::Categories::Enable (const ConstString& category,
169                                        TypeCategoryMap::Position pos)
170 {
171     if (GetFormatManager().GetCategory(category)->IsEnabled())
172         GetFormatManager().DisableCategory(category);
173     GetFormatManager().EnableCategory(category, pos, std::initializer_list<lldb::LanguageType>());
174 }
175
176 void
177 DataVisualization::Categories::Enable (lldb::LanguageType lang_type)
178 {
179     if (LanguageCategory* lang_category = GetFormatManager().GetCategoryForLanguage(lang_type))
180         lang_category->Enable();
181 }
182
183 void
184 DataVisualization::Categories::Disable (const ConstString& category)
185 {
186     if (GetFormatManager().GetCategory(category)->IsEnabled() == true)
187         GetFormatManager().DisableCategory(category);
188 }
189
190 void
191 DataVisualization::Categories::Disable (lldb::LanguageType lang_type)
192 {
193     if (LanguageCategory* lang_category = GetFormatManager().GetCategoryForLanguage(lang_type))
194         lang_category->Disable();
195 }
196
197 void
198 DataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category,
199                                        TypeCategoryMap::Position pos)
200 {
201     if (category.get())
202     {
203         if (category->IsEnabled())
204             GetFormatManager().DisableCategory(category);
205         GetFormatManager().EnableCategory(category, pos);
206     }
207 }
208
209 void
210 DataVisualization::Categories::Disable (const lldb::TypeCategoryImplSP& category)
211 {
212     if (category.get() && category->IsEnabled() == true)
213         GetFormatManager().DisableCategory(category);
214 }
215
216 void
217 DataVisualization::Categories::EnableStar ()
218 {
219     GetFormatManager().EnableAllCategories ();
220 }
221
222 void
223 DataVisualization::Categories::DisableStar ()
224 {
225     GetFormatManager().DisableAllCategories();
226 }
227
228 void
229 DataVisualization::Categories::ForEach (TypeCategoryMap::ForEachCallback callback)
230 {
231     GetFormatManager().ForEachCategory(callback);
232 }
233
234 uint32_t
235 DataVisualization::Categories::GetCount ()
236 {
237     return GetFormatManager().GetCategoriesCount();
238 }
239
240 lldb::TypeCategoryImplSP
241 DataVisualization::Categories::GetCategoryAtIndex (size_t index)
242 {
243     return GetFormatManager().GetCategoryAtIndex(index);
244 }
245
246 bool
247 DataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry)
248 {
249     return GetFormatManager().GetNamedSummaryContainer().Get(type,entry);
250 }
251
252 void
253 DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry)
254 {
255     GetFormatManager().GetNamedSummaryContainer().Add(FormatManager::GetValidTypeName(type),entry);
256 }
257
258 bool
259 DataVisualization::NamedSummaryFormats::Delete (const ConstString &type)
260 {
261     return GetFormatManager().GetNamedSummaryContainer().Delete(type);
262 }
263
264 void
265 DataVisualization::NamedSummaryFormats::Clear ()
266 {
267     GetFormatManager().GetNamedSummaryContainer().Clear();
268 }
269
270 void
271 DataVisualization::NamedSummaryFormats::ForEach (std::function<bool(ConstString, const lldb::TypeSummaryImplSP&)> callback)
272 {
273     GetFormatManager().GetNamedSummaryContainer().ForEach(callback);
274 }
275
276 uint32_t
277 DataVisualization::NamedSummaryFormats::GetCount ()
278 {
279     return GetFormatManager().GetNamedSummaryContainer().GetCount();
280 }