DataVisualization.cpp revision 344779
1//===-- DataVisualization.cpp ---------------------------------------*- C++ 2//-*-===// 3// 4// The LLVM Compiler Infrastructure 5// 6// This file is distributed under the University of Illinois Open Source 7// License. See LICENSE.TXT for details. 8// 9//===----------------------------------------------------------------------===// 10 11#include "lldb/DataFormatters/DataVisualization.h" 12 13 14using namespace lldb; 15using namespace lldb_private; 16 17static FormatManager &GetFormatManager() { 18 static FormatManager g_format_manager; 19 return g_format_manager; 20} 21 22void DataVisualization::ForceUpdate() { GetFormatManager().Changed(); } 23 24uint32_t DataVisualization::GetCurrentRevision() { 25 return GetFormatManager().GetCurrentRevision(); 26} 27 28bool DataVisualization::ShouldPrintAsOneLiner(ValueObject &valobj) { 29 return GetFormatManager().ShouldPrintAsOneLiner(valobj); 30} 31 32lldb::TypeFormatImplSP 33DataVisualization::GetFormat(ValueObject &valobj, 34 lldb::DynamicValueType use_dynamic) { 35 return GetFormatManager().GetFormat(valobj, use_dynamic); 36} 37 38lldb::TypeFormatImplSP 39DataVisualization::GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp) { 40 return GetFormatManager().GetFormatForType(type_sp); 41} 42 43lldb::TypeSummaryImplSP 44DataVisualization::GetSummaryFormat(ValueObject &valobj, 45 lldb::DynamicValueType use_dynamic) { 46 return GetFormatManager().GetSummaryFormat(valobj, use_dynamic); 47} 48 49lldb::TypeSummaryImplSP 50DataVisualization::GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp) { 51 return GetFormatManager().GetSummaryForType(type_sp); 52} 53 54#ifndef LLDB_DISABLE_PYTHON 55lldb::SyntheticChildrenSP 56DataVisualization::GetSyntheticChildren(ValueObject &valobj, 57 lldb::DynamicValueType use_dynamic) { 58 return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic); 59} 60#endif 61 62#ifndef LLDB_DISABLE_PYTHON 63lldb::SyntheticChildrenSP DataVisualization::GetSyntheticChildrenForType( 64 lldb::TypeNameSpecifierImplSP type_sp) { 65 return GetFormatManager().GetSyntheticChildrenForType(type_sp); 66} 67#endif 68 69lldb::TypeFilterImplSP 70DataVisualization::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) { 71 return GetFormatManager().GetFilterForType(type_sp); 72} 73 74#ifndef LLDB_DISABLE_PYTHON 75lldb::ScriptedSyntheticChildrenSP 76DataVisualization::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) { 77 return GetFormatManager().GetSyntheticForType(type_sp); 78} 79#endif 80 81lldb::TypeValidatorImplSP 82DataVisualization::GetValidator(ValueObject &valobj, 83 lldb::DynamicValueType use_dynamic) { 84 return GetFormatManager().GetValidator(valobj, use_dynamic); 85} 86 87lldb::TypeValidatorImplSP 88DataVisualization::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) { 89 return GetFormatManager().GetValidatorForType(type_sp); 90} 91 92bool DataVisualization::AnyMatches( 93 ConstString type_name, TypeCategoryImpl::FormatCategoryItems items, 94 bool only_enabled, const char **matching_category, 95 TypeCategoryImpl::FormatCategoryItems *matching_type) { 96 return GetFormatManager().AnyMatches(type_name, items, only_enabled, 97 matching_category, matching_type); 98} 99 100bool DataVisualization::Categories::GetCategory(const ConstString &category, 101 lldb::TypeCategoryImplSP &entry, 102 bool allow_create) { 103 entry = GetFormatManager().GetCategory(category, allow_create); 104 return (entry.get() != NULL); 105} 106 107bool DataVisualization::Categories::GetCategory( 108 lldb::LanguageType language, lldb::TypeCategoryImplSP &entry) { 109 if (LanguageCategory *lang_category = 110 GetFormatManager().GetCategoryForLanguage(language)) 111 entry = lang_category->GetCategory(); 112 return (entry.get() != nullptr); 113} 114 115void DataVisualization::Categories::Add(const ConstString &category) { 116 GetFormatManager().GetCategory(category); 117} 118 119bool DataVisualization::Categories::Delete(const ConstString &category) { 120 GetFormatManager().DisableCategory(category); 121 return GetFormatManager().DeleteCategory(category); 122} 123 124void DataVisualization::Categories::Clear() { 125 GetFormatManager().ClearCategories(); 126} 127 128void DataVisualization::Categories::Clear(const ConstString &category) { 129 GetFormatManager().GetCategory(category)->Clear( 130 eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); 131} 132 133void DataVisualization::Categories::Enable(const ConstString &category, 134 TypeCategoryMap::Position pos) { 135 if (GetFormatManager().GetCategory(category)->IsEnabled()) 136 GetFormatManager().DisableCategory(category); 137 GetFormatManager().EnableCategory( 138 category, pos, std::initializer_list<lldb::LanguageType>()); 139} 140 141void DataVisualization::Categories::Enable(lldb::LanguageType lang_type) { 142 if (LanguageCategory *lang_category = 143 GetFormatManager().GetCategoryForLanguage(lang_type)) 144 lang_category->Enable(); 145} 146 147void DataVisualization::Categories::Disable(const ConstString &category) { 148 if (GetFormatManager().GetCategory(category)->IsEnabled()) 149 GetFormatManager().DisableCategory(category); 150} 151 152void DataVisualization::Categories::Disable(lldb::LanguageType lang_type) { 153 if (LanguageCategory *lang_category = 154 GetFormatManager().GetCategoryForLanguage(lang_type)) 155 lang_category->Disable(); 156} 157 158void DataVisualization::Categories::Enable( 159 const lldb::TypeCategoryImplSP &category, TypeCategoryMap::Position pos) { 160 if (category.get()) { 161 if (category->IsEnabled()) 162 GetFormatManager().DisableCategory(category); 163 GetFormatManager().EnableCategory(category, pos); 164 } 165} 166 167void DataVisualization::Categories::Disable( 168 const lldb::TypeCategoryImplSP &category) { 169 if (category.get() && category->IsEnabled()) 170 GetFormatManager().DisableCategory(category); 171} 172 173void DataVisualization::Categories::EnableStar() { 174 GetFormatManager().EnableAllCategories(); 175} 176 177void DataVisualization::Categories::DisableStar() { 178 GetFormatManager().DisableAllCategories(); 179} 180 181void DataVisualization::Categories::ForEach( 182 TypeCategoryMap::ForEachCallback callback) { 183 GetFormatManager().ForEachCategory(callback); 184} 185 186uint32_t DataVisualization::Categories::GetCount() { 187 return GetFormatManager().GetCategoriesCount(); 188} 189 190lldb::TypeCategoryImplSP 191DataVisualization::Categories::GetCategoryAtIndex(size_t index) { 192 return GetFormatManager().GetCategoryAtIndex(index); 193} 194 195bool DataVisualization::NamedSummaryFormats::GetSummaryFormat( 196 const ConstString &type, lldb::TypeSummaryImplSP &entry) { 197 return GetFormatManager().GetNamedSummaryContainer().Get(type, entry); 198} 199 200void DataVisualization::NamedSummaryFormats::Add( 201 const ConstString &type, const lldb::TypeSummaryImplSP &entry) { 202 GetFormatManager().GetNamedSummaryContainer().Add( 203 FormatManager::GetValidTypeName(type), entry); 204} 205 206bool DataVisualization::NamedSummaryFormats::Delete(const ConstString &type) { 207 return GetFormatManager().GetNamedSummaryContainer().Delete(type); 208} 209 210void DataVisualization::NamedSummaryFormats::Clear() { 211 GetFormatManager().GetNamedSummaryContainer().Clear(); 212} 213 214void DataVisualization::NamedSummaryFormats::ForEach( 215 std::function<bool(ConstString, const lldb::TypeSummaryImplSP &)> 216 callback) { 217 GetFormatManager().GetNamedSummaryContainer().ForEach(callback); 218} 219 220uint32_t DataVisualization::NamedSummaryFormats::GetCount() { 221 return GetFormatManager().GetNamedSummaryContainer().GetCount(); 222} 223