diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -936,7 +936,7 @@ cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), SyntheticChildrenSP(new ScriptedSyntheticChildren( - stl_synth_flags, + stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"))); cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"), diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py @@ -84,10 +84,100 @@ '...' ]) + def do_test_ptr_and_ref(self, stdlib_type): + """Test that ref and ptr to std::forward_list is displayed correctly""" + self.build(dictionary={stdlib_type: "1"}) + + (_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, + 'Check ref and ptr', + lldb.SBFileSpec("main.cpp", False)) + + self.expect("frame variable ref", + substrs=[ + 'size=0', + '{}']) + + self.expect("frame variable *ptr", + substrs=[ + 'size=0', + '{}']) + + lldbutil.continue_to_breakpoint(process, bkpt) + + self.expect("frame variable ref", + substrs=[ + '{', + '[0] = 47', + '}']) + + self.expect("frame variable *ptr", + substrs=[ + '{', + '[0] = 47', + '}']) + + lldbutil.continue_to_breakpoint(process, bkpt) + + self.expect("frame variable ref", + substrs=[ + 'size=5', + '{', + '[0] = 1', + '[1] = 22', + '[2] = 333', + '[3] = 4444', + '[4] = 55555', + '}']) + + self.expect("frame variable *ptr", + substrs=[ + 'size=5', + '{', + '[0] = 1', + '[1] = 22', + '[2] = 333', + '[3] = 4444', + '[4] = 55555', + '}']) + + lldbutil.continue_to_breakpoint(process, bkpt) + + self.runCmd( + "settings set target.max-children-count 256", + check=False) + + self.expect("settings show target.max-children-count", matching=True, + substrs=['target.max-children-count (int) = 256']) + + + self.expect("frame variable ref",matching=True, + substrs=[ + 'size=256', + '[0] = 999', + '[1] = 998', + '[2] = 997', + ]) + + self.expect("frame variable *ptr",matching=True, + substrs=[ + 'size=256', + '[0] = 999', + '[1] = 998', + '[2] = 997', + ]) + @add_test_categories(["libstdcxx"]) def test_libstdcpp(self): self.do_test(USE_LIBSTDCPP) + @add_test_categories(["libstdcxx"]) + def test_ptr_and_ref_libstdcpp(self): + self.do_test_ptr_and_ref(USE_LIBSTDCPP) + @add_test_categories(["libc++"]) def test_libcpp(self): self.do_test(USE_LIBCPP) + + @add_test_categories(["libc++"]) + def test_ptr_and_ref_libcpp(self): + self.do_test_ptr_and_ref(USE_LIBCPP) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp @@ -1,10 +1,21 @@ #include + +void by_ref_and_ptr(std::forward_list &ref, std::forward_list *ptr) { + // Check ref and ptr + return; +} + int main() { std::forward_list empty{}, one_elt{47}, five_elts{1, 22, 333, 4444, 55555}, thousand_elts{}; for(int i = 0; i<1000;i++){ thousand_elts.push_front(i); } - return 0; // break here + + by_ref_and_ptr(empty, &empty); // break here + by_ref_and_ptr(one_elt, &one_elt); + by_ref_and_ptr(five_elts, &five_elts); + by_ref_and_ptr(thousand_elts, &thousand_elts); + return 0; } diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py @@ -205,11 +205,58 @@ self.assertTrue( self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!") + + def do_test_ptr_and_ref(self, stdlib_type): + """Test that ref and ptr to std::list is displayed correctly""" + self.build(dictionary={stdlib_type: "1"}) + + (_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, + 'Check ref and ptr', + lldb.SBFileSpec("main.cpp", False)) + + self.expect("frame variable ref", + substrs=['size=4', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) + + + self.expect("frame variable *ptr", + substrs=['size=4', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) + + lldbutil.continue_to_breakpoint(process, bkpt) + + self.expect("frame variable ref", + substrs=['size=4', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart', + '[3]', '!!!']) + + self.expect("frame variable *ptr", + substrs=['size=4', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart', + '[3]', '!!!']) @add_test_categories(["libstdcxx"]) def test_with_run_command_libstdcpp(self): self.do_test_with_run_command(USE_LIBSTDCPP) + @add_test_categories(["libstdcxx"]) + def test_ptr_and_ref_libstdcpp(self): + self.do_test_ptr_and_ref(USE_LIBSTDCPP) + @add_test_categories(["libc++"]) def test_with_run_command_libcpp(self): - self.do_test_with_run_command(USE_LIBCPP) \ No newline at end of file + self.do_test_with_run_command(USE_LIBCPP) + + @add_test_categories(["libc++"]) + def test_ptr_and_ref_libcpp(self): + self.do_test_ptr_and_ref(USE_LIBCPP) \ No newline at end of file diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp @@ -4,6 +4,12 @@ typedef std::list int_list; typedef std::list string_list; + +template void by_ref_and_ptr(T &ref, T *ptr) { + // Check ref and ptr + return; +} + int main() { int_list numbers_list; @@ -21,13 +27,16 @@ numbers_list.push_back(2); numbers_list.push_back(3); numbers_list.push_back(4); + + by_ref_and_ptr(numbers_list, &numbers_list); string_list text_list; text_list.push_back(std::string("goofy")); // Optional break point at this line. text_list.push_back(std::string("is")); text_list.push_back(std::string("smart")); - text_list.push_back(std::string("!!!")); + + by_ref_and_ptr(text_list, &text_list); return 0; // Set final break point at this line. }