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