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_
15 #include "lldb/lldb-private.h"
16 #include "lldb/lldb-public.h"
18 #include "lldb/Utility/Flags.h"
20 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
21 #include "lldb/Symbol/CompilerType.h"
23 namespace lldb_private {
25 class ValueObjectPrinter {
27 ValueObjectPrinter(ValueObject *valobj, Stream *s);
29 ValueObjectPrinter(ValueObject *valobj, Stream *s,
30 const DumpValueObjectOptions &options);
32 ~ValueObjectPrinter() {}
34 bool PrintValueObject();
37 typedef std::set<uint64_t> InstancePointersSet;
38 typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
40 InstancePointersSetSP m_printed_instance_pointers;
42 // only this class (and subclasses, if any) should ever be concerned with the
44 ValueObjectPrinter(ValueObject *valobj, Stream *s,
45 const DumpValueObjectOptions &options,
46 const DumpValueObjectOptions::PointerDepth &ptr_depth,
48 InstancePointersSetSP printed_instance_pointers);
50 // we should actually be using delegating constructors here but some versions
51 // of GCC still have trouble with those
52 void Init(ValueObject *valobj, Stream *s,
53 const DumpValueObjectOptions &options,
54 const DumpValueObjectOptions::PointerDepth &ptr_depth,
56 InstancePointersSetSP printed_instance_pointers);
58 bool GetMostSpecializedValue();
60 const char *GetDescriptionForDisplay();
62 const char *GetRootNameForDisplay(const char *if_fail = nullptr);
64 bool ShouldPrintValueObject();
66 bool ShouldPrintValidation();
70 bool IsUninitialized();
76 bool IsInstancePointer();
80 bool PrintValidationMarkerIfNeeded();
82 bool PrintValidationErrorIfNeeded();
84 bool PrintLocationIfNeeded();
88 bool CheckScopeIfNeeded();
90 bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
92 TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
94 void GetValueSummaryError(std::string &value, std::string &summary,
97 bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
99 bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed);
102 ShouldPrintChildren(bool is_failed_description,
103 DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
105 bool ShouldExpandEmptyAggregates();
107 ValueObject *GetValueObjectForChildrenGeneration();
109 void PrintChildrenPreamble();
111 void PrintChildrenPostamble(bool print_dotdotdot);
113 lldb::ValueObjectSP GenerateChild(ValueObject *synth_valobj, size_t idx);
115 void PrintChild(lldb::ValueObjectSP child_sp,
116 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
118 uint32_t GetMaxNumChildrenToPrint(bool &print_dotdotdot);
121 PrintChildren(bool value_printed, bool summary_printed,
122 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
124 void PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
126 bool PrintChildrenOneLiner(bool hide_names);
129 ValueObject *m_orig_valobj;
130 ValueObject *m_valobj;
132 DumpValueObjectOptions m_options;
134 CompilerType m_compiler_type;
135 DumpValueObjectOptions::PointerDepth m_ptr_depth;
136 uint32_t m_curr_depth;
137 LazyBool m_should_print;
139 LazyBool m_is_uninit;
142 LazyBool m_is_aggregate;
143 LazyBool m_is_instance_ptr;
144 std::pair<TypeSummaryImpl *, bool> m_summary_formatter;
146 std::string m_summary;
148 bool m_val_summary_ok;
149 std::pair<TypeValidatorResult, std::string> m_validation;
151 friend struct StringSummaryFormat;
153 DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter);
156 } // namespace lldb_private
158 #endif // lldb_ValueObjectPrinter_h_