1 //===-- ValueObjectPrinter.cpp -----------------------------------*- C++-*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/DataFormatters/ValueObjectPrinter.h"
11 #include "lldb/Core/ValueObject.h"
12 #include "lldb/DataFormatters/DataVisualization.h"
13 #include "lldb/Interpreter/CommandInterpreter.h"
14 #include "lldb/Target/Language.h"
15 #include "lldb/Target/Target.h"
16 #include "lldb/Utility/Stream.h"
19 using namespace lldb_private;
21 ValueObjectPrinter::ValueObjectPrinter(ValueObject *valobj, Stream *s) {
23 DumpValueObjectOptions options(*valobj);
24 Init(valobj, s, options, m_options.m_max_ptr_depth, 0, nullptr);
26 DumpValueObjectOptions options;
27 Init(valobj, s, options, m_options.m_max_ptr_depth, 0, nullptr);
31 ValueObjectPrinter::ValueObjectPrinter(ValueObject *valobj, Stream *s,
32 const DumpValueObjectOptions &options) {
33 Init(valobj, s, options, m_options.m_max_ptr_depth, 0, nullptr);
36 ValueObjectPrinter::ValueObjectPrinter(
37 ValueObject *valobj, Stream *s, const DumpValueObjectOptions &options,
38 const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth,
39 InstancePointersSetSP printed_instance_pointers) {
40 Init(valobj, s, options, ptr_depth, curr_depth, printed_instance_pointers);
43 void ValueObjectPrinter::Init(
44 ValueObject *valobj, Stream *s, const DumpValueObjectOptions &options,
45 const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth,
46 InstancePointersSetSP printed_instance_pointers) {
47 m_orig_valobj = valobj;
51 m_ptr_depth = ptr_depth;
52 m_curr_depth = curr_depth;
53 assert(m_orig_valobj && "cannot print a NULL ValueObject");
54 assert(m_stream && "cannot print to a NULL Stream");
55 m_should_print = eLazyBoolCalculate;
56 m_is_nil = eLazyBoolCalculate;
57 m_is_uninit = eLazyBoolCalculate;
58 m_is_ptr = eLazyBoolCalculate;
59 m_is_ref = eLazyBoolCalculate;
60 m_is_aggregate = eLazyBoolCalculate;
61 m_is_instance_ptr = eLazyBoolCalculate;
62 m_summary_formatter = {nullptr, false};
66 m_val_summary_ok = false;
67 m_printed_instance_pointers =
68 printed_instance_pointers
69 ? printed_instance_pointers
70 : InstancePointersSetSP(new InstancePointersSet());
73 bool ValueObjectPrinter::PrintValueObject() {
74 if (!GetMostSpecializedValue() || m_valobj == nullptr)
77 if (ShouldPrintValueObject()) {
78 PrintValidationMarkerIfNeeded();
80 PrintLocationIfNeeded();
86 bool value_printed = false;
87 bool summary_printed = false;
90 PrintValueAndSummaryIfNeeded(value_printed, summary_printed);
93 PrintChildrenIfNeeded(value_printed, summary_printed);
97 PrintValidationErrorIfNeeded();
102 bool ValueObjectPrinter::GetMostSpecializedValue() {
105 bool update_success = m_orig_valobj->UpdateValueIfNeeded(true);
106 if (!update_success) {
107 m_valobj = m_orig_valobj;
109 if (m_orig_valobj->IsDynamic()) {
110 if (m_options.m_use_dynamic == eNoDynamicValues) {
111 ValueObject *static_value = m_orig_valobj->GetStaticValue().get();
113 m_valobj = static_value;
115 m_valobj = m_orig_valobj;
117 m_valobj = m_orig_valobj;
119 if (m_options.m_use_dynamic != eNoDynamicValues) {
120 ValueObject *dynamic_value =
121 m_orig_valobj->GetDynamicValue(m_options.m_use_dynamic).get();
123 m_valobj = dynamic_value;
125 m_valobj = m_orig_valobj;
127 m_valobj = m_orig_valobj;
130 if (m_valobj->IsSynthetic()) {
131 if (!m_options.m_use_synthetic) {
132 ValueObject *non_synthetic = m_valobj->GetNonSyntheticValue().get();
134 m_valobj = non_synthetic;
137 if (m_options.m_use_synthetic) {
138 ValueObject *synthetic = m_valobj->GetSyntheticValue().get();
140 m_valobj = synthetic;
144 m_compiler_type = m_valobj->GetCompilerType();
145 m_type_flags = m_compiler_type.GetTypeInfo();
149 const char *ValueObjectPrinter::GetDescriptionForDisplay() {
150 const char *str = m_valobj->GetObjectDescription();
152 str = m_valobj->GetSummaryAsCString();
154 str = m_valobj->GetValueAsCString();
158 const char *ValueObjectPrinter::GetRootNameForDisplay(const char *if_fail) {
159 const char *root_valobj_name = m_options.m_root_valobj_name.empty()
160 ? m_valobj->GetName().AsCString()
161 : m_options.m_root_valobj_name.c_str();
162 return root_valobj_name ? root_valobj_name : if_fail;
165 bool ValueObjectPrinter::ShouldPrintValueObject() {
166 if (m_should_print == eLazyBoolCalculate)
168 (!m_options.m_flat_output || m_type_flags.Test(eTypeHasValue))
171 return m_should_print == eLazyBoolYes;
174 bool ValueObjectPrinter::IsNil() {
175 if (m_is_nil == eLazyBoolCalculate)
176 m_is_nil = m_valobj->IsNilReference() ? eLazyBoolYes : eLazyBoolNo;
177 return m_is_nil == eLazyBoolYes;
180 bool ValueObjectPrinter::IsUninitialized() {
181 if (m_is_uninit == eLazyBoolCalculate)
183 m_valobj->IsUninitializedReference() ? eLazyBoolYes : eLazyBoolNo;
184 return m_is_uninit == eLazyBoolYes;
187 bool ValueObjectPrinter::IsPtr() {
188 if (m_is_ptr == eLazyBoolCalculate)
189 m_is_ptr = m_type_flags.Test(eTypeIsPointer) ? eLazyBoolYes : eLazyBoolNo;
190 return m_is_ptr == eLazyBoolYes;
193 bool ValueObjectPrinter::IsRef() {
194 if (m_is_ref == eLazyBoolCalculate)
195 m_is_ref = m_type_flags.Test(eTypeIsReference) ? eLazyBoolYes : eLazyBoolNo;
196 return m_is_ref == eLazyBoolYes;
199 bool ValueObjectPrinter::IsAggregate() {
200 if (m_is_aggregate == eLazyBoolCalculate)
202 m_type_flags.Test(eTypeHasChildren) ? eLazyBoolYes : eLazyBoolNo;
203 return m_is_aggregate == eLazyBoolYes;
206 bool ValueObjectPrinter::IsInstancePointer() {
207 // you need to do this check on the value's clang type
208 if (m_is_instance_ptr == eLazyBoolCalculate)
209 m_is_instance_ptr = (m_valobj->GetValue().GetCompilerType().GetTypeInfo() &
210 eTypeInstanceIsPointer) != 0
213 if ((eLazyBoolYes == m_is_instance_ptr) && m_valobj->IsBaseClass())
214 m_is_instance_ptr = eLazyBoolNo;
215 return m_is_instance_ptr == eLazyBoolYes;
218 bool ValueObjectPrinter::PrintLocationIfNeeded() {
219 if (m_options.m_show_location) {
220 m_stream->Printf("%s: ", m_valobj->GetLocationAsCString());
226 void ValueObjectPrinter::PrintDecl() {
227 bool show_type = true;
228 // if we are at the root-level and been asked to hide the root's type, then
230 if (m_curr_depth == 0 && m_options.m_hide_root_type)
233 // otherwise decide according to the usual rules (asked to show types -
234 // always at the root level)
235 show_type = m_options.m_show_types ||
236 (m_curr_depth == 0 && !m_options.m_flat_output);
238 StreamString typeName;
240 // always show the type at the root level if it is invalid
242 // Some ValueObjects don't have types (like registers sets). Only print the
243 // type if there is one to print
244 ConstString type_name;
245 if (m_compiler_type.IsValid()) {
246 if (m_options.m_use_type_display_name)
247 type_name = m_valobj->GetDisplayTypeName();
249 type_name = m_valobj->GetQualifiedTypeName();
251 // only show an invalid type name if the user explicitly triggered
253 if (m_options.m_show_types)
254 type_name = ConstString("<invalid type>");
260 std::string type_name_str(type_name.GetCString());
261 if (m_options.m_hide_pointer_value) {
262 for (auto iter = type_name_str.find(" *"); iter != std::string::npos;
263 iter = type_name_str.find(" *")) {
264 type_name_str.erase(iter, 2);
267 typeName.Printf("%s", type_name_str.c_str());
271 StreamString varName;
273 if (m_options.m_flat_output) {
274 // If we are showing types, also qualify the C++ base classes
275 const bool qualify_cxx_base_classes = show_type;
276 if (!m_options.m_hide_name) {
277 m_valobj->GetExpressionPath(varName, qualify_cxx_base_classes);
279 } else if (!m_options.m_hide_name) {
280 const char *name_cstr = GetRootNameForDisplay("");
281 varName.Printf("%s", name_cstr);
284 bool decl_printed = false;
285 if (!m_options.m_decl_printing_helper) {
286 // if the user didn't give us a custom helper, pick one based upon the
287 // language, either the one that this printer is bound to, or the preferred
288 // one for the ValueObject
289 lldb::LanguageType lang_type =
290 (m_options.m_varformat_language == lldb::eLanguageTypeUnknown)
291 ? m_valobj->GetPreferredDisplayLanguage()
292 : m_options.m_varformat_language;
293 if (Language *lang_plugin = Language::FindPlugin(lang_type)) {
294 m_options.m_decl_printing_helper = lang_plugin->GetDeclPrintingHelper();
298 if (m_options.m_decl_printing_helper) {
299 ConstString type_name_cstr(typeName.GetString());
300 ConstString var_name_cstr(varName.GetString());
302 StreamString dest_stream;
303 if (m_options.m_decl_printing_helper(type_name_cstr, var_name_cstr,
304 m_options, dest_stream)) {
306 m_stream->PutCString(dest_stream.GetString());
310 // if the helper failed, or there is none, do a default thing
312 if (!typeName.Empty())
313 m_stream->Printf("(%s) ", typeName.GetData());
314 if (!varName.Empty())
315 m_stream->Printf("%s =", varName.GetData());
316 else if (!m_options.m_hide_name)
317 m_stream->Printf(" =");
321 bool ValueObjectPrinter::CheckScopeIfNeeded() {
322 if (m_options.m_scope_already_checked)
324 return m_valobj->IsInScope();
327 TypeSummaryImpl *ValueObjectPrinter::GetSummaryFormatter(bool null_if_omitted) {
328 if (!m_summary_formatter.second) {
329 TypeSummaryImpl *entry = m_options.m_summary_sp
330 ? m_options.m_summary_sp.get()
331 : m_valobj->GetSummaryFormat().get();
333 if (m_options.m_omit_summary_depth > 0)
335 m_summary_formatter.first = entry;
336 m_summary_formatter.second = true;
338 if (m_options.m_omit_summary_depth > 0 && null_if_omitted)
340 return m_summary_formatter.first;
343 static bool IsPointerValue(const CompilerType &type) {
344 Flags type_flags(type.GetTypeInfo());
345 if (type_flags.AnySet(eTypeInstanceIsPointer | eTypeIsPointer))
346 return type_flags.AllClear(eTypeIsBuiltIn);
350 void ValueObjectPrinter::GetValueSummaryError(std::string &value,
351 std::string &summary,
352 std::string &error) {
353 lldb::Format format = m_options.m_format;
354 // if I am printing synthetized elements, apply the format to those elements
356 if (m_options.m_pointer_as_array)
357 m_valobj->GetValueAsCString(lldb::eFormatDefault, value);
358 else if (format != eFormatDefault && format != m_valobj->GetFormat())
359 m_valobj->GetValueAsCString(format, value);
361 const char *val_cstr = m_valobj->GetValueAsCString();
363 value.assign(val_cstr);
365 const char *err_cstr = m_valobj->GetError().AsCString();
367 error.assign(err_cstr);
369 if (ShouldPrintValueObject()) {
371 summary.assign("nil");
372 else if (IsUninitialized())
373 summary.assign("<uninitialized>");
374 else if (m_options.m_omit_summary_depth == 0) {
375 TypeSummaryImpl *entry = GetSummaryFormatter();
377 m_valobj->GetSummaryAsCString(entry, summary,
378 m_options.m_varformat_language);
380 const char *sum_cstr =
381 m_valobj->GetSummaryAsCString(m_options.m_varformat_language);
383 summary.assign(sum_cstr);
389 bool ValueObjectPrinter::PrintValueAndSummaryIfNeeded(bool &value_printed,
390 bool &summary_printed) {
391 bool error_printed = false;
392 if (ShouldPrintValueObject()) {
393 if (!CheckScopeIfNeeded())
394 m_error.assign("out of scope");
395 if (m_error.empty()) {
396 GetValueSummaryError(m_value, m_summary, m_error);
398 if (m_error.size()) {
399 // we need to support scenarios in which it is actually fine for a value
400 // to have no type but - on the other hand - if we get an error *AND*
401 // have no type, we try to get out gracefully, since most often that
402 // combination means "could not resolve a type" and the default failure
403 // mode is quite ugly
404 if (!m_compiler_type.IsValid()) {
405 m_stream->Printf(" <could not resolve type>");
409 error_printed = true;
410 m_stream->Printf(" <%s>\n", m_error.c_str());
412 // Make sure we have a value and make sure the summary didn't specify
413 // that the value should not be printed - and do not print the value if
414 // this thing is nil (but show the value if the user passes a format
416 TypeSummaryImpl *entry = GetSummaryFormatter();
417 if (!IsNil() && !IsUninitialized() && !m_value.empty() &&
419 (entry->DoesPrintValue(m_valobj) ||
420 m_options.m_format != eFormatDefault) ||
421 m_summary.empty()) &&
422 !m_options.m_hide_value) {
423 if (m_options.m_hide_pointer_value &&
424 IsPointerValue(m_valobj->GetCompilerType())) {
426 m_stream->Printf(" %s", m_value.c_str());
427 value_printed = true;
431 if (m_summary.size()) {
432 m_stream->Printf(" %s", m_summary.c_str());
433 summary_printed = true;
437 return !error_printed;
440 bool ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
441 bool summary_printed) {
442 if (ShouldPrintValueObject()) {
443 // let's avoid the overly verbose no description error for a nil thing
444 if (m_options.m_use_objc && !IsNil() && !IsUninitialized() &&
445 (!m_options.m_pointer_as_array)) {
446 if (!m_options.m_hide_value || !m_options.m_hide_name)
447 m_stream->Printf(" ");
448 const char *object_desc = nullptr;
449 if (value_printed || summary_printed)
450 object_desc = m_valobj->GetObjectDescription();
452 object_desc = GetDescriptionForDisplay();
453 if (object_desc && *object_desc) {
454 // If the description already ends with a \n don't add another one.
455 size_t object_end = strlen(object_desc) - 1;
456 if (object_desc[object_end] == '\n')
457 m_stream->Printf("%s", object_desc);
459 m_stream->Printf("%s\n", object_desc);
461 } else if (!value_printed && !summary_printed)
470 bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
481 bool ValueObjectPrinter::ShouldPrintChildren(
482 bool is_failed_description,
483 DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
484 const bool is_ref = IsRef();
485 const bool is_ptr = IsPtr();
486 const bool is_uninit = IsUninitialized();
491 // if the user has specified an element count, always print children as it is
492 // explicit user demand being honored
493 if (m_options.m_pointer_as_array)
496 TypeSummaryImpl *entry = GetSummaryFormatter();
498 if (m_options.m_use_objc)
501 if (is_failed_description || m_curr_depth < m_options.m_max_depth) {
502 // We will show children for all concrete types. We won't show pointer
503 // contents unless a pointer depth has been specified. We won't reference
504 // contents unless the reference is the root object (depth of zero).
506 // Use a new temporary pointer depth in case we override the current
507 // pointer depth below...
509 if (is_ptr || is_ref) {
510 // We have a pointer or reference whose value is an address. Make sure
511 // that address is not NULL
512 AddressType ptr_address_type;
513 if (m_valobj->GetPointerValue(&ptr_address_type) == 0)
516 const bool is_root_level = m_curr_depth == 0;
518 if (is_ref && is_root_level) {
519 // If this is the root object (depth is zero) that we are showing and
520 // it is a reference, and no pointer depth has been supplied print out
521 // what it references. Don't do this at deeper depths otherwise we can
522 // end up with infinite recursion...
526 return curr_ptr_depth.CanAllowExpansion();
529 return (!entry || entry->DoesPrintChildren(m_valobj) || m_summary.empty());
534 bool ValueObjectPrinter::ShouldExpandEmptyAggregates() {
535 TypeSummaryImpl *entry = GetSummaryFormatter();
540 return entry->DoesPrintEmptyAggregates();
543 ValueObject *ValueObjectPrinter::GetValueObjectForChildrenGeneration() {
547 void ValueObjectPrinter::PrintChildrenPreamble() {
548 if (m_options.m_flat_output) {
549 if (ShouldPrintValueObject())
552 if (ShouldPrintValueObject())
553 m_stream->PutCString(IsRef() ? ": {\n" : " {\n");
554 m_stream->IndentMore();
558 void ValueObjectPrinter::PrintChild(
559 ValueObjectSP child_sp,
560 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
561 const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0;
562 const bool does_consume_ptr_depth =
563 ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
565 DumpValueObjectOptions child_options(m_options);
566 child_options.SetFormat(m_options.m_format)
568 .SetRootValueObjectName();
569 child_options.SetScopeChecked(true)
570 .SetHideName(m_options.m_hide_name)
571 .SetHideValue(m_options.m_hide_value)
572 .SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1
573 ? child_options.m_omit_summary_depth -
578 if (child_sp.get()) {
579 ValueObjectPrinter child_printer(
580 child_sp.get(), m_stream, child_options,
581 does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
582 m_curr_depth + consumed_depth, m_printed_instance_pointers);
583 child_printer.PrintValueObject();
587 uint32_t ValueObjectPrinter::GetMaxNumChildrenToPrint(bool &print_dotdotdot) {
588 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
590 if (m_options.m_pointer_as_array)
591 return m_options.m_pointer_as_array.m_element_count;
593 size_t num_children = synth_m_valobj->GetNumChildren();
594 print_dotdotdot = false;
596 const size_t max_num_children =
597 m_valobj->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
599 if (num_children > max_num_children && !m_options.m_ignore_cap) {
600 print_dotdotdot = true;
601 return max_num_children;
607 void ValueObjectPrinter::PrintChildrenPostamble(bool print_dotdotdot) {
608 if (!m_options.m_flat_output) {
609 if (print_dotdotdot) {
610 m_valobj->GetTargetSP()
612 .GetCommandInterpreter()
613 .ChildrenTruncated();
614 m_stream->Indent("...\n");
616 m_stream->IndentLess();
617 m_stream->Indent("}\n");
621 bool ValueObjectPrinter::ShouldPrintEmptyBrackets(bool value_printed,
622 bool summary_printed) {
623 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
628 if (!m_options.m_reveal_empty_aggregates) {
629 if (value_printed || summary_printed)
633 if (synth_m_valobj->MightHaveChildren())
636 if (m_val_summary_ok)
642 static constexpr size_t PhysicalIndexForLogicalIndex(size_t base, size_t stride,
644 return base + logical * stride;
647 ValueObjectSP ValueObjectPrinter::GenerateChild(ValueObject *synth_valobj,
649 if (m_options.m_pointer_as_array) {
650 // if generating pointer-as-array children, use GetSyntheticArrayMember
651 return synth_valobj->GetSyntheticArrayMember(
652 PhysicalIndexForLogicalIndex(
653 m_options.m_pointer_as_array.m_base_element,
654 m_options.m_pointer_as_array.m_stride, idx),
657 // otherwise, do the usual thing
658 return synth_valobj->GetChildAtIndex(idx, true);
662 void ValueObjectPrinter::PrintChildren(
663 bool value_printed, bool summary_printed,
664 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
665 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
667 bool print_dotdotdot = false;
668 size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
670 bool any_children_printed = false;
672 for (size_t idx = 0; idx < num_children; ++idx) {
673 if (ValueObjectSP child_sp = GenerateChild(synth_m_valobj, idx)) {
674 if (!any_children_printed) {
675 PrintChildrenPreamble();
676 any_children_printed = true;
678 PrintChild(child_sp, curr_ptr_depth);
682 if (any_children_printed)
683 PrintChildrenPostamble(print_dotdotdot);
685 if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
686 if (ShouldPrintValueObject())
687 m_stream->PutCString(" {}\n");
693 } else if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
694 // Aggregate, no children...
695 if (ShouldPrintValueObject()) {
696 // if it has a synthetic value, then don't print {}, the synthetic
697 // children are probably only being used to vend a value
698 if (m_valobj->DoesProvideSyntheticValue() ||
699 !ShouldExpandEmptyAggregates())
700 m_stream->PutCString("\n");
702 m_stream->PutCString(" {}\n");
705 if (ShouldPrintValueObject())
710 bool ValueObjectPrinter::PrintChildrenOneLiner(bool hide_names) {
711 if (!GetMostSpecializedValue() || m_valobj == nullptr)
714 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
716 bool print_dotdotdot = false;
717 size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
720 m_stream->PutChar('(');
722 for (uint32_t idx = 0; idx < num_children; ++idx) {
723 lldb::ValueObjectSP child_sp(synth_m_valobj->GetChildAtIndex(idx, true));
725 child_sp = child_sp->GetQualifiedRepresentationIfAvailable(
726 m_options.m_use_dynamic, m_options.m_use_synthetic);
729 m_stream->PutCString(", ");
731 const char *name = child_sp.get()->GetName().AsCString();
733 m_stream->PutCString(name);
734 m_stream->PutCString(" = ");
737 child_sp->DumpPrintableRepresentation(
738 *m_stream, ValueObject::eValueObjectRepresentationStyleSummary,
740 ValueObject::PrintableRepresentationSpecialCases::eDisable);
745 m_stream->PutCString(", ...)");
747 m_stream->PutChar(')');
752 void ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed,
753 bool summary_printed) {
754 // this flag controls whether we tried to display a description for this
755 // object and failed if that happens, we want to display the children, if any
756 bool is_failed_description =
757 !PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
759 auto curr_ptr_depth = m_ptr_depth;
760 bool print_children =
761 ShouldPrintChildren(is_failed_description, curr_ptr_depth);
763 (curr_ptr_depth.CanAllowExpansion() || m_options.m_show_types ||
764 !m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
765 (m_options.m_pointer_as_array) || m_options.m_show_location)
767 : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
768 bool is_instance_ptr = IsInstancePointer();
769 uint64_t instance_ptr_value = LLDB_INVALID_ADDRESS;
771 if (print_children && is_instance_ptr) {
772 instance_ptr_value = m_valobj->GetValueAsUnsigned(0);
773 if (m_printed_instance_pointers->count(instance_ptr_value)) {
774 // we already printed this instance-is-pointer thing, so don't expand it
775 m_stream->PutCString(" {...}\n");
777 // we're done here - get out fast
780 m_printed_instance_pointers->emplace(
781 instance_ptr_value); // remember this guy for future reference
784 if (print_children) {
786 m_stream->PutChar(' ');
787 PrintChildrenOneLiner(false);
790 PrintChildren(value_printed, summary_printed, curr_ptr_depth);
791 } else if (m_curr_depth >= m_options.m_max_depth && IsAggregate() &&
792 ShouldPrintValueObject()) {
793 m_stream->PutCString("{...}\n");
798 bool ValueObjectPrinter::ShouldPrintValidation() {
799 return m_options.m_run_validator;
802 bool ValueObjectPrinter::PrintValidationMarkerIfNeeded() {
803 if (!ShouldPrintValidation())
806 m_validation = m_valobj->GetValidationStatus();
808 if (TypeValidatorResult::Failure == m_validation.first) {
809 m_stream->Printf("! ");
816 bool ValueObjectPrinter::PrintValidationErrorIfNeeded() {
817 if (!ShouldPrintValidation())
820 if (TypeValidatorResult::Success == m_validation.first)
823 if (m_validation.second.empty())
824 m_validation.second.assign("unknown error");
826 m_stream->Printf(" ! validation error: %s", m_validation.second.c_str());