File indexing completed on 2026-05-10 08:42:47
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
0010 #define LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
0011
0012 #include "lldb/lldb-private.h"
0013 #include "lldb/lldb-public.h"
0014
0015 #include "lldb/Utility/Flags.h"
0016
0017 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
0018 #include "lldb/Symbol/CompilerType.h"
0019
0020 namespace lldb_private {
0021
0022 class ValueObjectPrinter {
0023
0024
0025
0026
0027
0028 public:
0029 ValueObjectPrinter(ValueObject &valobj, Stream *s);
0030
0031 ValueObjectPrinter(ValueObject &valobj, Stream *s,
0032 const DumpValueObjectOptions &options);
0033
0034 ~ValueObjectPrinter() = default;
0035
0036 llvm::Error PrintValueObject();
0037
0038 protected:
0039 typedef std::set<uint64_t> InstancePointersSet;
0040 typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
0041
0042 InstancePointersSetSP m_printed_instance_pointers;
0043
0044
0045
0046 ValueObjectPrinter(ValueObject &valobj, Stream *s,
0047 const DumpValueObjectOptions &options,
0048 const DumpValueObjectOptions::PointerDepth &ptr_depth,
0049 uint32_t curr_depth,
0050 InstancePointersSetSP printed_instance_pointers);
0051
0052
0053
0054 void Init(ValueObject &valobj, Stream *s,
0055 const DumpValueObjectOptions &options,
0056 const DumpValueObjectOptions::PointerDepth &ptr_depth,
0057 uint32_t curr_depth,
0058 InstancePointersSetSP printed_instance_pointers);
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 ValueObject &GetMostSpecializedValue();
0075
0076 void SetupMostSpecializedValue();
0077
0078 llvm::Expected<std::string> GetDescriptionForDisplay();
0079
0080 const char *GetRootNameForDisplay();
0081
0082 bool ShouldPrintValueObject();
0083
0084 bool IsNil();
0085
0086 bool IsUninitialized();
0087
0088 bool IsPtr();
0089
0090 bool IsRef();
0091
0092 bool IsInstancePointer();
0093
0094 bool IsAggregate();
0095
0096 bool PrintLocationIfNeeded();
0097
0098 void PrintDecl();
0099
0100 bool CheckScopeIfNeeded();
0101
0102 bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
0103
0104 TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
0105
0106 void GetValueSummaryError(std::string &value, std::string &summary,
0107 std::string &error);
0108
0109 bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
0110
0111 llvm::Error PrintObjectDescriptionIfNeeded(bool value_printed,
0112 bool summary_printed);
0113
0114 bool
0115 ShouldPrintChildren(DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
0116
0117 bool ShouldExpandEmptyAggregates();
0118
0119 ValueObject &GetValueObjectForChildrenGeneration();
0120
0121 void PrintChildrenPreamble(bool value_printed, bool summary_printed);
0122
0123 void PrintChildrenPostamble(bool print_dotdotdot);
0124
0125 lldb::ValueObjectSP GenerateChild(ValueObject &synth_valobj, size_t idx);
0126
0127 void PrintChild(lldb::ValueObjectSP child_sp,
0128 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
0129
0130 llvm::Expected<uint32_t> GetMaxNumChildrenToPrint(bool &print_dotdotdot);
0131
0132 void
0133 PrintChildren(bool value_printed, bool summary_printed,
0134 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
0135
0136 llvm::Error PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
0137
0138 bool PrintChildrenOneLiner(bool hide_names);
0139
0140 bool HasReachedMaximumDepth();
0141
0142 private:
0143 bool ShouldShowName() const;
0144
0145 ValueObject &m_orig_valobj;
0146
0147
0148 ValueObject *m_cached_valobj;
0149 Stream *m_stream;
0150 DumpValueObjectOptions m_options;
0151 Flags m_type_flags;
0152 CompilerType m_compiler_type;
0153 DumpValueObjectOptions::PointerDepth m_ptr_depth;
0154 uint32_t m_curr_depth;
0155 LazyBool m_should_print;
0156 LazyBool m_is_nil;
0157 LazyBool m_is_uninit;
0158 LazyBool m_is_ptr;
0159 LazyBool m_is_ref;
0160 LazyBool m_is_aggregate;
0161 LazyBool m_is_instance_ptr;
0162 std::pair<TypeSummaryImpl *, bool> m_summary_formatter;
0163 std::string m_value;
0164 std::string m_summary;
0165 std::string m_error;
0166 bool m_val_summary_ok;
0167
0168 friend struct StringSummaryFormat;
0169
0170 ValueObjectPrinter(const ValueObjectPrinter &) = delete;
0171 const ValueObjectPrinter &operator=(const ValueObjectPrinter &) = delete;
0172 };
0173
0174 }
0175
0176 #endif