diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 0d4e11b65339e..bcde310378acf 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -186,7 +186,7 @@ class TargetProperties : public Properties { uint32_t GetMaxZeroPaddingInFloatFormat() const; - uint32_t GetMaximumNumberOfChildrenToDisplay() const; + std::pair GetMaximumNumberOfChildrenToDisplay() const; /// Get the max depth value, augmented with a bool to indicate whether the /// depth is the default. diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 813e8f2c6ec00..9f1d7b5ad2065 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1648,7 +1648,7 @@ uint32_t SBTarget::GetMaximumNumberOfChildrenToDisplay() const { LLDB_INSTRUMENT_VA(this); if (TargetSP target_sp = GetSP()) - return target_sp->GetMaximumNumberOfChildrenToDisplay(); + return target_sp->GetMaximumNumberOfChildrenToDisplay().first; return 0; } diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 4dcfa43a7bb04..7eb7e8f162ee4 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -1027,7 +1027,7 @@ static bool DumpValue(Stream &s, const SymbolContext *sc, if (index_higher < 0) index_higher = valobj->GetNumChildrenIgnoringErrors() - 1; - uint32_t max_num_children = + auto [max_num_children, _] = target->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay(); bool success = true; diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 122f2304ead24..6820bad4efc48 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -466,7 +466,7 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) { if (valobj.GetSummaryFormat().get() != nullptr) return valobj.GetSummaryFormat()->IsOneLiner(); - const size_t max_num_children = + const auto [max_num_children, _] = (target_sp ? *target_sp : Target::GetGlobalProperties()) .GetMaximumNumberOfChildrenToDisplay(); auto num_children = valobj.GetNumChildren(max_num_children); diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp index 5e04a621bbda8..4890aa8f7ee66 100644 --- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp +++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp @@ -633,6 +633,27 @@ void ValueObjectPrinter::PrintChild( } } +static uint32_t determineMaxChildren(bool ignore_cap, uint32_t cur_depth, + TargetSP target_sp) { + if (ignore_cap) + return UINT32_MAX; + + const auto [max_num_children, max_is_default] = + target_sp->GetMaximumNumberOfChildrenToDisplay(); + + // Special handling for printing values at the top level (such as variables). + // The original default value for target.max-children-count was 256. The + // default has since been reduced, to avoid printing too much data. However, + // users will naturally have expectations that all children are shown for top + // level values. The following code keeps 256 as the max count for top level + // values (unless customized). + const uint32_t top_level_max_num_childen = 256; + if (cur_depth == 0 && max_is_default) + return top_level_max_num_childen; + + return max_num_children; +} + llvm::Expected ValueObjectPrinter::GetMaxNumChildrenToPrint(bool &print_dotdotdot) { ValueObject &synth_valobj = GetValueObjectForChildrenGeneration(); @@ -641,10 +662,8 @@ ValueObjectPrinter::GetMaxNumChildrenToPrint(bool &print_dotdotdot) { return m_options.m_pointer_as_array.m_element_count; const uint32_t max_num_children = - m_options.m_ignore_cap ? UINT32_MAX - : GetMostSpecializedValue() - .GetTargetSP() - ->GetMaximumNumberOfChildrenToDisplay(); + determineMaxChildren(m_options.m_ignore_cap, m_curr_depth, + GetMostSpecializedValue().GetTargetSP()); // Ask for one more child than the maximum to see if we should print "...". auto num_children_or_err = synth_valobj.GetNumChildren( llvm::SaturatingAdd(max_num_children, uint32_t(1))); diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp index 30db5f15c388f..87b66697feae9 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp @@ -176,7 +176,7 @@ lldb::ChildCacheState AbstractListFrontEnd::Update() { if (m_backend.GetTargetSP()) m_list_capping_size = - m_backend.GetTargetSP()->GetMaximumNumberOfChildrenToDisplay(); + m_backend.GetTargetSP()->GetMaximumNumberOfChildrenToDisplay().first; if (m_list_capping_size == 0) m_list_capping_size = 255; diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 9660fc97970b0..6e2ca57072fa4 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -4814,10 +4814,13 @@ uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const { idx, g_target_properties[idx].default_uint_value); } -uint32_t TargetProperties::GetMaximumNumberOfChildrenToDisplay() const { +std::pair +TargetProperties::GetMaximumNumberOfChildrenToDisplay() const { const uint32_t idx = ePropertyMaxChildrenCount; - return GetPropertyAtIndexAs( - idx, g_target_properties[idx].default_uint_value); + auto *option_value = + m_collection_sp->GetPropertyAtIndexAsOptionValueUInt64(idx); + bool is_default = !option_value->OptionWasSet(); + return {option_value->GetCurrentValue(), is_default}; } std::pair diff --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td index 4aa9e046d6077..3df28d2a283fa 100644 --- a/lldb/source/Target/TargetProperties.td +++ b/lldb/source/Target/TargetProperties.td @@ -97,7 +97,7 @@ let Definition = "target" in { Desc<"The maximum number of zeroes to insert when displaying a very small float before falling back to scientific notation.">; def MaxChildrenCount: Property<"max-children-count", "UInt64">, DefaultUnsignedValue<24>, - Desc<"Maximum number of children to expand in any level of depth.">; + Desc<"Maximum number of children to show. Note: The default behavior will show 256 children for top-level values, and 24 children for any nested value. A custom count applies to all values, at any nesting.">; def MaxChildrenDepth: Property<"max-children-depth", "UInt64">, DefaultUnsignedValue<0xFFFFFFFF>, Desc<"Maximum depth to expand children.">;