]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / DataFormatters / ValueObjectPrinter.h
1 //===-- ValueObjectPrinter.h ---------------------------------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef lldb_ValueObjectPrinter_h_
12 #define lldb_ValueObjectPrinter_h_
13
14 // C Includes
15 // C++ Includes
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/lldb-private.h"
20 #include "lldb/lldb-public.h"
21
22 #include "lldb/Utility/Flags.h"
23
24 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
25 #include "lldb/Symbol/CompilerType.h"
26
27 //#include <functional>
28 //#include <memory>
29 //#include <set>
30
31 namespace lldb_private {
32
33 class ValueObjectPrinter {
34 public:
35   ValueObjectPrinter(ValueObject *valobj, Stream *s);
36
37   ValueObjectPrinter(ValueObject *valobj, Stream *s,
38                      const DumpValueObjectOptions &options);
39
40   ~ValueObjectPrinter() {}
41
42   bool PrintValueObject();
43
44 protected:
45   typedef std::set<uint64_t> InstancePointersSet;
46   typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
47
48   InstancePointersSetSP m_printed_instance_pointers;
49
50   // only this class (and subclasses, if any) should ever be concerned with the
51   // depth mechanism
52   ValueObjectPrinter(ValueObject *valobj, Stream *s,
53                      const DumpValueObjectOptions &options,
54                      const DumpValueObjectOptions::PointerDepth &ptr_depth,
55                      uint32_t curr_depth,
56                      InstancePointersSetSP printed_instance_pointers);
57
58   // we should actually be using delegating constructors here but some versions
59   // of GCC still have trouble with those
60   void Init(ValueObject *valobj, Stream *s,
61             const DumpValueObjectOptions &options,
62             const DumpValueObjectOptions::PointerDepth &ptr_depth,
63             uint32_t curr_depth,
64             InstancePointersSetSP printed_instance_pointers);
65
66   bool GetMostSpecializedValue();
67
68   const char *GetDescriptionForDisplay();
69
70   const char *GetRootNameForDisplay(const char *if_fail = nullptr);
71
72   bool ShouldPrintValueObject();
73
74   bool ShouldPrintValidation();
75
76   bool IsNil();
77
78   bool IsUninitialized();
79
80   bool IsPtr();
81
82   bool IsRef();
83
84   bool IsInstancePointer();
85
86   bool IsAggregate();
87
88   bool PrintValidationMarkerIfNeeded();
89
90   bool PrintValidationErrorIfNeeded();
91
92   bool PrintLocationIfNeeded();
93
94   void PrintDecl();
95
96   bool CheckScopeIfNeeded();
97
98   bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
99
100   TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
101
102   void GetValueSummaryError(std::string &value, std::string &summary,
103                             std::string &error);
104
105   bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
106
107   bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed);
108
109   bool
110   ShouldPrintChildren(bool is_failed_description,
111                       DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
112
113   bool ShouldExpandEmptyAggregates();
114
115   ValueObject *GetValueObjectForChildrenGeneration();
116
117   void PrintChildrenPreamble();
118
119   void PrintChildrenPostamble(bool print_dotdotdot);
120
121   lldb::ValueObjectSP GenerateChild(ValueObject *synth_valobj, size_t idx);
122
123   void PrintChild(lldb::ValueObjectSP child_sp,
124                   const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
125
126   uint32_t GetMaxNumChildrenToPrint(bool &print_dotdotdot);
127
128   void
129   PrintChildren(bool value_printed, bool summary_printed,
130                 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
131
132   void PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
133
134   bool PrintChildrenOneLiner(bool hide_names);
135
136 private:
137   ValueObject *m_orig_valobj;
138   ValueObject *m_valobj;
139   Stream *m_stream;
140   DumpValueObjectOptions m_options;
141   Flags m_type_flags;
142   CompilerType m_compiler_type;
143   DumpValueObjectOptions::PointerDepth m_ptr_depth;
144   uint32_t m_curr_depth;
145   LazyBool m_should_print;
146   LazyBool m_is_nil;
147   LazyBool m_is_uninit;
148   LazyBool m_is_ptr;
149   LazyBool m_is_ref;
150   LazyBool m_is_aggregate;
151   LazyBool m_is_instance_ptr;
152   std::pair<TypeSummaryImpl *, bool> m_summary_formatter;
153   std::string m_value;
154   std::string m_summary;
155   std::string m_error;
156   bool m_val_summary_ok;
157   std::pair<TypeValidatorResult, std::string> m_validation;
158
159   friend struct StringSummaryFormat;
160
161   DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter);
162 };
163
164 } // namespace lldb_private
165
166 #endif // lldb_ValueObjectPrinter_h_