DataVisualization.cpp revision 296417
1254721Semaste//===-- DataVisualization.cpp ---------------------------------------*- C++ -*-===// 2254721Semaste// 3254721Semaste// The LLVM Compiler Infrastructure 4254721Semaste// 5254721Semaste// This file is distributed under the University of Illinois Open Source 6254721Semaste// License. See LICENSE.TXT for details. 7254721Semaste// 8254721Semaste//===----------------------------------------------------------------------===// 9254721Semaste 10254721Semaste#include "lldb/DataFormatters/DataVisualization.h" 11254721Semaste 12254721Semaste// C Includes 13254721Semaste// C++ Includes 14254721Semaste// Other libraries and framework includes 15254721Semaste// Project includes 16254721Semaste 17254721Semasteusing namespace lldb; 18254721Semasteusing namespace lldb_private; 19254721Semaste 20254721Semastestatic FormatManager& 21254721SemasteGetFormatManager() 22254721Semaste{ 23254721Semaste static FormatManager g_format_manager; 24254721Semaste return g_format_manager; 25254721Semaste} 26254721Semaste 27254721Semastevoid 28254721SemasteDataVisualization::ForceUpdate () 29254721Semaste{ 30254721Semaste GetFormatManager().Changed(); 31254721Semaste} 32254721Semaste 33254721Semasteuint32_t 34254721SemasteDataVisualization::GetCurrentRevision () 35254721Semaste{ 36254721Semaste return GetFormatManager().GetCurrentRevision(); 37254721Semaste} 38254721Semaste 39258054Semastebool 40258054SemasteDataVisualization::ShouldPrintAsOneLiner (ValueObject& valobj) 41254721Semaste{ 42258054Semaste return GetFormatManager().ShouldPrintAsOneLiner(valobj); 43254721Semaste} 44254721Semaste 45254721Semastelldb::TypeFormatImplSP 46258054SemasteDataVisualization::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) 47254721Semaste{ 48258054Semaste return GetFormatManager().GetFormat(valobj, use_dynamic); 49254721Semaste} 50254721Semaste 51254721Semastelldb::TypeFormatImplSP 52258054SemasteDataVisualization::GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp) 53254721Semaste{ 54258054Semaste return GetFormatManager().GetFormatForType(type_sp); 55254721Semaste} 56254721Semaste 57254721Semastelldb::TypeSummaryImplSP 58258054SemasteDataVisualization::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) 59254721Semaste{ 60254721Semaste return GetFormatManager().GetSummaryFormat(valobj, use_dynamic); 61254721Semaste} 62254721Semaste 63254721Semastelldb::TypeSummaryImplSP 64254721SemasteDataVisualization::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp) 65254721Semaste{ 66254721Semaste return GetFormatManager().GetSummaryForType(type_sp); 67254721Semaste} 68254721Semaste 69254721Semaste#ifndef LLDB_DISABLE_PYTHON 70254721Semastelldb::SyntheticChildrenSP 71254721SemasteDataVisualization::GetSyntheticChildren (ValueObject& valobj, 72254721Semaste lldb::DynamicValueType use_dynamic) 73254721Semaste{ 74254721Semaste return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic); 75254721Semaste} 76254721Semaste#endif 77254721Semaste 78254721Semaste#ifndef LLDB_DISABLE_PYTHON 79254721Semastelldb::SyntheticChildrenSP 80254721SemasteDataVisualization::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp) 81254721Semaste{ 82254721Semaste return GetFormatManager().GetSyntheticChildrenForType(type_sp); 83254721Semaste} 84254721Semaste#endif 85254721Semaste 86254721Semastelldb::TypeFilterImplSP 87254721SemasteDataVisualization::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp) 88254721Semaste{ 89254721Semaste return GetFormatManager().GetFilterForType(type_sp); 90254721Semaste} 91254721Semaste 92254721Semaste#ifndef LLDB_DISABLE_PYTHON 93254721Semastelldb::ScriptedSyntheticChildrenSP 94254721SemasteDataVisualization::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp) 95254721Semaste{ 96254721Semaste return GetFormatManager().GetSyntheticForType(type_sp); 97254721Semaste} 98254721Semaste#endif 99254721Semaste 100280031Sdimlldb::TypeValidatorImplSP 101280031SdimDataVisualization::GetValidator (ValueObject& valobj, lldb::DynamicValueType use_dynamic) 102280031Sdim{ 103280031Sdim return GetFormatManager().GetValidator(valobj, use_dynamic); 104280031Sdim} 105280031Sdim 106280031Sdimlldb::TypeValidatorImplSP 107280031SdimDataVisualization::GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp) 108280031Sdim{ 109280031Sdim return GetFormatManager().GetValidatorForType(type_sp); 110280031Sdim} 111280031Sdim 112254721Semastebool 113254721SemasteDataVisualization::AnyMatches (ConstString type_name, 114254721Semaste TypeCategoryImpl::FormatCategoryItems items, 115254721Semaste bool only_enabled, 116254721Semaste const char** matching_category, 117254721Semaste TypeCategoryImpl::FormatCategoryItems* matching_type) 118254721Semaste{ 119254721Semaste return GetFormatManager().AnyMatches(type_name, 120254721Semaste items, 121254721Semaste only_enabled, 122254721Semaste matching_category, 123254721Semaste matching_type); 124254721Semaste} 125254721Semaste 126254721Semastebool 127254721SemasteDataVisualization::Categories::GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry, 128254721Semaste bool allow_create) 129254721Semaste{ 130254721Semaste entry = GetFormatManager().GetCategory(category, allow_create); 131254721Semaste return (entry.get() != NULL); 132254721Semaste} 133254721Semaste 134296417Sdimbool 135296417SdimDataVisualization::Categories::GetCategory (lldb::LanguageType language, lldb::TypeCategoryImplSP &entry) 136296417Sdim{ 137296417Sdim if (LanguageCategory *lang_category = GetFormatManager().GetCategoryForLanguage(language)) 138296417Sdim entry = lang_category->GetCategory(); 139296417Sdim return (entry.get() != nullptr); 140296417Sdim} 141296417Sdim 142254721Semastevoid 143254721SemasteDataVisualization::Categories::Add (const ConstString &category) 144254721Semaste{ 145254721Semaste GetFormatManager().GetCategory(category); 146254721Semaste} 147254721Semaste 148254721Semastebool 149254721SemasteDataVisualization::Categories::Delete (const ConstString &category) 150254721Semaste{ 151254721Semaste GetFormatManager().DisableCategory(category); 152254721Semaste return GetFormatManager().DeleteCategory(category); 153254721Semaste} 154254721Semaste 155254721Semastevoid 156254721SemasteDataVisualization::Categories::Clear () 157254721Semaste{ 158254721Semaste GetFormatManager().ClearCategories(); 159254721Semaste} 160254721Semaste 161254721Semastevoid 162254721SemasteDataVisualization::Categories::Clear (const ConstString &category) 163254721Semaste{ 164254721Semaste GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); 165254721Semaste} 166254721Semaste 167254721Semastevoid 168254721SemasteDataVisualization::Categories::Enable (const ConstString& category, 169254721Semaste TypeCategoryMap::Position pos) 170254721Semaste{ 171254721Semaste if (GetFormatManager().GetCategory(category)->IsEnabled()) 172254721Semaste GetFormatManager().DisableCategory(category); 173296417Sdim GetFormatManager().EnableCategory(category, pos, std::initializer_list<lldb::LanguageType>()); 174254721Semaste} 175254721Semaste 176254721Semastevoid 177296417SdimDataVisualization::Categories::Enable (lldb::LanguageType lang_type) 178296417Sdim{ 179296417Sdim if (LanguageCategory* lang_category = GetFormatManager().GetCategoryForLanguage(lang_type)) 180296417Sdim lang_category->Enable(); 181296417Sdim} 182296417Sdim 183296417Sdimvoid 184254721SemasteDataVisualization::Categories::Disable (const ConstString& category) 185254721Semaste{ 186254721Semaste if (GetFormatManager().GetCategory(category)->IsEnabled() == true) 187254721Semaste GetFormatManager().DisableCategory(category); 188254721Semaste} 189254721Semaste 190254721Semastevoid 191296417SdimDataVisualization::Categories::Disable (lldb::LanguageType lang_type) 192296417Sdim{ 193296417Sdim if (LanguageCategory* lang_category = GetFormatManager().GetCategoryForLanguage(lang_type)) 194296417Sdim lang_category->Disable(); 195296417Sdim} 196296417Sdim 197296417Sdimvoid 198254721SemasteDataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category, 199254721Semaste TypeCategoryMap::Position pos) 200254721Semaste{ 201254721Semaste if (category.get()) 202254721Semaste { 203254721Semaste if (category->IsEnabled()) 204254721Semaste GetFormatManager().DisableCategory(category); 205254721Semaste GetFormatManager().EnableCategory(category, pos); 206254721Semaste } 207254721Semaste} 208254721Semaste 209254721Semastevoid 210254721SemasteDataVisualization::Categories::Disable (const lldb::TypeCategoryImplSP& category) 211254721Semaste{ 212254721Semaste if (category.get() && category->IsEnabled() == true) 213254721Semaste GetFormatManager().DisableCategory(category); 214254721Semaste} 215254721Semaste 216254721Semastevoid 217280031SdimDataVisualization::Categories::EnableStar () 218280031Sdim{ 219280031Sdim GetFormatManager().EnableAllCategories (); 220280031Sdim} 221280031Sdim 222280031Sdimvoid 223280031SdimDataVisualization::Categories::DisableStar () 224280031Sdim{ 225280031Sdim GetFormatManager().DisableAllCategories(); 226280031Sdim} 227280031Sdim 228280031Sdimvoid 229296417SdimDataVisualization::Categories::ForEach (TypeCategoryMap::ForEachCallback callback) 230254721Semaste{ 231296417Sdim GetFormatManager().ForEachCategory(callback); 232254721Semaste} 233254721Semaste 234254721Semasteuint32_t 235254721SemasteDataVisualization::Categories::GetCount () 236254721Semaste{ 237254721Semaste return GetFormatManager().GetCategoriesCount(); 238254721Semaste} 239254721Semaste 240254721Semastelldb::TypeCategoryImplSP 241254721SemasteDataVisualization::Categories::GetCategoryAtIndex (size_t index) 242254721Semaste{ 243254721Semaste return GetFormatManager().GetCategoryAtIndex(index); 244254721Semaste} 245254721Semaste 246254721Semastebool 247254721SemasteDataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry) 248254721Semaste{ 249262528Semaste return GetFormatManager().GetNamedSummaryContainer().Get(type,entry); 250254721Semaste} 251254721Semaste 252254721Semastevoid 253254721SemasteDataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry) 254254721Semaste{ 255262528Semaste GetFormatManager().GetNamedSummaryContainer().Add(FormatManager::GetValidTypeName(type),entry); 256254721Semaste} 257254721Semaste 258254721Semastebool 259254721SemasteDataVisualization::NamedSummaryFormats::Delete (const ConstString &type) 260254721Semaste{ 261262528Semaste return GetFormatManager().GetNamedSummaryContainer().Delete(type); 262254721Semaste} 263254721Semaste 264254721Semastevoid 265254721SemasteDataVisualization::NamedSummaryFormats::Clear () 266254721Semaste{ 267262528Semaste GetFormatManager().GetNamedSummaryContainer().Clear(); 268254721Semaste} 269254721Semaste 270254721Semastevoid 271296417SdimDataVisualization::NamedSummaryFormats::ForEach (std::function<bool(ConstString, const lldb::TypeSummaryImplSP&)> callback) 272254721Semaste{ 273296417Sdim GetFormatManager().GetNamedSummaryContainer().ForEach(callback); 274254721Semaste} 275254721Semaste 276254721Semasteuint32_t 277254721SemasteDataVisualization::NamedSummaryFormats::GetCount () 278254721Semaste{ 279262528Semaste return GetFormatManager().GetNamedSummaryContainer().GetCount(); 280254721Semaste} 281