1 //===-- ValueObjectPrinter.h ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_ValueObjectPrinter_h_
11 #define lldb_ValueObjectPrinter_h_
16 // Other libraries and framework includes
18 #include "lldb/lldb-private.h"
19 #include "lldb/lldb-public.h"
21 #include "lldb/Core/Stream.h"
22 #include "lldb/Core/ValueObject.h"
23 #include "lldb/DataFormatters/TypeSummary.h"
25 namespace lldb_private {
27 struct DumpValueObjectOptions
29 uint32_t m_max_ptr_depth = 0;
30 uint32_t m_max_depth = UINT32_MAX;
31 lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
32 uint32_t m_omit_summary_depth = 0;
33 lldb::Format m_format = lldb::eFormatDefault;
34 lldb::TypeSummaryImplSP m_summary_sp;
35 std::string m_root_valobj_name;
36 bool m_use_synthetic : 1;
37 bool m_scope_already_checked : 1;
38 bool m_flat_output : 1;
39 bool m_ignore_cap : 1;
40 bool m_show_types : 1;
41 bool m_show_location : 1;
43 bool m_hide_root_type : 1;
45 bool m_hide_value : 1;
46 bool m_run_validator : 1;
47 bool m_use_type_display_name : 1;
48 bool m_allow_oneliner_mode : 1;
50 DumpValueObjectOptions() :
53 m_use_synthetic(true),
54 m_scope_already_checked(false),
58 m_show_location(false),
60 m_hide_root_type(false),
63 m_run_validator(false),
64 m_use_type_display_name(true),
65 m_allow_oneliner_mode(true)
68 static const DumpValueObjectOptions
71 static DumpValueObjectOptions g_default_options;
73 return g_default_options;
76 DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default;
78 DumpValueObjectOptions&
79 SetMaximumPointerDepth(uint32_t depth = 0)
81 m_max_ptr_depth = depth;
85 DumpValueObjectOptions&
86 SetMaximumDepth(uint32_t depth = 0)
92 DumpValueObjectOptions&
93 SetShowTypes(bool show = false)
99 DumpValueObjectOptions&
100 SetShowLocation(bool show = false)
102 m_show_location = show;
106 DumpValueObjectOptions&
107 SetUseObjectiveC(bool use = false)
113 DumpValueObjectOptions&
114 SetShowSummary(bool show = true)
117 SetOmitSummaryDepth(UINT32_MAX);
119 SetOmitSummaryDepth(0);
123 DumpValueObjectOptions&
124 SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues)
130 DumpValueObjectOptions&
131 SetUseSyntheticValue(bool use_synthetic = true)
133 m_use_synthetic = use_synthetic;
137 DumpValueObjectOptions&
138 SetScopeChecked(bool check = true)
140 m_scope_already_checked = check;
144 DumpValueObjectOptions&
145 SetFlatOutput(bool flat = false)
147 m_flat_output = flat;
151 DumpValueObjectOptions&
152 SetOmitSummaryDepth(uint32_t depth = 0)
154 m_omit_summary_depth = depth;
158 DumpValueObjectOptions&
159 SetIgnoreCap(bool ignore = false)
161 m_ignore_cap = ignore;
165 DumpValueObjectOptions&
168 SetUseSyntheticValue(false);
169 SetOmitSummaryDepth(UINT32_MAX);
173 SetUseTypeDisplayName(false);
174 SetAllowOnelinerMode(false);
178 DumpValueObjectOptions&
179 SetFormat (lldb::Format format = lldb::eFormatDefault)
185 DumpValueObjectOptions&
186 SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP())
188 m_summary_sp = summary;
192 DumpValueObjectOptions&
193 SetRootValueObjectName (const char* name = NULL)
196 m_root_valobj_name.assign(name);
198 m_root_valobj_name.clear();
202 DumpValueObjectOptions&
203 SetHideRootType (bool hide_root_type = false)
205 m_hide_root_type = hide_root_type;
209 DumpValueObjectOptions&
210 SetHideName (bool hide_name = false)
212 m_hide_name = hide_name;
216 DumpValueObjectOptions&
217 SetHideValue (bool hide_value = false)
219 m_hide_value = hide_value;
223 DumpValueObjectOptions&
224 SetRunValidator (bool run = true)
226 m_run_validator = run;
230 DumpValueObjectOptions&
231 SetUseTypeDisplayName (bool dis = false)
233 m_use_type_display_name = dis;
237 DumpValueObjectOptions&
238 SetAllowOnelinerMode (bool oneliner = false)
240 m_allow_oneliner_mode = oneliner;
246 class ValueObjectPrinter
250 ValueObjectPrinter (ValueObject* valobj,
252 const DumpValueObjectOptions& options);
254 ~ValueObjectPrinter () {}
261 // only this class (and subclasses, if any) should ever be concerned with
262 // the depth mechanism
263 ValueObjectPrinter (ValueObject* valobj,
265 const DumpValueObjectOptions& options,
267 uint32_t curr_depth);
269 // we should actually be using delegating constructors here
270 // but some versions of GCC still have trouble with those
272 Init (ValueObject* valobj,
274 const DumpValueObjectOptions& options,
276 uint32_t curr_depth);
279 GetMostSpecializedValue ();
282 GetDescriptionForDisplay ();
285 GetRootNameForDisplay (const char* if_fail = nullptr);
288 ShouldPrintValueObject ();
291 ShouldPrintValidation ();
306 PrintValidationMarkerIfNeeded ();
309 PrintValidationErrorIfNeeded ();
312 PrintLocationIfNeeded ();
315 PrintTypeIfNeeded ();
318 PrintNameIfNeeded (bool show_type);
321 CheckScopeIfNeeded ();
324 GetSummaryFormatter ();
327 GetValueSummaryError (std::string& value,
328 std::string& summary,
332 PrintValueAndSummaryIfNeeded (bool& value_printed,
333 bool& summary_printed);
336 PrintObjectDescriptionIfNeeded (bool value_printed,
337 bool summary_printed);
340 ShouldPrintChildren (bool is_failed_description,
341 uint32_t& curr_ptr_depth);
344 GetValueObjectForChildrenGeneration ();
347 PrintChildrenPreamble ();
350 PrintChildrenPostamble (bool print_dotdotdot);
353 PrintChild (lldb::ValueObjectSP child_sp,
354 uint32_t curr_ptr_depth);
357 GetMaxNumChildrenToPrint (bool& print_dotdotdot);
360 PrintChildren (uint32_t curr_ptr_depth);
363 PrintChildrenIfNeeded (bool value_printed,
364 bool summary_printed);
367 PrintChildrenOneLiner (bool hide_names);
371 ValueObject *m_orig_valobj;
372 ValueObject *m_valobj;
374 DumpValueObjectOptions options;
376 ClangASTType m_clang_type;
377 uint32_t m_ptr_depth;
378 uint32_t m_curr_depth;
379 LazyBool m_should_print;
383 LazyBool m_is_aggregate;
384 std::pair<TypeSummaryImpl*,bool> m_summary_formatter;
386 std::string m_summary;
388 std::pair<TypeValidatorResult,std::string> m_validation;
390 friend struct StringSummaryFormat;
392 DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter);
395 } // namespace lldb_private
397 #endif // lldb_ValueObjectPrinter_h_