]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/source/DataFormatters/DataVisualization.cpp
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.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 bool
105 DataVisualization::AnyMatches (ConstString type_name,
106                                TypeCategoryImpl::FormatCategoryItems items,
107                                bool only_enabled,
108                                const char** matching_category,
109                                TypeCategoryImpl::FormatCategoryItems* matching_type)
110 {
111     return GetFormatManager().AnyMatches(type_name,
112                                          items,
113                                          only_enabled,
114                                          matching_category,
115                                          matching_type);
116 }
117
118 bool
119 DataVisualization::Categories::GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry,
120                                             bool allow_create)
121 {
122     entry = GetFormatManager().GetCategory(category, allow_create);
123     return (entry.get() != NULL);
124 }
125
126 void
127 DataVisualization::Categories::Add (const ConstString &category)
128 {
129     GetFormatManager().GetCategory(category);
130 }
131
132 bool
133 DataVisualization::Categories::Delete (const ConstString &category)
134 {
135     GetFormatManager().DisableCategory(category);
136     return GetFormatManager().DeleteCategory(category);
137 }
138
139 void
140 DataVisualization::Categories::Clear ()
141 {
142     GetFormatManager().ClearCategories();
143 }
144
145 void
146 DataVisualization::Categories::Clear (const ConstString &category)
147 {
148     GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
149 }
150
151 void
152 DataVisualization::Categories::Enable (const ConstString& category,
153                                        TypeCategoryMap::Position pos)
154 {
155     if (GetFormatManager().GetCategory(category)->IsEnabled())
156         GetFormatManager().DisableCategory(category);
157     GetFormatManager().EnableCategory(category, pos);
158 }
159
160 void
161 DataVisualization::Categories::Disable (const ConstString& category)
162 {
163     if (GetFormatManager().GetCategory(category)->IsEnabled() == true)
164         GetFormatManager().DisableCategory(category);
165 }
166
167 void
168 DataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category,
169                                        TypeCategoryMap::Position pos)
170 {
171     if (category.get())
172     {
173         if (category->IsEnabled())
174             GetFormatManager().DisableCategory(category);
175         GetFormatManager().EnableCategory(category, pos);
176     }
177 }
178
179 void
180 DataVisualization::Categories::Disable (const lldb::TypeCategoryImplSP& category)
181 {
182     if (category.get() && category->IsEnabled() == true)
183         GetFormatManager().DisableCategory(category);
184 }
185
186 void
187 DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton)
188 {
189     GetFormatManager().LoopThroughCategories(callback, callback_baton);
190 }
191
192 uint32_t
193 DataVisualization::Categories::GetCount ()
194 {
195     return GetFormatManager().GetCategoriesCount();
196 }
197
198 lldb::TypeCategoryImplSP
199 DataVisualization::Categories::GetCategoryAtIndex (size_t index)
200 {
201     return GetFormatManager().GetCategoryAtIndex(index);
202 }
203
204 bool
205 DataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry)
206 {
207     return GetFormatManager().GetNamedSummaryContainer().Get(type,entry);
208 }
209
210 void
211 DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry)
212 {
213     GetFormatManager().GetNamedSummaryContainer().Add(FormatManager::GetValidTypeName(type),entry);
214 }
215
216 bool
217 DataVisualization::NamedSummaryFormats::Delete (const ConstString &type)
218 {
219     return GetFormatManager().GetNamedSummaryContainer().Delete(type);
220 }
221
222 void
223 DataVisualization::NamedSummaryFormats::Clear ()
224 {
225     GetFormatManager().GetNamedSummaryContainer().Clear();
226 }
227
228 void
229 DataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton)
230 {
231     GetFormatManager().GetNamedSummaryContainer().LoopThrough(callback, callback_baton);
232 }
233
234 uint32_t
235 DataVisualization::NamedSummaryFormats::GetCount ()
236 {
237     return GetFormatManager().GetNamedSummaryContainer().GetCount();
238 }