1 //===-- ValueObjectPrinter.cpp -----------------------------------*- 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 #include "lldb/DataFormatters/ValueObjectPrinter.h"
14 // Other libraries and framework includes
16 #include "lldb/Core/ValueObject.h"
17 #include "lldb/DataFormatters/DataVisualization.h"
18 #include "lldb/Interpreter/CommandInterpreter.h"
19 #include "lldb/Target/Language.h"
20 #include "lldb/Target/Target.h"
21 #include "lldb/Utility/Stream.h"
24 using namespace lldb_private;
26 ValueObjectPrinter::ValueObjectPrinter(ValueObject *valobj, Stream *s) {
28 DumpValueObjectOptions options(*valobj);
29 Init(valobj, s, options, m_options.m_max_ptr_depth, 0, nullptr);
31 DumpValueObjectOptions options;
32 Init(valobj, s, options, m_options.m_max_ptr_depth, 0, nullptr);
36 ValueObjectPrinter::ValueObjectPrinter(ValueObject *valobj, Stream *s,
37 const DumpValueObjectOptions &options) {
38 Init(valobj, s, options, m_options.m_max_ptr_depth, 0, nullptr);
41 ValueObjectPrinter::ValueObjectPrinter(
42 ValueObject *valobj, Stream *s, const DumpValueObjectOptions &options,
43 const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth,
44 InstancePointersSetSP printed_instance_pointers) {
45 Init(valobj, s, options, ptr_depth, curr_depth, printed_instance_pointers);
48 void ValueObjectPrinter::Init(
49 ValueObject *valobj, Stream *s, const DumpValueObjectOptions &options,
50 const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth,
51 InstancePointersSetSP printed_instance_pointers) {
52 m_orig_valobj = valobj;
56 m_ptr_depth = ptr_depth;
57 m_curr_depth = curr_depth;
58 assert(m_orig_valobj && "cannot print a NULL ValueObject");
59 assert(m_stream && "cannot print to a NULL Stream");
60 m_should_print = eLazyBoolCalculate;
61 m_is_nil = eLazyBoolCalculate;
62 m_is_uninit = eLazyBoolCalculate;
63 m_is_ptr = eLazyBoolCalculate;
64 m_is_ref = eLazyBoolCalculate;
65 m_is_aggregate = eLazyBoolCalculate;
66 m_is_instance_ptr = eLazyBoolCalculate;
67 m_summary_formatter = {nullptr, false};
71 m_val_summary_ok = false;
72 m_printed_instance_pointers =
73 printed_instance_pointers
74 ? printed_instance_pointers
75 : InstancePointersSetSP(new InstancePointersSet());
78 bool ValueObjectPrinter::PrintValueObject() {
79 if (!GetMostSpecializedValue() || m_valobj == nullptr)
82 if (ShouldPrintValueObject()) {
83 PrintValidationMarkerIfNeeded();
85 PrintLocationIfNeeded();
91 bool value_printed = false;
92 bool summary_printed = false;
95 PrintValueAndSummaryIfNeeded(value_printed, summary_printed);
98 PrintChildrenIfNeeded(value_printed, summary_printed);
102 PrintValidationErrorIfNeeded();
107 bool ValueObjectPrinter::GetMostSpecializedValue() {
110 bool update_success = m_orig_valobj->UpdateValueIfNeeded(true);
111 if (!update_success) {
112 m_valobj = m_orig_valobj;
114 if (m_orig_valobj->IsDynamic()) {
115 if (m_options.m_use_dynamic == eNoDynamicValues) {
116 ValueObject *static_value = m_orig_valobj->GetStaticValue().get();
118 m_valobj = static_value;
120 m_valobj = m_orig_valobj;
122 m_valobj = m_orig_valobj;
124 if (m_options.m_use_dynamic != eNoDynamicValues) {
125 ValueObject *dynamic_value =
126 m_orig_valobj->GetDynamicValue(m_options.m_use_dynamic).get();
128 m_valobj = dynamic_value;
130 m_valobj = m_orig_valobj;
132 m_valobj = m_orig_valobj;
135 if (m_valobj->IsSynthetic()) {
136 if (m_options.m_use_synthetic == false) {
137 ValueObject *non_synthetic = m_valobj->GetNonSyntheticValue().get();
139 m_valobj = non_synthetic;
142 if (m_options.m_use_synthetic == true) {
143 ValueObject *synthetic = m_valobj->GetSyntheticValue().get();
145 m_valobj = synthetic;
149 m_compiler_type = m_valobj->GetCompilerType();
150 m_type_flags = m_compiler_type.GetTypeInfo();
154 const char *ValueObjectPrinter::GetDescriptionForDisplay() {
155 const char *str = m_valobj->GetObjectDescription();
157 str = m_valobj->GetSummaryAsCString();
159 str = m_valobj->GetValueAsCString();
163 const char *ValueObjectPrinter::GetRootNameForDisplay(const char *if_fail) {
164 const char *root_valobj_name = m_options.m_root_valobj_name.empty()
165 ? m_valobj->GetName().AsCString()
166 : m_options.m_root_valobj_name.c_str();
167 return root_valobj_name ? root_valobj_name : if_fail;
170 bool ValueObjectPrinter::ShouldPrintValueObject() {
171 if (m_should_print == eLazyBoolCalculate)
173 (m_options.m_flat_output == false || m_type_flags.Test(eTypeHasValue))
176 return m_should_print == eLazyBoolYes;
179 bool ValueObjectPrinter::IsNil() {
180 if (m_is_nil == eLazyBoolCalculate)
181 m_is_nil = m_valobj->IsNilReference() ? eLazyBoolYes : eLazyBoolNo;
182 return m_is_nil == eLazyBoolYes;
185 bool ValueObjectPrinter::IsUninitialized() {
186 if (m_is_uninit == eLazyBoolCalculate)
188 m_valobj->IsUninitializedReference() ? eLazyBoolYes : eLazyBoolNo;
189 return m_is_uninit == eLazyBoolYes;
192 bool ValueObjectPrinter::IsPtr() {
193 if (m_is_ptr == eLazyBoolCalculate)
194 m_is_ptr = m_type_flags.Test(eTypeIsPointer) ? eLazyBoolYes : eLazyBoolNo;
195 return m_is_ptr == eLazyBoolYes;
198 bool ValueObjectPrinter::IsRef() {
199 if (m_is_ref == eLazyBoolCalculate)
200 m_is_ref = m_type_flags.Test(eTypeIsReference) ? eLazyBoolYes : eLazyBoolNo;
201 return m_is_ref == eLazyBoolYes;
204 bool ValueObjectPrinter::IsAggregate() {
205 if (m_is_aggregate == eLazyBoolCalculate)
207 m_type_flags.Test(eTypeHasChildren) ? eLazyBoolYes : eLazyBoolNo;
208 return m_is_aggregate == eLazyBoolYes;
211 bool ValueObjectPrinter::IsInstancePointer() {
212 // you need to do this check on the value's clang type
213 if (m_is_instance_ptr == eLazyBoolCalculate)
214 m_is_instance_ptr = (m_valobj->GetValue().GetCompilerType().GetTypeInfo() &
215 eTypeInstanceIsPointer) != 0
218 if ((eLazyBoolYes == m_is_instance_ptr) && m_valobj->IsBaseClass())
219 m_is_instance_ptr = eLazyBoolNo;
220 return m_is_instance_ptr == eLazyBoolYes;
223 bool ValueObjectPrinter::PrintLocationIfNeeded() {
224 if (m_options.m_show_location) {
225 m_stream->Printf("%s: ", m_valobj->GetLocationAsCString());
231 void ValueObjectPrinter::PrintDecl() {
232 bool show_type = true;
233 // if we are at the root-level and been asked to hide the root's type, then
235 if (m_curr_depth == 0 && m_options.m_hide_root_type)
238 // otherwise decide according to the usual rules (asked to show types -
239 // always at the root level)
240 show_type = m_options.m_show_types ||
241 (m_curr_depth == 0 && !m_options.m_flat_output);
243 StreamString typeName;
245 // always show the type at the root level if it is invalid
247 // Some ValueObjects don't have types (like registers sets). Only print the
248 // type if there is one to print
249 ConstString type_name;
250 if (m_compiler_type.IsValid()) {
251 if (m_options.m_use_type_display_name)
252 type_name = m_valobj->GetDisplayTypeName();
254 type_name = m_valobj->GetQualifiedTypeName();
256 // only show an invalid type name if the user explicitly triggered
258 if (m_options.m_show_types)
259 type_name = ConstString("<invalid type>");
265 std::string type_name_str(type_name.GetCString());
266 if (m_options.m_hide_pointer_value) {
267 for (auto iter = type_name_str.find(" *"); iter != std::string::npos;
268 iter = type_name_str.find(" *")) {
269 type_name_str.erase(iter, 2);
272 typeName.Printf("%s", type_name_str.c_str());
276 StreamString varName;
278 if (m_options.m_flat_output) {
279 // If we are showing types, also qualify the C++ base classes
280 const bool qualify_cxx_base_classes = show_type;
281 if (!m_options.m_hide_name) {
282 m_valobj->GetExpressionPath(varName, qualify_cxx_base_classes);
284 } else if (!m_options.m_hide_name) {
285 const char *name_cstr = GetRootNameForDisplay("");
286 varName.Printf("%s", name_cstr);
289 bool decl_printed = false;
290 if (!m_options.m_decl_printing_helper) {
291 // if the user didn't give us a custom helper, pick one based upon the
292 // language, either the one that this printer is bound to, or the preferred
293 // one for the ValueObject
294 lldb::LanguageType lang_type =
295 (m_options.m_varformat_language == lldb::eLanguageTypeUnknown)
296 ? m_valobj->GetPreferredDisplayLanguage()
297 : m_options.m_varformat_language;
298 if (Language *lang_plugin = Language::FindPlugin(lang_type)) {
299 m_options.m_decl_printing_helper = lang_plugin->GetDeclPrintingHelper();
303 if (m_options.m_decl_printing_helper) {
304 ConstString type_name_cstr(typeName.GetString());
305 ConstString var_name_cstr(varName.GetString());
307 StreamString dest_stream;
308 if (m_options.m_decl_printing_helper(type_name_cstr, var_name_cstr,
309 m_options, dest_stream)) {
311 m_stream->PutCString(dest_stream.GetString());
315 // if the helper failed, or there is none, do a default thing
317 if (!typeName.Empty())
318 m_stream->Printf("(%s) ", typeName.GetData());
319 if (!varName.Empty())
320 m_stream->Printf("%s =", varName.GetData());
321 else if (!m_options.m_hide_name)
322 m_stream->Printf(" =");
326 bool ValueObjectPrinter::CheckScopeIfNeeded() {
327 if (m_options.m_scope_already_checked)
329 return m_valobj->IsInScope();
332 TypeSummaryImpl *ValueObjectPrinter::GetSummaryFormatter(bool null_if_omitted) {
333 if (m_summary_formatter.second == false) {
334 TypeSummaryImpl *entry = m_options.m_summary_sp
335 ? m_options.m_summary_sp.get()
336 : m_valobj->GetSummaryFormat().get();
338 if (m_options.m_omit_summary_depth > 0)
340 m_summary_formatter.first = entry;
341 m_summary_formatter.second = true;
343 if (m_options.m_omit_summary_depth > 0 && null_if_omitted)
345 return m_summary_formatter.first;
348 static bool IsPointerValue(const CompilerType &type) {
349 Flags type_flags(type.GetTypeInfo());
350 if (type_flags.AnySet(eTypeInstanceIsPointer | eTypeIsPointer))
351 return type_flags.AllClear(eTypeIsBuiltIn);
355 void ValueObjectPrinter::GetValueSummaryError(std::string &value,
356 std::string &summary,
357 std::string &error) {
358 lldb::Format format = m_options.m_format;
359 // if I am printing synthetized elements, apply the format to those elements
361 if (m_options.m_pointer_as_array)
362 m_valobj->GetValueAsCString(lldb::eFormatDefault, value);
363 else if (format != eFormatDefault && format != m_valobj->GetFormat())
364 m_valobj->GetValueAsCString(format, value);
366 const char *val_cstr = m_valobj->GetValueAsCString();
368 value.assign(val_cstr);
370 const char *err_cstr = m_valobj->GetError().AsCString();
372 error.assign(err_cstr);
374 if (ShouldPrintValueObject()) {
376 summary.assign("nil");
377 else if (IsUninitialized())
378 summary.assign("<uninitialized>");
379 else if (m_options.m_omit_summary_depth == 0) {
380 TypeSummaryImpl *entry = GetSummaryFormatter();
382 m_valobj->GetSummaryAsCString(entry, summary,
383 m_options.m_varformat_language);
385 const char *sum_cstr =
386 m_valobj->GetSummaryAsCString(m_options.m_varformat_language);
388 summary.assign(sum_cstr);
394 bool ValueObjectPrinter::PrintValueAndSummaryIfNeeded(bool &value_printed,
395 bool &summary_printed) {
396 bool error_printed = false;
397 if (ShouldPrintValueObject()) {
398 if (!CheckScopeIfNeeded())
399 m_error.assign("out of scope");
400 if (m_error.empty()) {
401 GetValueSummaryError(m_value, m_summary, m_error);
403 if (m_error.size()) {
404 // we need to support scenarios in which it is actually fine for a value
405 // to have no type but - on the other hand - if we get an error *AND*
406 // have no type, we try to get out gracefully, since most often that
407 // combination means "could not resolve a type" and the default failure
408 // mode is quite ugly
409 if (!m_compiler_type.IsValid()) {
410 m_stream->Printf(" <could not resolve type>");
414 error_printed = true;
415 m_stream->Printf(" <%s>\n", m_error.c_str());
417 // Make sure we have a value and make sure the summary didn't specify
418 // that the value should not be printed - and do not print the value if
419 // this thing is nil (but show the value if the user passes a format
421 TypeSummaryImpl *entry = GetSummaryFormatter();
422 if (!IsNil() && !IsUninitialized() && !m_value.empty() &&
423 (entry == NULL || (entry->DoesPrintValue(m_valobj) ||
424 m_options.m_format != eFormatDefault) ||
425 m_summary.empty()) &&
426 !m_options.m_hide_value) {
427 if (m_options.m_hide_pointer_value &&
428 IsPointerValue(m_valobj->GetCompilerType())) {
430 m_stream->Printf(" %s", m_value.c_str());
431 value_printed = true;
435 if (m_summary.size()) {
436 m_stream->Printf(" %s", m_summary.c_str());
437 summary_printed = true;
441 return !error_printed;
444 bool ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
445 bool summary_printed) {
446 if (ShouldPrintValueObject()) {
447 // let's avoid the overly verbose no description error for a nil thing
448 if (m_options.m_use_objc && !IsNil() && !IsUninitialized() &&
449 (!m_options.m_pointer_as_array)) {
450 if (!m_options.m_hide_value || !m_options.m_hide_name)
451 m_stream->Printf(" ");
452 const char *object_desc = nullptr;
453 if (value_printed || summary_printed)
454 object_desc = m_valobj->GetObjectDescription();
456 object_desc = GetDescriptionForDisplay();
457 if (object_desc && *object_desc) {
458 // If the description already ends with a \n don't add another one.
459 size_t object_end = strlen(object_desc) - 1;
460 if (object_desc[object_end] == '\n')
461 m_stream->Printf("%s", object_desc);
463 m_stream->Printf("%s\n", object_desc);
465 } else if (value_printed == false && summary_printed == false)
474 bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
485 bool ValueObjectPrinter::ShouldPrintChildren(
486 bool is_failed_description,
487 DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
488 const bool is_ref = IsRef();
489 const bool is_ptr = IsPtr();
490 const bool is_uninit = IsUninitialized();
495 // if the user has specified an element count, always print children as it is
496 // explicit user demand being honored
497 if (m_options.m_pointer_as_array)
500 TypeSummaryImpl *entry = GetSummaryFormatter();
502 if (m_options.m_use_objc)
505 if (is_failed_description || m_curr_depth < m_options.m_max_depth) {
506 // We will show children for all concrete types. We won't show pointer
507 // contents unless a pointer depth has been specified. We won't reference
508 // contents unless the reference is the root object (depth of zero).
510 // Use a new temporary pointer depth in case we override the current
511 // pointer depth below...
513 if (is_ptr || is_ref) {
514 // We have a pointer or reference whose value is an address. Make sure
515 // that address is not NULL
516 AddressType ptr_address_type;
517 if (m_valobj->GetPointerValue(&ptr_address_type) == 0)
520 const bool is_root_level = m_curr_depth == 0;
522 if (is_ref && is_root_level) {
523 // If this is the root object (depth is zero) that we are showing and
524 // it is a reference, and no pointer depth has been supplied print out
525 // what it references. Don't do this at deeper depths otherwise we can
526 // end up with infinite recursion...
530 return curr_ptr_depth.CanAllowExpansion();
533 return (!entry || entry->DoesPrintChildren(m_valobj) || m_summary.empty());
538 bool ValueObjectPrinter::ShouldExpandEmptyAggregates() {
539 TypeSummaryImpl *entry = GetSummaryFormatter();
544 return entry->DoesPrintEmptyAggregates();
547 ValueObject *ValueObjectPrinter::GetValueObjectForChildrenGeneration() {
551 void ValueObjectPrinter::PrintChildrenPreamble() {
552 if (m_options.m_flat_output) {
553 if (ShouldPrintValueObject())
556 if (ShouldPrintValueObject())
557 m_stream->PutCString(IsRef() ? ": {\n" : " {\n");
558 m_stream->IndentMore();
562 void ValueObjectPrinter::PrintChild(
563 ValueObjectSP child_sp,
564 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
565 const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0;
566 const bool does_consume_ptr_depth =
567 ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
569 DumpValueObjectOptions child_options(m_options);
570 child_options.SetFormat(m_options.m_format)
572 .SetRootValueObjectName();
573 child_options.SetScopeChecked(true)
574 .SetHideName(m_options.m_hide_name)
575 .SetHideValue(m_options.m_hide_value)
576 .SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1
577 ? child_options.m_omit_summary_depth -
582 if (child_sp.get()) {
583 ValueObjectPrinter child_printer(
584 child_sp.get(), m_stream, child_options,
585 does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
586 m_curr_depth + consumed_depth, m_printed_instance_pointers);
587 child_printer.PrintValueObject();
591 uint32_t ValueObjectPrinter::GetMaxNumChildrenToPrint(bool &print_dotdotdot) {
592 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
594 if (m_options.m_pointer_as_array)
595 return m_options.m_pointer_as_array.m_element_count;
597 size_t num_children = synth_m_valobj->GetNumChildren();
598 print_dotdotdot = false;
600 const size_t max_num_children =
601 m_valobj->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
603 if (num_children > max_num_children && !m_options.m_ignore_cap) {
604 print_dotdotdot = true;
605 return max_num_children;
611 void ValueObjectPrinter::PrintChildrenPostamble(bool print_dotdotdot) {
612 if (!m_options.m_flat_output) {
613 if (print_dotdotdot) {
614 m_valobj->GetTargetSP()
616 .GetCommandInterpreter()
617 .ChildrenTruncated();
618 m_stream->Indent("...\n");
620 m_stream->IndentLess();
621 m_stream->Indent("}\n");
625 bool ValueObjectPrinter::ShouldPrintEmptyBrackets(bool value_printed,
626 bool summary_printed) {
627 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
632 if (m_options.m_reveal_empty_aggregates == false) {
633 if (value_printed || summary_printed)
637 if (synth_m_valobj->MightHaveChildren())
640 if (m_val_summary_ok)
646 static constexpr size_t PhysicalIndexForLogicalIndex(size_t base, size_t stride,
648 return base + logical * stride;
651 ValueObjectSP ValueObjectPrinter::GenerateChild(ValueObject *synth_valobj,
653 if (m_options.m_pointer_as_array) {
654 // if generating pointer-as-array children, use GetSyntheticArrayMember
655 return synth_valobj->GetSyntheticArrayMember(
656 PhysicalIndexForLogicalIndex(
657 m_options.m_pointer_as_array.m_base_element,
658 m_options.m_pointer_as_array.m_stride, idx),
661 // otherwise, do the usual thing
662 return synth_valobj->GetChildAtIndex(idx, true);
666 void ValueObjectPrinter::PrintChildren(
667 bool value_printed, bool summary_printed,
668 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
669 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
671 bool print_dotdotdot = false;
672 size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
674 bool any_children_printed = false;
676 for (size_t idx = 0; idx < num_children; ++idx) {
677 if (ValueObjectSP child_sp = GenerateChild(synth_m_valobj, idx)) {
678 if (!any_children_printed) {
679 PrintChildrenPreamble();
680 any_children_printed = true;
682 PrintChild(child_sp, curr_ptr_depth);
686 if (any_children_printed)
687 PrintChildrenPostamble(print_dotdotdot);
689 if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
690 if (ShouldPrintValueObject())
691 m_stream->PutCString(" {}\n");
697 } else if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
698 // Aggregate, no children...
699 if (ShouldPrintValueObject()) {
700 // if it has a synthetic value, then don't print {}, the synthetic
701 // children are probably only being used to vend a value
702 if (m_valobj->DoesProvideSyntheticValue() ||
703 !ShouldExpandEmptyAggregates())
704 m_stream->PutCString("\n");
706 m_stream->PutCString(" {}\n");
709 if (ShouldPrintValueObject())
714 bool ValueObjectPrinter::PrintChildrenOneLiner(bool hide_names) {
715 if (!GetMostSpecializedValue() || m_valobj == nullptr)
718 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
720 bool print_dotdotdot = false;
721 size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
724 m_stream->PutChar('(');
726 for (uint32_t idx = 0; idx < num_children; ++idx) {
727 lldb::ValueObjectSP child_sp(synth_m_valobj->GetChildAtIndex(idx, true));
729 child_sp = child_sp->GetQualifiedRepresentationIfAvailable(
730 m_options.m_use_dynamic, m_options.m_use_synthetic);
733 m_stream->PutCString(", ");
735 const char *name = child_sp.get()->GetName().AsCString();
737 m_stream->PutCString(name);
738 m_stream->PutCString(" = ");
741 child_sp->DumpPrintableRepresentation(
742 *m_stream, ValueObject::eValueObjectRepresentationStyleSummary,
744 ValueObject::PrintableRepresentationSpecialCases::eDisable);
749 m_stream->PutCString(", ...)");
751 m_stream->PutChar(')');
756 void ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed,
757 bool summary_printed) {
758 // this flag controls whether we tried to display a description for this
759 // object and failed if that happens, we want to display the children, if any
760 bool is_failed_description =
761 !PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
763 auto curr_ptr_depth = m_ptr_depth;
764 bool print_children =
765 ShouldPrintChildren(is_failed_description, curr_ptr_depth);
767 (curr_ptr_depth.CanAllowExpansion() || m_options.m_show_types ||
768 !m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
769 (m_options.m_pointer_as_array) || m_options.m_show_location)
771 : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
772 bool is_instance_ptr = IsInstancePointer();
773 uint64_t instance_ptr_value = LLDB_INVALID_ADDRESS;
775 if (print_children && is_instance_ptr) {
776 instance_ptr_value = m_valobj->GetValueAsUnsigned(0);
777 if (m_printed_instance_pointers->count(instance_ptr_value)) {
778 // we already printed this instance-is-pointer thing, so don't expand it
779 m_stream->PutCString(" {...}\n");
781 // we're done here - get out fast
784 m_printed_instance_pointers->emplace(
785 instance_ptr_value); // remember this guy for future reference
788 if (print_children) {
790 m_stream->PutChar(' ');
791 PrintChildrenOneLiner(false);
794 PrintChildren(value_printed, summary_printed, curr_ptr_depth);
795 } else if (m_curr_depth >= m_options.m_max_depth && IsAggregate() &&
796 ShouldPrintValueObject()) {
797 m_stream->PutCString("{...}\n");
802 bool ValueObjectPrinter::ShouldPrintValidation() {
803 return m_options.m_run_validator;
806 bool ValueObjectPrinter::PrintValidationMarkerIfNeeded() {
807 if (!ShouldPrintValidation())
810 m_validation = m_valobj->GetValidationStatus();
812 if (TypeValidatorResult::Failure == m_validation.first) {
813 m_stream->Printf("! ");
820 bool ValueObjectPrinter::PrintValidationErrorIfNeeded() {
821 if (!ShouldPrintValidation())
824 if (TypeValidatorResult::Success == m_validation.first)
827 if (m_validation.second.empty())
828 m_validation.second.assign("unknown error");
830 m_stream->Printf(" ! validation error: %s", m_validation.second.c_str());