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