Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/include/lldb/Target/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class TargetProperties : public Properties {

uint32_t GetMaxZeroPaddingInFloatFormat() const;

uint32_t GetMaximumNumberOfChildrenToDisplay() const;
std::pair<uint32_t, bool> GetMaximumNumberOfChildrenToDisplay() const;

/// Get the max depth value, augmented with a bool to indicate whether the
/// depth is the default.
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/API/SBTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/FormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/DataFormatters/FormatManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 23 additions & 4 deletions lldb/source/DataFormatters/ValueObjectPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>
ValueObjectPrinter::GetMaxNumChildrenToPrint(bool &print_dotdotdot) {
ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
Expand All @@ -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)));
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 6 additions & 3 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4814,10 +4814,13 @@ uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const {
idx, g_target_properties[idx].default_uint_value);
}

uint32_t TargetProperties::GetMaximumNumberOfChildrenToDisplay() const {
std::pair<uint32_t, bool>
TargetProperties::GetMaximumNumberOfChildrenToDisplay() const {
const uint32_t idx = ePropertyMaxChildrenCount;
return GetPropertyAtIndexAs<uint64_t>(
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<uint32_t, bool>
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Target/TargetProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -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.">;
Expand Down
Loading