DataVisualization.cpp revision 269024
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
43bool
44DataVisualization::ShouldPrintAsOneLiner (ValueObject& valobj)
45{
46    return GetFormatManager().ShouldPrintAsOneLiner(valobj);
47}
48
49lldb::TypeFormatImplSP
50DataVisualization::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
51{
52    return GetFormatManager().GetFormat(valobj, use_dynamic);
53}
54
55lldb::TypeFormatImplSP
56DataVisualization::GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp)
57{
58    return GetFormatManager().GetFormatForType(type_sp);
59}
60
61lldb::TypeSummaryImplSP
62DataVisualization::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
63{
64    return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
65}
66
67lldb::TypeSummaryImplSP
68DataVisualization::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
69{
70    return GetFormatManager().GetSummaryForType(type_sp);
71}
72
73#ifndef LLDB_DISABLE_PYTHON
74lldb::SyntheticChildrenSP
75DataVisualization::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
83lldb::SyntheticChildrenSP
84DataVisualization::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp)
85{
86    return GetFormatManager().GetSyntheticChildrenForType(type_sp);
87}
88#endif
89
90lldb::TypeFilterImplSP
91DataVisualization::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
92{
93    return GetFormatManager().GetFilterForType(type_sp);
94}
95
96#ifndef LLDB_DISABLE_PYTHON
97lldb::ScriptedSyntheticChildrenSP
98DataVisualization::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
99{
100    return GetFormatManager().GetSyntheticForType(type_sp);
101}
102#endif
103
104bool
105DataVisualization::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
118bool
119DataVisualization::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
126void
127DataVisualization::Categories::Add (const ConstString &category)
128{
129    GetFormatManager().GetCategory(category);
130}
131
132bool
133DataVisualization::Categories::Delete (const ConstString &category)
134{
135    GetFormatManager().DisableCategory(category);
136    return GetFormatManager().DeleteCategory(category);
137}
138
139void
140DataVisualization::Categories::Clear ()
141{
142    GetFormatManager().ClearCategories();
143}
144
145void
146DataVisualization::Categories::Clear (const ConstString &category)
147{
148    GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
149}
150
151void
152DataVisualization::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
160void
161DataVisualization::Categories::Disable (const ConstString& category)
162{
163    if (GetFormatManager().GetCategory(category)->IsEnabled() == true)
164        GetFormatManager().DisableCategory(category);
165}
166
167void
168DataVisualization::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
179void
180DataVisualization::Categories::Disable (const lldb::TypeCategoryImplSP& category)
181{
182    if (category.get() && category->IsEnabled() == true)
183        GetFormatManager().DisableCategory(category);
184}
185
186void
187DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton)
188{
189    GetFormatManager().LoopThroughCategories(callback, callback_baton);
190}
191
192uint32_t
193DataVisualization::Categories::GetCount ()
194{
195    return GetFormatManager().GetCategoriesCount();
196}
197
198lldb::TypeCategoryImplSP
199DataVisualization::Categories::GetCategoryAtIndex (size_t index)
200{
201    return GetFormatManager().GetCategoryAtIndex(index);
202}
203
204bool
205DataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry)
206{
207    return GetFormatManager().GetNamedSummaryContainer().Get(type,entry);
208}
209
210void
211DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry)
212{
213    GetFormatManager().GetNamedSummaryContainer().Add(FormatManager::GetValidTypeName(type),entry);
214}
215
216bool
217DataVisualization::NamedSummaryFormats::Delete (const ConstString &type)
218{
219    return GetFormatManager().GetNamedSummaryContainer().Delete(type);
220}
221
222void
223DataVisualization::NamedSummaryFormats::Clear ()
224{
225    GetFormatManager().GetNamedSummaryContainer().Clear();
226}
227
228void
229DataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton)
230{
231    GetFormatManager().GetNamedSummaryContainer().LoopThrough(callback, callback_baton);
232}
233
234uint32_t
235DataVisualization::NamedSummaryFormats::GetCount ()
236{
237    return GetFormatManager().GetNamedSummaryContainer().GetCount();
238}
239