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