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