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