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 PrintLocationIfNeeded();
84 bool value_printed
= false;
85 bool summary_printed
= false;
88 PrintValueAndSummaryIfNeeded(value_printed
, summary_printed
);
91 PrintChildrenIfNeeded(value_printed
, summary_printed
);
98 bool ValueObjectPrinter::GetMostSpecializedValue() {
101 bool update_success
= m_orig_valobj
->UpdateValueIfNeeded(true);
102 if (!update_success
) {
103 m_valobj
= m_orig_valobj
;
105 if (m_orig_valobj
->IsDynamic()) {
106 if (m_options
.m_use_dynamic
== eNoDynamicValues
) {
107 ValueObject
*static_value
= m_orig_valobj
->GetStaticValue().get();
109 m_valobj
= static_value
;
111 m_valobj
= m_orig_valobj
;
113 m_valobj
= m_orig_valobj
;
115 if (m_options
.m_use_dynamic
!= eNoDynamicValues
) {
116 ValueObject
*dynamic_value
=
117 m_orig_valobj
->GetDynamicValue(m_options
.m_use_dynamic
).get();
119 m_valobj
= dynamic_value
;
121 m_valobj
= m_orig_valobj
;
123 m_valobj
= m_orig_valobj
;
126 if (m_valobj
->IsSynthetic()) {
127 if (!m_options
.m_use_synthetic
) {
128 ValueObject
*non_synthetic
= m_valobj
->GetNonSyntheticValue().get();
130 m_valobj
= non_synthetic
;
133 if (m_options
.m_use_synthetic
) {
134 ValueObject
*synthetic
= m_valobj
->GetSyntheticValue().get();
136 m_valobj
= synthetic
;
140 m_compiler_type
= m_valobj
->GetCompilerType();
141 m_type_flags
= m_compiler_type
.GetTypeInfo();
145 const char *ValueObjectPrinter::GetDescriptionForDisplay() {
146 const char *str
= m_valobj
->GetObjectDescription();
148 str
= m_valobj
->GetSummaryAsCString();
150 str
= m_valobj
->GetValueAsCString();
154 const char *ValueObjectPrinter::GetRootNameForDisplay(const char *if_fail
) {
155 const char *root_valobj_name
= m_options
.m_root_valobj_name
.empty()
156 ? m_valobj
->GetName().AsCString()
157 : m_options
.m_root_valobj_name
.c_str();
158 return root_valobj_name
? root_valobj_name
: if_fail
;
161 bool ValueObjectPrinter::ShouldPrintValueObject() {
162 if (m_should_print
== eLazyBoolCalculate
)
164 (!m_options
.m_flat_output
|| m_type_flags
.Test(eTypeHasValue
))
167 return m_should_print
== eLazyBoolYes
;
170 bool ValueObjectPrinter::IsNil() {
171 if (m_is_nil
== eLazyBoolCalculate
)
172 m_is_nil
= m_valobj
->IsNilReference() ? eLazyBoolYes
: eLazyBoolNo
;
173 return m_is_nil
== eLazyBoolYes
;
176 bool ValueObjectPrinter::IsUninitialized() {
177 if (m_is_uninit
== eLazyBoolCalculate
)
179 m_valobj
->IsUninitializedReference() ? eLazyBoolYes
: eLazyBoolNo
;
180 return m_is_uninit
== eLazyBoolYes
;
183 bool ValueObjectPrinter::IsPtr() {
184 if (m_is_ptr
== eLazyBoolCalculate
)
185 m_is_ptr
= m_type_flags
.Test(eTypeIsPointer
) ? eLazyBoolYes
: eLazyBoolNo
;
186 return m_is_ptr
== eLazyBoolYes
;
189 bool ValueObjectPrinter::IsRef() {
190 if (m_is_ref
== eLazyBoolCalculate
)
191 m_is_ref
= m_type_flags
.Test(eTypeIsReference
) ? eLazyBoolYes
: eLazyBoolNo
;
192 return m_is_ref
== eLazyBoolYes
;
195 bool ValueObjectPrinter::IsAggregate() {
196 if (m_is_aggregate
== eLazyBoolCalculate
)
198 m_type_flags
.Test(eTypeHasChildren
) ? eLazyBoolYes
: eLazyBoolNo
;
199 return m_is_aggregate
== eLazyBoolYes
;
202 bool ValueObjectPrinter::IsInstancePointer() {
203 // you need to do this check on the value's clang type
204 if (m_is_instance_ptr
== eLazyBoolCalculate
)
205 m_is_instance_ptr
= (m_valobj
->GetValue().GetCompilerType().GetTypeInfo() &
206 eTypeInstanceIsPointer
) != 0
209 if ((eLazyBoolYes
== m_is_instance_ptr
) && m_valobj
->IsBaseClass())
210 m_is_instance_ptr
= eLazyBoolNo
;
211 return m_is_instance_ptr
== eLazyBoolYes
;
214 bool ValueObjectPrinter::PrintLocationIfNeeded() {
215 if (m_options
.m_show_location
) {
216 m_stream
->Printf("%s: ", m_valobj
->GetLocationAsCString());
222 void ValueObjectPrinter::PrintDecl() {
223 bool show_type
= true;
224 // if we are at the root-level and been asked to hide the root's type, then
226 if (m_curr_depth
== 0 && m_options
.m_hide_root_type
)
229 // otherwise decide according to the usual rules (asked to show types -
230 // always at the root level)
231 show_type
= m_options
.m_show_types
||
232 (m_curr_depth
== 0 && !m_options
.m_flat_output
);
234 StreamString typeName
;
236 // always show the type at the root level if it is invalid
238 // Some ValueObjects don't have types (like registers sets). Only print the
239 // type if there is one to print
240 ConstString type_name
;
241 if (m_compiler_type
.IsValid()) {
242 if (m_options
.m_use_type_display_name
)
243 type_name
= m_valobj
->GetDisplayTypeName();
245 type_name
= m_valobj
->GetQualifiedTypeName();
247 // only show an invalid type name if the user explicitly triggered
249 if (m_options
.m_show_types
)
250 type_name
= ConstString("<invalid type>");
256 std::string
type_name_str(type_name
.GetCString());
257 if (m_options
.m_hide_pointer_value
) {
258 for (auto iter
= type_name_str
.find(" *"); iter
!= std::string::npos
;
259 iter
= type_name_str
.find(" *")) {
260 type_name_str
.erase(iter
, 2);
263 typeName
.Printf("%s", type_name_str
.c_str());
267 StreamString varName
;
269 if (m_options
.m_flat_output
) {
270 // If we are showing types, also qualify the C++ base classes
271 const bool qualify_cxx_base_classes
= show_type
;
272 if (!m_options
.m_hide_name
) {
273 m_valobj
->GetExpressionPath(varName
, qualify_cxx_base_classes
);
275 } else if (!m_options
.m_hide_name
) {
276 const char *name_cstr
= GetRootNameForDisplay("");
277 varName
.Printf("%s", name_cstr
);
280 bool decl_printed
= false;
281 if (!m_options
.m_decl_printing_helper
) {
282 // if the user didn't give us a custom helper, pick one based upon the
283 // language, either the one that this printer is bound to, or the preferred
284 // one for the ValueObject
285 lldb::LanguageType lang_type
=
286 (m_options
.m_varformat_language
== lldb::eLanguageTypeUnknown
)
287 ? m_valobj
->GetPreferredDisplayLanguage()
288 : m_options
.m_varformat_language
;
289 if (Language
*lang_plugin
= Language::FindPlugin(lang_type
)) {
290 m_options
.m_decl_printing_helper
= lang_plugin
->GetDeclPrintingHelper();
294 if (m_options
.m_decl_printing_helper
) {
295 ConstString
type_name_cstr(typeName
.GetString());
296 ConstString
var_name_cstr(varName
.GetString());
298 StreamString dest_stream
;
299 if (m_options
.m_decl_printing_helper(type_name_cstr
, var_name_cstr
,
300 m_options
, dest_stream
)) {
302 m_stream
->PutCString(dest_stream
.GetString());
306 // if the helper failed, or there is none, do a default thing
308 if (!typeName
.Empty())
309 m_stream
->Printf("(%s) ", typeName
.GetData());
310 if (!varName
.Empty())
311 m_stream
->Printf("%s =", varName
.GetData());
312 else if (!m_options
.m_hide_name
)
313 m_stream
->Printf(" =");
317 bool ValueObjectPrinter::CheckScopeIfNeeded() {
318 if (m_options
.m_scope_already_checked
)
320 return m_valobj
->IsInScope();
323 TypeSummaryImpl
*ValueObjectPrinter::GetSummaryFormatter(bool null_if_omitted
) {
324 if (!m_summary_formatter
.second
) {
325 TypeSummaryImpl
*entry
= m_options
.m_summary_sp
326 ? m_options
.m_summary_sp
.get()
327 : m_valobj
->GetSummaryFormat().get();
329 if (m_options
.m_omit_summary_depth
> 0)
331 m_summary_formatter
.first
= entry
;
332 m_summary_formatter
.second
= true;
334 if (m_options
.m_omit_summary_depth
> 0 && null_if_omitted
)
336 return m_summary_formatter
.first
;
339 static bool IsPointerValue(const CompilerType
&type
) {
340 Flags
type_flags(type
.GetTypeInfo());
341 if (type_flags
.AnySet(eTypeInstanceIsPointer
| eTypeIsPointer
))
342 return type_flags
.AllClear(eTypeIsBuiltIn
);
346 void ValueObjectPrinter::GetValueSummaryError(std::string
&value
,
347 std::string
&summary
,
348 std::string
&error
) {
349 lldb::Format format
= m_options
.m_format
;
350 // if I am printing synthetized elements, apply the format to those elements
352 if (m_options
.m_pointer_as_array
)
353 m_valobj
->GetValueAsCString(lldb::eFormatDefault
, value
);
354 else if (format
!= eFormatDefault
&& format
!= m_valobj
->GetFormat())
355 m_valobj
->GetValueAsCString(format
, value
);
357 const char *val_cstr
= m_valobj
->GetValueAsCString();
359 value
.assign(val_cstr
);
361 const char *err_cstr
= m_valobj
->GetError().AsCString();
363 error
.assign(err_cstr
);
365 if (ShouldPrintValueObject()) {
367 summary
.assign("nil");
368 else if (IsUninitialized())
369 summary
.assign("<uninitialized>");
370 else if (m_options
.m_omit_summary_depth
== 0) {
371 TypeSummaryImpl
*entry
= GetSummaryFormatter();
373 m_valobj
->GetSummaryAsCString(entry
, summary
,
374 m_options
.m_varformat_language
);
376 const char *sum_cstr
=
377 m_valobj
->GetSummaryAsCString(m_options
.m_varformat_language
);
379 summary
.assign(sum_cstr
);
385 bool ValueObjectPrinter::PrintValueAndSummaryIfNeeded(bool &value_printed
,
386 bool &summary_printed
) {
387 bool error_printed
= false;
388 if (ShouldPrintValueObject()) {
389 if (!CheckScopeIfNeeded())
390 m_error
.assign("out of scope");
391 if (m_error
.empty()) {
392 GetValueSummaryError(m_value
, m_summary
, m_error
);
394 if (m_error
.size()) {
395 // we need to support scenarios in which it is actually fine for a value
396 // to have no type but - on the other hand - if we get an error *AND*
397 // have no type, we try to get out gracefully, since most often that
398 // combination means "could not resolve a type" and the default failure
399 // mode is quite ugly
400 if (!m_compiler_type
.IsValid()) {
401 m_stream
->Printf(" <could not resolve type>");
405 error_printed
= true;
406 m_stream
->Printf(" <%s>\n", m_error
.c_str());
408 // Make sure we have a value and make sure the summary didn't specify
409 // that the value should not be printed - and do not print the value if
410 // this thing is nil (but show the value if the user passes a format
412 TypeSummaryImpl
*entry
= GetSummaryFormatter();
413 if (!IsNil() && !IsUninitialized() && !m_value
.empty() &&
415 (entry
->DoesPrintValue(m_valobj
) ||
416 m_options
.m_format
!= eFormatDefault
) ||
417 m_summary
.empty()) &&
418 !m_options
.m_hide_value
) {
419 if (m_options
.m_hide_pointer_value
&&
420 IsPointerValue(m_valobj
->GetCompilerType())) {
422 m_stream
->Printf(" %s", m_value
.c_str());
423 value_printed
= true;
427 if (m_summary
.size()) {
428 m_stream
->Printf(" %s", m_summary
.c_str());
429 summary_printed
= true;
433 return !error_printed
;
436 bool ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed
,
437 bool summary_printed
) {
438 if (ShouldPrintValueObject()) {
439 // let's avoid the overly verbose no description error for a nil thing
440 if (m_options
.m_use_objc
&& !IsNil() && !IsUninitialized() &&
441 (!m_options
.m_pointer_as_array
)) {
442 if (!m_options
.m_hide_value
|| !m_options
.m_hide_name
)
443 m_stream
->Printf(" ");
444 const char *object_desc
= nullptr;
445 if (value_printed
|| summary_printed
)
446 object_desc
= m_valobj
->GetObjectDescription();
448 object_desc
= GetDescriptionForDisplay();
449 if (object_desc
&& *object_desc
) {
450 // If the description already ends with a \n don't add another one.
451 size_t object_end
= strlen(object_desc
) - 1;
452 if (object_desc
[object_end
] == '\n')
453 m_stream
->Printf("%s", object_desc
);
455 m_stream
->Printf("%s\n", object_desc
);
457 } else if (!value_printed
&& !summary_printed
)
466 bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
477 bool ValueObjectPrinter::ShouldPrintChildren(
478 bool is_failed_description
,
479 DumpValueObjectOptions::PointerDepth
&curr_ptr_depth
) {
480 const bool is_ref
= IsRef();
481 const bool is_ptr
= IsPtr();
482 const bool is_uninit
= IsUninitialized();
487 // if the user has specified an element count, always print children as it is
488 // explicit user demand being honored
489 if (m_options
.m_pointer_as_array
)
492 TypeSummaryImpl
*entry
= GetSummaryFormatter();
494 if (m_options
.m_use_objc
)
497 if (is_failed_description
|| m_curr_depth
< m_options
.m_max_depth
) {
498 // We will show children for all concrete types. We won't show pointer
499 // contents unless a pointer depth has been specified. We won't reference
500 // contents unless the reference is the root object (depth of zero).
502 // Use a new temporary pointer depth in case we override the current
503 // pointer depth below...
505 if (is_ptr
|| is_ref
) {
506 // We have a pointer or reference whose value is an address. Make sure
507 // that address is not NULL
508 AddressType ptr_address_type
;
509 if (m_valobj
->GetPointerValue(&ptr_address_type
) == 0)
512 const bool is_root_level
= m_curr_depth
== 0;
514 if (is_ref
&& is_root_level
) {
515 // If this is the root object (depth is zero) that we are showing and
516 // it is a reference, and no pointer depth has been supplied print out
517 // what it references. Don't do this at deeper depths otherwise we can
518 // end up with infinite recursion...
522 return curr_ptr_depth
.CanAllowExpansion();
525 return (!entry
|| entry
->DoesPrintChildren(m_valobj
) || m_summary
.empty());
530 bool ValueObjectPrinter::ShouldExpandEmptyAggregates() {
531 TypeSummaryImpl
*entry
= GetSummaryFormatter();
536 return entry
->DoesPrintEmptyAggregates();
539 ValueObject
*ValueObjectPrinter::GetValueObjectForChildrenGeneration() {
543 void ValueObjectPrinter::PrintChildrenPreamble() {
544 if (m_options
.m_flat_output
) {
545 if (ShouldPrintValueObject())
548 if (ShouldPrintValueObject())
549 m_stream
->PutCString(IsRef() ? ": {\n" : " {\n");
550 m_stream
->IndentMore();
554 void ValueObjectPrinter::PrintChild(
555 ValueObjectSP child_sp
,
556 const DumpValueObjectOptions::PointerDepth
&curr_ptr_depth
) {
557 const uint32_t consumed_depth
= (!m_options
.m_pointer_as_array
) ? 1 : 0;
558 const bool does_consume_ptr_depth
=
559 ((IsPtr() && !m_options
.m_pointer_as_array
) || IsRef());
561 DumpValueObjectOptions
child_options(m_options
);
562 child_options
.SetFormat(m_options
.m_format
)
564 .SetRootValueObjectName();
565 child_options
.SetScopeChecked(true)
566 .SetHideName(m_options
.m_hide_name
)
567 .SetHideValue(m_options
.m_hide_value
)
568 .SetOmitSummaryDepth(child_options
.m_omit_summary_depth
> 1
569 ? child_options
.m_omit_summary_depth
-
574 if (child_sp
.get()) {
575 ValueObjectPrinter
child_printer(
576 child_sp
.get(), m_stream
, child_options
,
577 does_consume_ptr_depth
? --curr_ptr_depth
: curr_ptr_depth
,
578 m_curr_depth
+ consumed_depth
, m_printed_instance_pointers
);
579 child_printer
.PrintValueObject();
583 uint32_t ValueObjectPrinter::GetMaxNumChildrenToPrint(bool &print_dotdotdot
) {
584 ValueObject
*synth_m_valobj
= GetValueObjectForChildrenGeneration();
586 if (m_options
.m_pointer_as_array
)
587 return m_options
.m_pointer_as_array
.m_element_count
;
589 size_t num_children
= synth_m_valobj
->GetNumChildren();
590 print_dotdotdot
= false;
592 const size_t max_num_children
=
593 m_valobj
->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
595 if (num_children
> max_num_children
&& !m_options
.m_ignore_cap
) {
596 print_dotdotdot
= true;
597 return max_num_children
;
603 void ValueObjectPrinter::PrintChildrenPostamble(bool print_dotdotdot
) {
604 if (!m_options
.m_flat_output
) {
605 if (print_dotdotdot
) {
606 m_valobj
->GetTargetSP()
608 .GetCommandInterpreter()
609 .ChildrenTruncated();
610 m_stream
->Indent("...\n");
612 m_stream
->IndentLess();
613 m_stream
->Indent("}\n");
617 bool ValueObjectPrinter::ShouldPrintEmptyBrackets(bool value_printed
,
618 bool summary_printed
) {
619 ValueObject
*synth_m_valobj
= GetValueObjectForChildrenGeneration();
624 if (!m_options
.m_reveal_empty_aggregates
) {
625 if (value_printed
|| summary_printed
)
629 if (synth_m_valobj
->MightHaveChildren())
632 if (m_val_summary_ok
)
638 static constexpr size_t PhysicalIndexForLogicalIndex(size_t base
, size_t stride
,
640 return base
+ logical
* stride
;
643 ValueObjectSP
ValueObjectPrinter::GenerateChild(ValueObject
*synth_valobj
,
645 if (m_options
.m_pointer_as_array
) {
646 // if generating pointer-as-array children, use GetSyntheticArrayMember
647 return synth_valobj
->GetSyntheticArrayMember(
648 PhysicalIndexForLogicalIndex(
649 m_options
.m_pointer_as_array
.m_base_element
,
650 m_options
.m_pointer_as_array
.m_stride
, idx
),
653 // otherwise, do the usual thing
654 return synth_valobj
->GetChildAtIndex(idx
, true);
658 void ValueObjectPrinter::PrintChildren(
659 bool value_printed
, bool summary_printed
,
660 const DumpValueObjectOptions::PointerDepth
&curr_ptr_depth
) {
661 ValueObject
*synth_m_valobj
= GetValueObjectForChildrenGeneration();
663 bool print_dotdotdot
= false;
664 size_t num_children
= GetMaxNumChildrenToPrint(print_dotdotdot
);
666 bool any_children_printed
= false;
668 for (size_t idx
= 0; idx
< num_children
; ++idx
) {
669 if (ValueObjectSP child_sp
= GenerateChild(synth_m_valobj
, idx
)) {
670 if (!any_children_printed
) {
671 PrintChildrenPreamble();
672 any_children_printed
= true;
674 PrintChild(child_sp
, curr_ptr_depth
);
678 if (any_children_printed
)
679 PrintChildrenPostamble(print_dotdotdot
);
681 if (ShouldPrintEmptyBrackets(value_printed
, summary_printed
)) {
682 if (ShouldPrintValueObject())
683 m_stream
->PutCString(" {}\n");
689 } else if (ShouldPrintEmptyBrackets(value_printed
, summary_printed
)) {
690 // Aggregate, no children...
691 if (ShouldPrintValueObject()) {
692 // if it has a synthetic value, then don't print {}, the synthetic
693 // children are probably only being used to vend a value
694 if (m_valobj
->DoesProvideSyntheticValue() ||
695 !ShouldExpandEmptyAggregates())
696 m_stream
->PutCString("\n");
698 m_stream
->PutCString(" {}\n");
701 if (ShouldPrintValueObject())
706 bool ValueObjectPrinter::PrintChildrenOneLiner(bool hide_names
) {
707 if (!GetMostSpecializedValue() || m_valobj
== nullptr)
710 ValueObject
*synth_m_valobj
= GetValueObjectForChildrenGeneration();
712 bool print_dotdotdot
= false;
713 size_t num_children
= GetMaxNumChildrenToPrint(print_dotdotdot
);
716 m_stream
->PutChar('(');
718 for (uint32_t idx
= 0; idx
< num_children
; ++idx
) {
719 lldb::ValueObjectSP
child_sp(synth_m_valobj
->GetChildAtIndex(idx
, true));
721 child_sp
= child_sp
->GetQualifiedRepresentationIfAvailable(
722 m_options
.m_use_dynamic
, m_options
.m_use_synthetic
);
725 m_stream
->PutCString(", ");
727 const char *name
= child_sp
.get()->GetName().AsCString();
729 m_stream
->PutCString(name
);
730 m_stream
->PutCString(" = ");
733 child_sp
->DumpPrintableRepresentation(
734 *m_stream
, ValueObject::eValueObjectRepresentationStyleSummary
,
736 ValueObject::PrintableRepresentationSpecialCases::eDisable
);
741 m_stream
->PutCString(", ...)");
743 m_stream
->PutChar(')');
748 void ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed
,
749 bool summary_printed
) {
750 // This flag controls whether we tried to display a description for this
751 // object and failed if that happens, we want to display the children if any.
752 bool is_failed_description
=
753 !PrintObjectDescriptionIfNeeded(value_printed
, summary_printed
);
755 DumpValueObjectOptions::PointerDepth curr_ptr_depth
= m_ptr_depth
;
756 const bool print_children
=
757 ShouldPrintChildren(is_failed_description
, curr_ptr_depth
);
758 const bool print_oneline
=
759 (curr_ptr_depth
.CanAllowExpansion() || m_options
.m_show_types
||
760 !m_options
.m_allow_oneliner_mode
|| m_options
.m_flat_output
||
761 (m_options
.m_pointer_as_array
) || m_options
.m_show_location
)
763 : DataVisualization::ShouldPrintAsOneLiner(*m_valobj
);
764 if (print_children
&& IsInstancePointer()) {
765 uint64_t instance_ptr_value
= m_valobj
->GetValueAsUnsigned(0);
766 if (m_printed_instance_pointers
->count(instance_ptr_value
)) {
767 // We already printed this instance-is-pointer thing, so don't expand it.
768 m_stream
->PutCString(" {...}\n");
771 // Remember this guy for future reference.
772 m_printed_instance_pointers
->emplace(instance_ptr_value
);
776 if (print_children
) {
778 m_stream
->PutChar(' ');
779 PrintChildrenOneLiner(false);
782 PrintChildren(value_printed
, summary_printed
, curr_ptr_depth
);
783 } else if (m_curr_depth
>= m_options
.m_max_depth
&& IsAggregate() &&
784 ShouldPrintValueObject()) {
785 m_stream
->PutCString("{...}\n");