1 //===-- ValueObjectPrinter.h ---------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef lldb_ValueObjectPrinter_h_
12 #define lldb_ValueObjectPrinter_h_
17 // Other libraries and framework includes
19 #include "lldb/lldb-private.h"
20 #include "lldb/lldb-public.h"
22 #include "lldb/Utility/Flags.h"
24 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
25 #include "lldb/Symbol/CompilerType.h"
27 //#include <functional>
31 namespace lldb_private {
33 class ValueObjectPrinter {
35 ValueObjectPrinter(ValueObject *valobj, Stream *s);
37 ValueObjectPrinter(ValueObject *valobj, Stream *s,
38 const DumpValueObjectOptions &options);
40 ~ValueObjectPrinter() {}
42 bool PrintValueObject();
45 typedef std::set<uint64_t> InstancePointersSet;
46 typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
48 InstancePointersSetSP m_printed_instance_pointers;
50 // only this class (and subclasses, if any) should ever be concerned with
51 // the depth mechanism
52 ValueObjectPrinter(ValueObject *valobj, Stream *s,
53 const DumpValueObjectOptions &options,
54 const DumpValueObjectOptions::PointerDepth &ptr_depth,
56 InstancePointersSetSP printed_instance_pointers);
58 // we should actually be using delegating constructors here
59 // but some versions of GCC still have trouble with those
60 void Init(ValueObject *valobj, Stream *s,
61 const DumpValueObjectOptions &options,
62 const DumpValueObjectOptions::PointerDepth &ptr_depth,
64 InstancePointersSetSP printed_instance_pointers);
66 bool GetMostSpecializedValue();
68 const char *GetDescriptionForDisplay();
70 const char *GetRootNameForDisplay(const char *if_fail = nullptr);
72 bool ShouldPrintValueObject();
74 bool ShouldPrintValidation();
78 bool IsUninitialized();
84 bool IsInstancePointer();
88 bool PrintValidationMarkerIfNeeded();
90 bool PrintValidationErrorIfNeeded();
92 bool PrintLocationIfNeeded();
96 bool CheckScopeIfNeeded();
98 bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
100 TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
102 void GetValueSummaryError(std::string &value, std::string &summary,
105 bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
107 bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed);
110 ShouldPrintChildren(bool is_failed_description,
111 DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
113 bool ShouldExpandEmptyAggregates();
115 ValueObject *GetValueObjectForChildrenGeneration();
117 void PrintChildrenPreamble();
119 void PrintChildrenPostamble(bool print_dotdotdot);
121 lldb::ValueObjectSP GenerateChild(ValueObject *synth_valobj, size_t idx);
123 void PrintChild(lldb::ValueObjectSP child_sp,
124 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
126 uint32_t GetMaxNumChildrenToPrint(bool &print_dotdotdot);
129 PrintChildren(bool value_printed, bool summary_printed,
130 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
132 void PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
134 bool PrintChildrenOneLiner(bool hide_names);
137 ValueObject *m_orig_valobj;
138 ValueObject *m_valobj;
140 DumpValueObjectOptions m_options;
142 CompilerType m_compiler_type;
143 DumpValueObjectOptions::PointerDepth m_ptr_depth;
144 uint32_t m_curr_depth;
145 LazyBool m_should_print;
147 LazyBool m_is_uninit;
150 LazyBool m_is_aggregate;
151 LazyBool m_is_instance_ptr;
152 std::pair<TypeSummaryImpl *, bool> m_summary_formatter;
154 std::string m_summary;
156 bool m_val_summary_ok;
157 std::pair<TypeValidatorResult, std::string> m_validation;
159 friend struct StringSummaryFormat;
161 DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter);
164 } // namespace lldb_private
166 #endif // lldb_ValueObjectPrinter_h_