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