Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/lldb/source/DataFormatters/DataVisualization.cpp
39587 views
1
//===-- DataVisualization.cpp ---------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "lldb/DataFormatters/DataVisualization.h"
10
11
12
using namespace lldb;
13
using namespace lldb_private;
14
15
static FormatManager &GetFormatManager() {
16
static FormatManager g_format_manager;
17
return g_format_manager;
18
}
19
20
void DataVisualization::ForceUpdate() { GetFormatManager().Changed(); }
21
22
uint32_t DataVisualization::GetCurrentRevision() {
23
return GetFormatManager().GetCurrentRevision();
24
}
25
26
bool DataVisualization::ShouldPrintAsOneLiner(ValueObject &valobj) {
27
return GetFormatManager().ShouldPrintAsOneLiner(valobj);
28
}
29
30
lldb::TypeFormatImplSP
31
DataVisualization::GetFormat(ValueObject &valobj,
32
lldb::DynamicValueType use_dynamic) {
33
return GetFormatManager().GetFormat(valobj, use_dynamic);
34
}
35
36
lldb::TypeFormatImplSP
37
DataVisualization::GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp) {
38
return GetFormatManager().GetFormatForType(type_sp);
39
}
40
41
lldb::TypeSummaryImplSP
42
DataVisualization::GetSummaryFormat(ValueObject &valobj,
43
lldb::DynamicValueType use_dynamic) {
44
return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
45
}
46
47
lldb::TypeSummaryImplSP
48
DataVisualization::GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp) {
49
return GetFormatManager().GetSummaryForType(type_sp);
50
}
51
52
lldb::SyntheticChildrenSP
53
DataVisualization::GetSyntheticChildren(ValueObject &valobj,
54
lldb::DynamicValueType use_dynamic) {
55
return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
56
}
57
58
lldb::TypeFilterImplSP
59
DataVisualization::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) {
60
return GetFormatManager().GetFilterForType(type_sp);
61
}
62
63
lldb::ScriptedSyntheticChildrenSP
64
DataVisualization::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
65
return GetFormatManager().GetSyntheticForType(type_sp);
66
}
67
68
bool DataVisualization::AnyMatches(
69
const FormattersMatchCandidate &candidate_type,
70
TypeCategoryImpl::FormatCategoryItems items, bool only_enabled,
71
const char **matching_category,
72
TypeCategoryImpl::FormatCategoryItems *matching_type) {
73
return GetFormatManager().AnyMatches(candidate_type, items, only_enabled,
74
matching_category, matching_type);
75
}
76
77
bool DataVisualization::Categories::GetCategory(ConstString category,
78
lldb::TypeCategoryImplSP &entry,
79
bool allow_create) {
80
entry = GetFormatManager().GetCategory(category, allow_create);
81
return (entry.get() != nullptr);
82
}
83
84
bool DataVisualization::Categories::GetCategory(
85
lldb::LanguageType language, lldb::TypeCategoryImplSP &entry) {
86
if (LanguageCategory *lang_category =
87
GetFormatManager().GetCategoryForLanguage(language))
88
entry = lang_category->GetCategory();
89
return (entry.get() != nullptr);
90
}
91
92
void DataVisualization::Categories::Add(ConstString category) {
93
GetFormatManager().GetCategory(category);
94
}
95
96
bool DataVisualization::Categories::Delete(ConstString category) {
97
GetFormatManager().DisableCategory(category);
98
return GetFormatManager().DeleteCategory(category);
99
}
100
101
void DataVisualization::Categories::Clear() {
102
GetFormatManager().ClearCategories();
103
}
104
105
void DataVisualization::Categories::Clear(ConstString category) {
106
GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary);
107
}
108
109
void DataVisualization::Categories::Enable(ConstString category,
110
TypeCategoryMap::Position pos) {
111
if (GetFormatManager().GetCategory(category)->IsEnabled())
112
GetFormatManager().DisableCategory(category);
113
GetFormatManager().EnableCategory(category, pos, {});
114
}
115
116
void DataVisualization::Categories::Enable(lldb::LanguageType lang_type) {
117
if (LanguageCategory *lang_category =
118
GetFormatManager().GetCategoryForLanguage(lang_type))
119
lang_category->Enable();
120
}
121
122
void DataVisualization::Categories::Disable(ConstString category) {
123
if (GetFormatManager().GetCategory(category)->IsEnabled())
124
GetFormatManager().DisableCategory(category);
125
}
126
127
void DataVisualization::Categories::Disable(lldb::LanguageType lang_type) {
128
if (LanguageCategory *lang_category =
129
GetFormatManager().GetCategoryForLanguage(lang_type))
130
lang_category->Disable();
131
}
132
133
void DataVisualization::Categories::Enable(
134
const lldb::TypeCategoryImplSP &category, TypeCategoryMap::Position pos) {
135
if (category.get()) {
136
if (category->IsEnabled())
137
GetFormatManager().DisableCategory(category);
138
GetFormatManager().EnableCategory(category, pos);
139
}
140
}
141
142
void DataVisualization::Categories::Disable(
143
const lldb::TypeCategoryImplSP &category) {
144
if (category.get() && category->IsEnabled())
145
GetFormatManager().DisableCategory(category);
146
}
147
148
void DataVisualization::Categories::EnableStar() {
149
GetFormatManager().EnableAllCategories();
150
}
151
152
void DataVisualization::Categories::DisableStar() {
153
GetFormatManager().DisableAllCategories();
154
}
155
156
void DataVisualization::Categories::ForEach(
157
TypeCategoryMap::ForEachCallback callback) {
158
GetFormatManager().ForEachCategory(callback);
159
}
160
161
uint32_t DataVisualization::Categories::GetCount() {
162
return GetFormatManager().GetCategoriesCount();
163
}
164
165
lldb::TypeCategoryImplSP
166
DataVisualization::Categories::GetCategoryAtIndex(size_t index) {
167
return GetFormatManager().GetCategoryAtIndex(index);
168
}
169
170
bool DataVisualization::NamedSummaryFormats::GetSummaryFormat(
171
ConstString type, lldb::TypeSummaryImplSP &entry) {
172
return GetFormatManager().GetNamedSummaryContainer().GetExact(type, entry);
173
}
174
175
void DataVisualization::NamedSummaryFormats::Add(
176
ConstString type, const lldb::TypeSummaryImplSP &entry) {
177
GetFormatManager().GetNamedSummaryContainer().Add(type, entry);
178
}
179
180
bool DataVisualization::NamedSummaryFormats::Delete(ConstString type) {
181
return GetFormatManager().GetNamedSummaryContainer().Delete(type);
182
}
183
184
void DataVisualization::NamedSummaryFormats::Clear() {
185
GetFormatManager().GetNamedSummaryContainer().Clear();
186
}
187
188
void DataVisualization::NamedSummaryFormats::ForEach(
189
std::function<bool(const TypeMatcher &, const lldb::TypeSummaryImplSP &)>
190
callback) {
191
GetFormatManager().GetNamedSummaryContainer().ForEach(callback);
192
}
193
194
uint32_t DataVisualization::NamedSummaryFormats::GetCount() {
195
return GetFormatManager().GetNamedSummaryContainer().GetCount();
196
}
197
198