Path: blob/main/contrib/llvm-project/lldb/source/DataFormatters/DataVisualization.cpp
39587 views
//===-- DataVisualization.cpp ---------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/DataFormatters/DataVisualization.h"91011using namespace lldb;12using namespace lldb_private;1314static FormatManager &GetFormatManager() {15static FormatManager g_format_manager;16return g_format_manager;17}1819void DataVisualization::ForceUpdate() { GetFormatManager().Changed(); }2021uint32_t DataVisualization::GetCurrentRevision() {22return GetFormatManager().GetCurrentRevision();23}2425bool DataVisualization::ShouldPrintAsOneLiner(ValueObject &valobj) {26return GetFormatManager().ShouldPrintAsOneLiner(valobj);27}2829lldb::TypeFormatImplSP30DataVisualization::GetFormat(ValueObject &valobj,31lldb::DynamicValueType use_dynamic) {32return GetFormatManager().GetFormat(valobj, use_dynamic);33}3435lldb::TypeFormatImplSP36DataVisualization::GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp) {37return GetFormatManager().GetFormatForType(type_sp);38}3940lldb::TypeSummaryImplSP41DataVisualization::GetSummaryFormat(ValueObject &valobj,42lldb::DynamicValueType use_dynamic) {43return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);44}4546lldb::TypeSummaryImplSP47DataVisualization::GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp) {48return GetFormatManager().GetSummaryForType(type_sp);49}5051lldb::SyntheticChildrenSP52DataVisualization::GetSyntheticChildren(ValueObject &valobj,53lldb::DynamicValueType use_dynamic) {54return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);55}5657lldb::TypeFilterImplSP58DataVisualization::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) {59return GetFormatManager().GetFilterForType(type_sp);60}6162lldb::ScriptedSyntheticChildrenSP63DataVisualization::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {64return GetFormatManager().GetSyntheticForType(type_sp);65}6667bool DataVisualization::AnyMatches(68const FormattersMatchCandidate &candidate_type,69TypeCategoryImpl::FormatCategoryItems items, bool only_enabled,70const char **matching_category,71TypeCategoryImpl::FormatCategoryItems *matching_type) {72return GetFormatManager().AnyMatches(candidate_type, items, only_enabled,73matching_category, matching_type);74}7576bool DataVisualization::Categories::GetCategory(ConstString category,77lldb::TypeCategoryImplSP &entry,78bool allow_create) {79entry = GetFormatManager().GetCategory(category, allow_create);80return (entry.get() != nullptr);81}8283bool DataVisualization::Categories::GetCategory(84lldb::LanguageType language, lldb::TypeCategoryImplSP &entry) {85if (LanguageCategory *lang_category =86GetFormatManager().GetCategoryForLanguage(language))87entry = lang_category->GetCategory();88return (entry.get() != nullptr);89}9091void DataVisualization::Categories::Add(ConstString category) {92GetFormatManager().GetCategory(category);93}9495bool DataVisualization::Categories::Delete(ConstString category) {96GetFormatManager().DisableCategory(category);97return GetFormatManager().DeleteCategory(category);98}99100void DataVisualization::Categories::Clear() {101GetFormatManager().ClearCategories();102}103104void DataVisualization::Categories::Clear(ConstString category) {105GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary);106}107108void DataVisualization::Categories::Enable(ConstString category,109TypeCategoryMap::Position pos) {110if (GetFormatManager().GetCategory(category)->IsEnabled())111GetFormatManager().DisableCategory(category);112GetFormatManager().EnableCategory(category, pos, {});113}114115void DataVisualization::Categories::Enable(lldb::LanguageType lang_type) {116if (LanguageCategory *lang_category =117GetFormatManager().GetCategoryForLanguage(lang_type))118lang_category->Enable();119}120121void DataVisualization::Categories::Disable(ConstString category) {122if (GetFormatManager().GetCategory(category)->IsEnabled())123GetFormatManager().DisableCategory(category);124}125126void DataVisualization::Categories::Disable(lldb::LanguageType lang_type) {127if (LanguageCategory *lang_category =128GetFormatManager().GetCategoryForLanguage(lang_type))129lang_category->Disable();130}131132void DataVisualization::Categories::Enable(133const lldb::TypeCategoryImplSP &category, TypeCategoryMap::Position pos) {134if (category.get()) {135if (category->IsEnabled())136GetFormatManager().DisableCategory(category);137GetFormatManager().EnableCategory(category, pos);138}139}140141void DataVisualization::Categories::Disable(142const lldb::TypeCategoryImplSP &category) {143if (category.get() && category->IsEnabled())144GetFormatManager().DisableCategory(category);145}146147void DataVisualization::Categories::EnableStar() {148GetFormatManager().EnableAllCategories();149}150151void DataVisualization::Categories::DisableStar() {152GetFormatManager().DisableAllCategories();153}154155void DataVisualization::Categories::ForEach(156TypeCategoryMap::ForEachCallback callback) {157GetFormatManager().ForEachCategory(callback);158}159160uint32_t DataVisualization::Categories::GetCount() {161return GetFormatManager().GetCategoriesCount();162}163164lldb::TypeCategoryImplSP165DataVisualization::Categories::GetCategoryAtIndex(size_t index) {166return GetFormatManager().GetCategoryAtIndex(index);167}168169bool DataVisualization::NamedSummaryFormats::GetSummaryFormat(170ConstString type, lldb::TypeSummaryImplSP &entry) {171return GetFormatManager().GetNamedSummaryContainer().GetExact(type, entry);172}173174void DataVisualization::NamedSummaryFormats::Add(175ConstString type, const lldb::TypeSummaryImplSP &entry) {176GetFormatManager().GetNamedSummaryContainer().Add(type, entry);177}178179bool DataVisualization::NamedSummaryFormats::Delete(ConstString type) {180return GetFormatManager().GetNamedSummaryContainer().Delete(type);181}182183void DataVisualization::NamedSummaryFormats::Clear() {184GetFormatManager().GetNamedSummaryContainer().Clear();185}186187void DataVisualization::NamedSummaryFormats::ForEach(188std::function<bool(const TypeMatcher &, const lldb::TypeSummaryImplSP &)>189callback) {190GetFormatManager().GetNamedSummaryContainer().ForEach(callback);191}192193uint32_t DataVisualization::NamedSummaryFormats::GetCount() {194return GetFormatManager().GetNamedSummaryContainer().GetCount();195}196197198