diff --git a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h --- a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h +++ b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -91,8 +91,7 @@ bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed); bool - ShouldPrintChildren(bool is_failed_description, - DumpValueObjectOptions::PointerDepth &curr_ptr_depth); + ShouldPrintChildren(DumpValueObjectOptions::PointerDepth &curr_ptr_depth); bool ShouldExpandEmptyAggregates(); diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp --- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp +++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp @@ -502,7 +502,6 @@ } bool ValueObjectPrinter::ShouldPrintChildren( - bool is_failed_description, DumpValueObjectOptions::PointerDepth &curr_ptr_depth) { const bool is_ref = IsRef(); const bool is_ptr = IsPtr(); @@ -511,6 +510,10 @@ if (is_uninit) return false; + // If we have reached the maximum depth we shouldn't print any more children. + if (HasReachedMaximumDepth()) + return false; + // if the user has specified an element count, always print children as it is // explicit user demand being honored if (m_options.m_pointer_as_array) @@ -523,37 +526,34 @@ if (TypeSummaryImpl *type_summary = GetSummaryFormatter()) print_children = type_summary->DoesPrintChildren(m_valobj); - if (is_failed_description || !HasReachedMaximumDepth()) { - // We will show children for all concrete types. We won't show pointer - // contents unless a pointer depth has been specified. We won't reference - // contents unless the reference is the root object (depth of zero). + // We will show children for all concrete types. We won't show pointer + // contents unless a pointer depth has been specified. We won't reference + // contents unless the reference is the root object (depth of zero). - // Use a new temporary pointer depth in case we override the current - // pointer depth below... + // Use a new temporary pointer depth in case we override the current + // pointer depth below... - if (is_ptr || is_ref) { - // We have a pointer or reference whose value is an address. Make sure - // that address is not NULL - AddressType ptr_address_type; - if (m_valobj->GetPointerValue(&ptr_address_type) == 0) - return false; + if (is_ptr || is_ref) { + // We have a pointer or reference whose value is an address. Make sure + // that address is not NULL + AddressType ptr_address_type; + if (m_valobj->GetPointerValue(&ptr_address_type) == 0) + return false; - const bool is_root_level = m_curr_depth == 0; + const bool is_root_level = m_curr_depth == 0; - if (is_ref && is_root_level && print_children) { - // If this is the root object (depth is zero) that we are showing and - // it is a reference, and no pointer depth has been supplied print out - // what it references. Don't do this at deeper depths otherwise we can - // end up with infinite recursion... - return true; - } - - return curr_ptr_depth.CanAllowExpansion(); + if (is_ref && is_root_level && print_children) { + // If this is the root object (depth is zero) that we are showing and + // it is a reference, and no pointer depth has been supplied print out + // what it references. Don't do this at deeper depths otherwise we can + // end up with infinite recursion... + return true; } - return print_children || m_summary.empty(); + return curr_ptr_depth.CanAllowExpansion(); } - return false; + + return print_children || m_summary.empty(); } bool ValueObjectPrinter::ShouldExpandEmptyAggregates() { @@ -794,14 +794,10 @@ void ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed, bool summary_printed) { - // This flag controls whether we tried to display a description for this - // object and failed if that happens, we want to display the children if any. - bool is_failed_description = - !PrintObjectDescriptionIfNeeded(value_printed, summary_printed); + PrintObjectDescriptionIfNeeded(value_printed, summary_printed); DumpValueObjectOptions::PointerDepth curr_ptr_depth = m_ptr_depth; - const bool print_children = - ShouldPrintChildren(is_failed_description, curr_ptr_depth); + const bool print_children = ShouldPrintChildren(curr_ptr_depth); const bool print_oneline = (curr_ptr_depth.CanAllowExpansion() || m_options.m_show_types || !m_options.m_allow_oneliner_mode || m_options.m_flat_output || diff --git a/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py --- a/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py +++ b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py @@ -12,7 +12,7 @@ """Test that bool types work in the expression parser""" self.build() lldbutil.run_to_source_breakpoint( - self, "// break here", lldb.SBFileSpec("main.cpp") + self, "break here", lldb.SBFileSpec("main.cpp") ) # Check that we print 5 elements but only 2 levels deep. diff --git a/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp --- a/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp +++ b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp @@ -15,5 +15,5 @@ int main() { C *c = new C[5]; puts("break here"); - return 0; // break here + return 0; }