1 //===-- ValueObjectPrinter.h ---------------------------------------*- C++
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_ValueObjectPrinter_h_
11 #define lldb_ValueObjectPrinter_h_
14 #include "lldb/lldb-private.h"
15 #include "lldb/lldb-public.h"
17 #include "lldb/Utility/Flags.h"
19 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
20 #include "lldb/Symbol/CompilerType.h"
22 namespace lldb_private {
24 class ValueObjectPrinter {
26 ValueObjectPrinter(ValueObject *valobj, Stream *s);
28 ValueObjectPrinter(ValueObject *valobj, Stream *s,
29 const DumpValueObjectOptions &options);
31 ~ValueObjectPrinter() {}
33 bool PrintValueObject();
36 typedef std::set<uint64_t> InstancePointersSet;
37 typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
39 InstancePointersSetSP m_printed_instance_pointers;
41 // only this class (and subclasses, if any) should ever be concerned with the
43 ValueObjectPrinter(ValueObject *valobj, Stream *s,
44 const DumpValueObjectOptions &options,
45 const DumpValueObjectOptions::PointerDepth &ptr_depth,
47 InstancePointersSetSP printed_instance_pointers);
49 // we should actually be using delegating constructors here but some versions
50 // of GCC still have trouble with those
51 void Init(ValueObject *valobj, Stream *s,
52 const DumpValueObjectOptions &options,
53 const DumpValueObjectOptions::PointerDepth &ptr_depth,
55 InstancePointersSetSP printed_instance_pointers);
57 bool GetMostSpecializedValue();
59 const char *GetDescriptionForDisplay();
61 const char *GetRootNameForDisplay(const char *if_fail = nullptr);
63 bool ShouldPrintValueObject();
65 bool ShouldPrintValidation();
69 bool IsUninitialized();
75 bool IsInstancePointer();
79 bool PrintValidationMarkerIfNeeded();
81 bool PrintValidationErrorIfNeeded();
83 bool PrintLocationIfNeeded();
87 bool CheckScopeIfNeeded();
89 bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
91 TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
93 void GetValueSummaryError(std::string &value, std::string &summary,
96 bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
98 bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed);
101 ShouldPrintChildren(bool is_failed_description,
102 DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
104 bool ShouldExpandEmptyAggregates();
106 ValueObject *GetValueObjectForChildrenGeneration();
108 void PrintChildrenPreamble();
110 void PrintChildrenPostamble(bool print_dotdotdot);
112 lldb::ValueObjectSP GenerateChild(ValueObject *synth_valobj, size_t idx);
114 void PrintChild(lldb::ValueObjectSP child_sp,
115 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
117 uint32_t GetMaxNumChildrenToPrint(bool &print_dotdotdot);
120 PrintChildren(bool value_printed, bool summary_printed,
121 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
123 void PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
125 bool PrintChildrenOneLiner(bool hide_names);
128 ValueObject *m_orig_valobj;
129 ValueObject *m_valobj;
131 DumpValueObjectOptions m_options;
133 CompilerType m_compiler_type;
134 DumpValueObjectOptions::PointerDepth m_ptr_depth;
135 uint32_t m_curr_depth;
136 LazyBool m_should_print;
138 LazyBool m_is_uninit;
141 LazyBool m_is_aggregate;
142 LazyBool m_is_instance_ptr;
143 std::pair<TypeSummaryImpl *, bool> m_summary_formatter;
145 std::string m_summary;
147 bool m_val_summary_ok;
148 std::pair<TypeValidatorResult, std::string> m_validation;
150 friend struct StringSummaryFormat;
152 DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter);
155 } // namespace lldb_private
157 #endif // lldb_ValueObjectPrinter_h_