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 @@ -590,7 +590,7 @@ void ValueObjectPrinter::PrintChild( ValueObjectSP child_sp, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) { - const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0; + const uint32_t consumed_summary_depth = m_options.m_pointer_as_array ? 0 : 1; const bool does_consume_ptr_depth = ((IsPtr() && !m_options.m_pointer_as_array) || IsRef()); @@ -603,7 +603,7 @@ .SetHideValue(m_options.m_hide_value) .SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1 ? child_options.m_omit_summary_depth - - consumed_depth + consumed_summary_depth : 0) .SetElementCount(0); @@ -611,7 +611,7 @@ ValueObjectPrinter child_printer( child_sp.get(), m_stream, child_options, does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth, - m_curr_depth + consumed_depth, m_printed_instance_pointers); + m_curr_depth + 1, m_printed_instance_pointers); child_printer.PrintValueObject(); } } diff --git a/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile new file mode 100644 --- /dev/null +++ b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules 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 new file mode 100644 --- /dev/null +++ b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py @@ -0,0 +1,27 @@ +""" +Tests that frame variable --depth and --element-count options work correctly +together +""" +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + + +class TestFrameVarDepthAndElemCount(TestBase): + def test(self): + """Test that bool types work in the expression parser""" + self.build() + lldbutil.run_to_source_breakpoint( + self, "// break here", lldb.SBFileSpec("main.cpp") + ) + + # Check that we print 5 elements but only 2 levels deep. + self.expect('frame var --depth 2 --element-count 5 -- c', + substrs=[ + '[0] = {\n b ={...}\n }', + '[1] = {\n b ={...}\n }', + '[2] = {\n b ={...}\n }', + '[3] = {\n b ={...}\n }', + '[4] = {\n b ={...}\n }', + ]) + 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 new file mode 100644 --- /dev/null +++ b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp @@ -0,0 +1,16 @@ +struct A { + int i = 42; +}; + +struct B { + A a; +}; + +struct C { + B b; +}; + +int main() { + C *c = new C[5]; + return 0; // break here +}