Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 1 | //===-- DataVisualization.h -------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef lldb_DataVisualization_h_ |
| 10 | #define lldb_DataVisualization_h_ |
| 11 | |
| 12 | |
| 13 | #include "lldb/DataFormatters/FormatClasses.h" |
| 14 | #include "lldb/DataFormatters/FormatManager.h" |
| 15 | #include "lldb/Utility/ConstString.h" |
| 16 | |
| 17 | namespace lldb_private { |
| 18 | |
| 19 | // this class is the high-level front-end of LLDB Data Visualization code in |
| 20 | // FormatManager.h/cpp is the low-level implementation of this feature clients |
| 21 | // should refer to this class as the entry-point into the data formatters |
| 22 | // unless they have a good reason to bypass this and go to the backend |
| 23 | class DataVisualization { |
| 24 | public: |
| 25 | // use this call to force the FM to consider itself updated even when there |
| 26 | // is no apparent reason for that |
| 27 | static void ForceUpdate(); |
| 28 | |
| 29 | static uint32_t GetCurrentRevision(); |
| 30 | |
| 31 | static bool ShouldPrintAsOneLiner(ValueObject &valobj); |
| 32 | |
| 33 | static lldb::TypeFormatImplSP GetFormat(ValueObject &valobj, |
| 34 | lldb::DynamicValueType use_dynamic); |
| 35 | |
| 36 | static lldb::TypeFormatImplSP |
| 37 | GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp); |
| 38 | |
| 39 | static lldb::TypeSummaryImplSP |
| 40 | GetSummaryFormat(ValueObject &valobj, lldb::DynamicValueType use_dynamic); |
| 41 | |
| 42 | static lldb::TypeSummaryImplSP |
| 43 | GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp); |
| 44 | |
| 45 | static lldb::TypeFilterImplSP |
| 46 | GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp); |
| 47 | |
| 48 | static lldb::ScriptedSyntheticChildrenSP |
| 49 | GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp); |
| 50 | |
| 51 | static lldb::SyntheticChildrenSP |
| 52 | GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic); |
| 53 | |
| 54 | static lldb::TypeValidatorImplSP |
| 55 | GetValidator(ValueObject &valobj, lldb::DynamicValueType use_dynamic); |
| 56 | |
| 57 | static lldb::TypeValidatorImplSP |
| 58 | GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp); |
| 59 | |
| 60 | static bool |
| 61 | AnyMatches(ConstString type_name, |
| 62 | TypeCategoryImpl::FormatCategoryItems items = |
| 63 | TypeCategoryImpl::ALL_ITEM_TYPES, |
| 64 | bool only_enabled = true, const char **matching_category = nullptr, |
| 65 | TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr); |
| 66 | |
| 67 | class NamedSummaryFormats { |
| 68 | public: |
| 69 | static bool GetSummaryFormat(ConstString type, |
| 70 | lldb::TypeSummaryImplSP &entry); |
| 71 | |
| 72 | static void Add(ConstString type, |
| 73 | const lldb::TypeSummaryImplSP &entry); |
| 74 | |
| 75 | static bool Delete(ConstString type); |
| 76 | |
| 77 | static void Clear(); |
| 78 | |
| 79 | static void |
| 80 | ForEach(std::function<bool(ConstString, const lldb::TypeSummaryImplSP &)> |
| 81 | callback); |
| 82 | |
| 83 | static uint32_t GetCount(); |
| 84 | }; |
| 85 | |
| 86 | class Categories { |
| 87 | public: |
| 88 | static bool GetCategory(ConstString category, |
| 89 | lldb::TypeCategoryImplSP &entry, |
| 90 | bool allow_create = true); |
| 91 | |
| 92 | static bool GetCategory(lldb::LanguageType language, |
| 93 | lldb::TypeCategoryImplSP &entry); |
| 94 | |
| 95 | static void Add(ConstString category); |
| 96 | |
| 97 | static bool Delete(ConstString category); |
| 98 | |
| 99 | static void Clear(); |
| 100 | |
| 101 | static void Clear(ConstString category); |
| 102 | |
| 103 | static void Enable(ConstString category, |
| 104 | TypeCategoryMap::Position = TypeCategoryMap::Default); |
| 105 | |
| 106 | static void Enable(lldb::LanguageType lang_type); |
| 107 | |
| 108 | static void Disable(ConstString category); |
| 109 | |
| 110 | static void Disable(lldb::LanguageType lang_type); |
| 111 | |
| 112 | static void Enable(const lldb::TypeCategoryImplSP &category, |
| 113 | TypeCategoryMap::Position = TypeCategoryMap::Default); |
| 114 | |
| 115 | static void Disable(const lldb::TypeCategoryImplSP &category); |
| 116 | |
| 117 | static void EnableStar(); |
| 118 | |
| 119 | static void DisableStar(); |
| 120 | |
| 121 | static void ForEach(TypeCategoryMap::ForEachCallback callback); |
| 122 | |
| 123 | static uint32_t GetCount(); |
| 124 | |
| 125 | static lldb::TypeCategoryImplSP GetCategoryAtIndex(size_t); |
| 126 | }; |
| 127 | }; |
| 128 | |
| 129 | } // namespace lldb_private |
| 130 | |
| 131 | #endif // lldb_DataVisualization_h_ |