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