DataVisualization.cpp revision 280031
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/lldb-python.h" 11254721Semaste 12254721Semaste#include "lldb/DataFormatters/DataVisualization.h" 13254721Semaste 14254721Semaste// C Includes 15254721Semaste// C++ Includes 16254721Semaste// Other libraries and framework includes 17254721Semaste// Project includes 18254721Semaste 19254721Semaste#include "lldb/Core/Debugger.h" 20254721Semaste 21254721Semasteusing namespace lldb; 22254721Semasteusing namespace lldb_private; 23254721Semaste 24254721Semastestatic FormatManager& 25254721SemasteGetFormatManager() 26254721Semaste{ 27254721Semaste static FormatManager g_format_manager; 28254721Semaste return g_format_manager; 29254721Semaste} 30254721Semaste 31254721Semastevoid 32254721SemasteDataVisualization::ForceUpdate () 33254721Semaste{ 34254721Semaste GetFormatManager().Changed(); 35254721Semaste} 36254721Semaste 37254721Semasteuint32_t 38254721SemasteDataVisualization::GetCurrentRevision () 39254721Semaste{ 40254721Semaste return GetFormatManager().GetCurrentRevision(); 41254721Semaste} 42254721Semaste 43258054Semastebool 44258054SemasteDataVisualization::ShouldPrintAsOneLiner (ValueObject& valobj) 45254721Semaste{ 46258054Semaste return GetFormatManager().ShouldPrintAsOneLiner(valobj); 47254721Semaste} 48254721Semaste 49254721Semastelldb::TypeFormatImplSP 50258054SemasteDataVisualization::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) 51254721Semaste{ 52258054Semaste return GetFormatManager().GetFormat(valobj, use_dynamic); 53254721Semaste} 54254721Semaste 55254721Semastelldb::TypeFormatImplSP 56258054SemasteDataVisualization::GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp) 57254721Semaste{ 58258054Semaste return GetFormatManager().GetFormatForType(type_sp); 59254721Semaste} 60254721Semaste 61254721Semastelldb::TypeSummaryImplSP 62258054SemasteDataVisualization::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) 63254721Semaste{ 64254721Semaste return GetFormatManager().GetSummaryFormat(valobj, use_dynamic); 65254721Semaste} 66254721Semaste 67254721Semastelldb::TypeSummaryImplSP 68254721SemasteDataVisualization::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp) 69254721Semaste{ 70254721Semaste return GetFormatManager().GetSummaryForType(type_sp); 71254721Semaste} 72254721Semaste 73254721Semaste#ifndef LLDB_DISABLE_PYTHON 74254721Semastelldb::SyntheticChildrenSP 75254721SemasteDataVisualization::GetSyntheticChildren (ValueObject& valobj, 76254721Semaste lldb::DynamicValueType use_dynamic) 77254721Semaste{ 78254721Semaste return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic); 79254721Semaste} 80254721Semaste#endif 81254721Semaste 82254721Semaste#ifndef LLDB_DISABLE_PYTHON 83254721Semastelldb::SyntheticChildrenSP 84254721SemasteDataVisualization::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp) 85254721Semaste{ 86254721Semaste return GetFormatManager().GetSyntheticChildrenForType(type_sp); 87254721Semaste} 88254721Semaste#endif 89254721Semaste 90254721Semastelldb::TypeFilterImplSP 91254721SemasteDataVisualization::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp) 92254721Semaste{ 93254721Semaste return GetFormatManager().GetFilterForType(type_sp); 94254721Semaste} 95254721Semaste 96254721Semaste#ifndef LLDB_DISABLE_PYTHON 97254721Semastelldb::ScriptedSyntheticChildrenSP 98254721SemasteDataVisualization::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp) 99254721Semaste{ 100254721Semaste return GetFormatManager().GetSyntheticForType(type_sp); 101254721Semaste} 102254721Semaste#endif 103254721Semaste 104280031Sdimlldb::TypeValidatorImplSP 105280031SdimDataVisualization::GetValidator (ValueObject& valobj, lldb::DynamicValueType use_dynamic) 106280031Sdim{ 107280031Sdim return GetFormatManager().GetValidator(valobj, use_dynamic); 108280031Sdim} 109280031Sdim 110280031Sdimlldb::TypeValidatorImplSP 111280031SdimDataVisualization::GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp) 112280031Sdim{ 113280031Sdim return GetFormatManager().GetValidatorForType(type_sp); 114280031Sdim} 115280031Sdim 116254721Semastebool 117254721SemasteDataVisualization::AnyMatches (ConstString type_name, 118254721Semaste TypeCategoryImpl::FormatCategoryItems items, 119254721Semaste bool only_enabled, 120254721Semaste const char** matching_category, 121254721Semaste TypeCategoryImpl::FormatCategoryItems* matching_type) 122254721Semaste{ 123254721Semaste return GetFormatManager().AnyMatches(type_name, 124254721Semaste items, 125254721Semaste only_enabled, 126254721Semaste matching_category, 127254721Semaste matching_type); 128254721Semaste} 129254721Semaste 130254721Semastebool 131254721SemasteDataVisualization::Categories::GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry, 132254721Semaste bool allow_create) 133254721Semaste{ 134254721Semaste entry = GetFormatManager().GetCategory(category, allow_create); 135254721Semaste return (entry.get() != NULL); 136254721Semaste} 137254721Semaste 138254721Semastevoid 139254721SemasteDataVisualization::Categories::Add (const ConstString &category) 140254721Semaste{ 141254721Semaste GetFormatManager().GetCategory(category); 142254721Semaste} 143254721Semaste 144254721Semastebool 145254721SemasteDataVisualization::Categories::Delete (const ConstString &category) 146254721Semaste{ 147254721Semaste GetFormatManager().DisableCategory(category); 148254721Semaste return GetFormatManager().DeleteCategory(category); 149254721Semaste} 150254721Semaste 151254721Semastevoid 152254721SemasteDataVisualization::Categories::Clear () 153254721Semaste{ 154254721Semaste GetFormatManager().ClearCategories(); 155254721Semaste} 156254721Semaste 157254721Semastevoid 158254721SemasteDataVisualization::Categories::Clear (const ConstString &category) 159254721Semaste{ 160254721Semaste GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); 161254721Semaste} 162254721Semaste 163254721Semastevoid 164254721SemasteDataVisualization::Categories::Enable (const ConstString& category, 165254721Semaste TypeCategoryMap::Position pos) 166254721Semaste{ 167254721Semaste if (GetFormatManager().GetCategory(category)->IsEnabled()) 168254721Semaste GetFormatManager().DisableCategory(category); 169254721Semaste GetFormatManager().EnableCategory(category, pos); 170254721Semaste} 171254721Semaste 172254721Semastevoid 173254721SemasteDataVisualization::Categories::Disable (const ConstString& category) 174254721Semaste{ 175254721Semaste if (GetFormatManager().GetCategory(category)->IsEnabled() == true) 176254721Semaste GetFormatManager().DisableCategory(category); 177254721Semaste} 178254721Semaste 179254721Semastevoid 180254721SemasteDataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category, 181254721Semaste TypeCategoryMap::Position pos) 182254721Semaste{ 183254721Semaste if (category.get()) 184254721Semaste { 185254721Semaste if (category->IsEnabled()) 186254721Semaste GetFormatManager().DisableCategory(category); 187254721Semaste GetFormatManager().EnableCategory(category, pos); 188254721Semaste } 189254721Semaste} 190254721Semaste 191254721Semastevoid 192254721SemasteDataVisualization::Categories::Disable (const lldb::TypeCategoryImplSP& category) 193254721Semaste{ 194254721Semaste if (category.get() && category->IsEnabled() == true) 195254721Semaste GetFormatManager().DisableCategory(category); 196254721Semaste} 197254721Semaste 198254721Semastevoid 199280031SdimDataVisualization::Categories::EnableStar () 200280031Sdim{ 201280031Sdim GetFormatManager().EnableAllCategories (); 202280031Sdim} 203280031Sdim 204280031Sdimvoid 205280031SdimDataVisualization::Categories::DisableStar () 206280031Sdim{ 207280031Sdim GetFormatManager().DisableAllCategories(); 208280031Sdim} 209280031Sdim 210280031Sdimvoid 211254721SemasteDataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton) 212254721Semaste{ 213254721Semaste GetFormatManager().LoopThroughCategories(callback, callback_baton); 214254721Semaste} 215254721Semaste 216254721Semasteuint32_t 217254721SemasteDataVisualization::Categories::GetCount () 218254721Semaste{ 219254721Semaste return GetFormatManager().GetCategoriesCount(); 220254721Semaste} 221254721Semaste 222254721Semastelldb::TypeCategoryImplSP 223254721SemasteDataVisualization::Categories::GetCategoryAtIndex (size_t index) 224254721Semaste{ 225254721Semaste return GetFormatManager().GetCategoryAtIndex(index); 226254721Semaste} 227254721Semaste 228254721Semastebool 229254721SemasteDataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry) 230254721Semaste{ 231262528Semaste return GetFormatManager().GetNamedSummaryContainer().Get(type,entry); 232254721Semaste} 233254721Semaste 234254721Semastevoid 235254721SemasteDataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry) 236254721Semaste{ 237262528Semaste GetFormatManager().GetNamedSummaryContainer().Add(FormatManager::GetValidTypeName(type),entry); 238254721Semaste} 239254721Semaste 240254721Semastebool 241254721SemasteDataVisualization::NamedSummaryFormats::Delete (const ConstString &type) 242254721Semaste{ 243262528Semaste return GetFormatManager().GetNamedSummaryContainer().Delete(type); 244254721Semaste} 245254721Semaste 246254721Semastevoid 247254721SemasteDataVisualization::NamedSummaryFormats::Clear () 248254721Semaste{ 249262528Semaste GetFormatManager().GetNamedSummaryContainer().Clear(); 250254721Semaste} 251254721Semaste 252254721Semastevoid 253254721SemasteDataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton) 254254721Semaste{ 255262528Semaste GetFormatManager().GetNamedSummaryContainer().LoopThrough(callback, callback_baton); 256254721Semaste} 257254721Semaste 258254721Semasteuint32_t 259254721SemasteDataVisualization::NamedSummaryFormats::GetCount () 260254721Semaste{ 261262528Semaste return GetFormatManager().GetNamedSummaryContainer().GetCount(); 262254721Semaste} 263