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;
34 lldb::DynamicValueType m_use_dynamic;
36 bool m_scope_already_checked;
38 uint32_t m_omit_summary_depth;
40 lldb::Format m_format;
41 lldb::TypeSummaryImplSP m_summary_sp;
42 std::string m_root_valobj_name;
43 bool m_hide_root_type;
48 DumpValueObjectOptions() :
50 m_max_depth(UINT32_MAX),
52 m_show_location(false),
54 m_use_dynamic(lldb::eNoDynamicValues),
55 m_use_synthetic(true),
56 m_scope_already_checked(false),
58 m_omit_summary_depth(0),
60 m_format (lldb::eFormatDefault),
63 m_hide_root_type(false), // provide a special compact display for "po"
64 m_hide_name(false), // provide a special compact display for "po"
65 m_hide_value(false), // provide a special compact display for "po"
69 static const DumpValueObjectOptions
72 static DumpValueObjectOptions g_default_options;
74 return g_default_options;
77 DumpValueObjectOptions (const DumpValueObjectOptions& rhs) :
78 m_max_ptr_depth(rhs.m_max_ptr_depth),
79 m_max_depth(rhs.m_max_depth),
80 m_show_types(rhs.m_show_types),
81 m_show_location(rhs.m_show_location),
82 m_use_objc(rhs.m_use_objc),
83 m_use_dynamic(rhs.m_use_dynamic),
84 m_use_synthetic(rhs.m_use_synthetic),
85 m_scope_already_checked(rhs.m_scope_already_checked),
86 m_flat_output(rhs.m_flat_output),
87 m_omit_summary_depth(rhs.m_omit_summary_depth),
88 m_ignore_cap(rhs.m_ignore_cap),
89 m_format(rhs.m_format),
90 m_summary_sp(rhs.m_summary_sp),
91 m_root_valobj_name(rhs.m_root_valobj_name),
92 m_hide_root_type(rhs.m_hide_root_type),
93 m_hide_name(rhs.m_hide_name),
94 m_hide_value(rhs.m_hide_value),
95 m_be_raw(rhs.m_be_raw)
98 DumpValueObjectOptions&
99 SetMaximumPointerDepth(uint32_t depth = 0)
101 m_max_ptr_depth = depth;
105 DumpValueObjectOptions&
106 SetMaximumDepth(uint32_t depth = 0)
112 DumpValueObjectOptions&
113 SetShowTypes(bool show = false)
119 DumpValueObjectOptions&
120 SetShowLocation(bool show = false)
122 m_show_location = show;
126 DumpValueObjectOptions&
127 SetUseObjectiveC(bool use = false)
133 DumpValueObjectOptions&
134 SetShowSummary(bool show = true)
137 SetOmitSummaryDepth(UINT32_MAX);
139 SetOmitSummaryDepth(0);
143 DumpValueObjectOptions&
144 SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues)
150 DumpValueObjectOptions&
151 SetUseSyntheticValue(bool use_synthetic = true)
153 m_use_synthetic = use_synthetic;
157 DumpValueObjectOptions&
158 SetScopeChecked(bool check = true)
160 m_scope_already_checked = check;
164 DumpValueObjectOptions&
165 SetFlatOutput(bool flat = false)
167 m_flat_output = flat;
171 DumpValueObjectOptions&
172 SetOmitSummaryDepth(uint32_t depth = 0)
174 m_omit_summary_depth = depth;
178 DumpValueObjectOptions&
179 SetIgnoreCap(bool ignore = false)
181 m_ignore_cap = ignore;
185 DumpValueObjectOptions&
186 SetRawDisplay(bool raw = false)
190 SetUseSyntheticValue(false);
191 SetOmitSummaryDepth(UINT32_MAX);
199 SetUseSyntheticValue(true);
200 SetOmitSummaryDepth(0);
209 DumpValueObjectOptions&
210 SetFormat (lldb::Format format = lldb::eFormatDefault)
216 DumpValueObjectOptions&
217 SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP())
219 m_summary_sp = summary;
223 DumpValueObjectOptions&
224 SetRootValueObjectName (const char* name = NULL)
227 m_root_valobj_name.assign(name);
229 m_root_valobj_name.clear();
233 DumpValueObjectOptions&
234 SetHideRootType (bool hide_root_type = false)
236 m_hide_root_type = hide_root_type;
240 DumpValueObjectOptions&
241 SetHideName (bool hide_name = false)
243 m_hide_name = hide_name;
247 DumpValueObjectOptions&
248 SetHideValue (bool hide_value = false)
250 m_hide_value = hide_value;
255 class ValueObjectPrinter
259 ValueObjectPrinter (ValueObject* valobj,
261 const DumpValueObjectOptions& options);
263 ~ValueObjectPrinter () {}
270 // only this class (and subclasses, if any) should ever be concerned with
271 // the depth mechanism
272 ValueObjectPrinter (ValueObject* valobj,
274 const DumpValueObjectOptions& options,
276 uint32_t curr_depth);
278 // we should actually be using delegating constructors here
279 // but some versions of GCC still have trouble with those
281 Init (ValueObject* valobj,
283 const DumpValueObjectOptions& options,
285 uint32_t curr_depth);
288 GetDynamicValueIfNeeded ();
291 GetDescriptionForDisplay ();
294 GetRootNameForDisplay (const char* if_fail = nullptr);
297 ShouldPrintValueObject ();
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;
389 friend class StringSummaryFormat;
391 DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter);
394 } // namespace lldb_private
396 #endif // lldb_ValueObjectPrinter_h_