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