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