@@ -523,7 +523,6 @@ bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
523
523
}
524
524
525
525
bool ValueObjectPrinter::ShouldPrintChildren (
526
- bool is_failed_description,
527
526
DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
528
527
const bool is_ref = IsRef ();
529
528
const bool is_ptr = IsPtr ();
@@ -532,6 +531,10 @@ bool ValueObjectPrinter::ShouldPrintChildren(
532
531
if (is_uninit)
533
532
return false ;
534
533
534
+ // If we have reached the maximum depth we shouldn't print any more children.
535
+ if (HasReachedMaximumDepth ())
536
+ return false ;
537
+
535
538
// if the user has specified an element count, always print children as it is
536
539
// explicit user demand being honored
537
540
if (m_options.m_pointer_as_array )
@@ -542,38 +545,37 @@ bool ValueObjectPrinter::ShouldPrintChildren(
542
545
if (m_options.m_use_objc )
543
546
return false ;
544
547
545
- if (is_failed_description || !HasReachedMaximumDepth ()) {
546
- // We will show children for all concrete types. We won't show pointer
547
- // contents unless a pointer depth has been specified. We won't reference
548
- // contents unless the reference is the root object (depth of zero).
548
+ bool print_children = true ;
549
+ if (TypeSummaryImpl *type_summary = GetSummaryFormatter ())
550
+ print_children = type_summary->DoesPrintChildren (m_valobj);
549
551
550
- // Use a new temporary pointer depth in case we override the current
551
- // pointer depth below...
552
+ // We will show children for all concrete types. We won't show pointer
553
+ // contents unless a pointer depth has been specified. We won't reference
554
+ // contents unless the reference is the root object (depth of zero).
552
555
553
- if (is_ptr || is_ref) {
554
- // We have a pointer or reference whose value is an address. Make sure
555
- // that address is not NULL
556
- AddressType ptr_address_type;
557
- if (m_valobj->GetPointerValue (&ptr_address_type) == 0 )
558
- return false ;
556
+ // Use a new temporary pointer depth in case we override the current
557
+ // pointer depth below...
559
558
560
- const bool is_root_level = m_curr_depth == 0 ;
559
+ if (is_ptr || is_ref) {
560
+ // We have a pointer or reference whose value is an address. Make sure
561
+ // that address is not NULL
562
+ AddressType ptr_address_type;
563
+ if (m_valobj->GetPointerValue (&ptr_address_type) == 0 )
564
+ return false ;
561
565
562
- if (is_ref && is_root_level) {
563
- // If this is the root object (depth is zero) that we are showing and
564
- // it is a reference, and no pointer depth has been supplied print out
565
- // what it references. Don't do this at deeper depths otherwise we can
566
- // end up with infinite recursion...
567
- return true ;
568
- }
566
+ const bool is_root_level = m_curr_depth == 0 ;
569
567
570
- return curr_ptr_depth.CanAllowExpansion (false , entry, m_valobj,
571
- m_summary);
568
+ if (is_ref && is_root_level && print_children) {
569
+ // If this is the root object (depth is zero) that we are showing and
570
+ // it is a reference, and no pointer depth has been supplied print out
571
+ // what it references. Don't do this at deeper depths otherwise we can
572
+ // end up with infinite recursion...
573
+ return true ;
572
574
}
573
-
574
- return (!entry || entry->DoesPrintChildren (m_valobj) || m_summary.empty ());
575
+ return curr_ptr_depth.CanAllowExpansion (false , entry, m_valobj, m_summary);
575
576
}
576
- return false ;
577
+
578
+ return print_children || m_summary.empty ();
577
579
}
578
580
579
581
bool ValueObjectPrinter::ShouldExpandEmptyAggregates () {
@@ -610,7 +612,7 @@ void ValueObjectPrinter::PrintChildrenPreamble(bool value_printed,
610
612
void ValueObjectPrinter::PrintChild (
611
613
ValueObjectSP child_sp,
612
614
const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
613
- const uint32_t consumed_depth = (! m_options.m_pointer_as_array ) ? 1 : 0 ;
615
+ const uint32_t consumed_summary_depth = m_options.m_pointer_as_array ? 0 : 1 ;
614
616
const bool does_consume_ptr_depth =
615
617
((IsPtr () && !m_options.m_pointer_as_array ) || IsRef ());
616
618
@@ -623,15 +625,18 @@ void ValueObjectPrinter::PrintChild(
623
625
.SetHideValue (m_options.m_hide_value )
624
626
.SetOmitSummaryDepth (child_options.m_omit_summary_depth > 1
625
627
? child_options.m_omit_summary_depth -
626
- consumed_depth
628
+ consumed_summary_depth
627
629
: 0 )
628
630
.SetElementCount (0 );
629
631
630
632
if (child_sp.get ()) {
631
- ValueObjectPrinter child_printer (
632
- child_sp.get (), m_stream, child_options,
633
- does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
634
- m_curr_depth + consumed_depth, m_printed_instance_pointers);
633
+ auto ptr_depth = curr_ptr_depth;
634
+ if (does_consume_ptr_depth)
635
+ ptr_depth = curr_ptr_depth.Decremented ();
636
+
637
+ ValueObjectPrinter child_printer (child_sp.get (), m_stream, child_options,
638
+ ptr_depth, m_curr_depth + 1 ,
639
+ m_printed_instance_pointers);
635
640
child_printer.PrintValueObject ();
636
641
}
637
642
}
@@ -803,14 +808,10 @@ bool ValueObjectPrinter::PrintChildrenOneLiner(bool hide_names) {
803
808
804
809
void ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed,
805
810
bool summary_printed) {
806
- // This flag controls whether we tried to display a description for this
807
- // object and failed if that happens, we want to display the children if any.
808
- bool is_failed_description =
809
- !PrintObjectDescriptionIfNeeded (value_printed, summary_printed);
811
+ PrintObjectDescriptionIfNeeded (value_printed, summary_printed);
810
812
811
813
DumpValueObjectOptions::PointerDepth curr_ptr_depth = m_ptr_depth;
812
- const bool print_children =
813
- ShouldPrintChildren (is_failed_description, curr_ptr_depth);
814
+ const bool print_children = ShouldPrintChildren (curr_ptr_depth);
814
815
const bool print_oneline =
815
816
(curr_ptr_depth.CanAllowExpansion () || m_options.m_show_types ||
816
817
!m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
0 commit comments