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 @@ -905,6 +905,8 @@ SyntheticChildren::Flags stl_synth_flags; stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences( false); + SyntheticChildren::Flags stl_deref_flags = stl_synth_flags; + stl_deref_flags.SetFrontEndWantsDereference(); cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( RegularExpression("^std::vector<.+>(( )?&)?$"), @@ -916,6 +918,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::set<.+> >(( )?&)?$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_deref_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider"))); cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), SyntheticChildrenSP(new ScriptedSyntheticChildren( @@ -931,6 +938,12 @@ RegularExpression("^std::map<.+> >(( )?&)?$"), TypeSummaryImplSP( new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); + TypeSummaryImpl::Flags stl_set_summary_flags = stl_summary_flags; + stl_set_summary_flags.SetSkipPointers(false).SetDontShowValue(false); + cpp_category_sp->GetRegexTypeSummariesContainer()->Add( + RegularExpression("^std::set<.+> >(( )?&)?$"), + TypeSummaryImplSP( + new StringSummaryFormat(stl_set_summary_flags, "size=${svar%#}"))); cpp_category_sp->GetRegexTypeSummariesContainer()->Add( RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), TypeSummaryImplSP( diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile @@ -1,6 +1,5 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 -CXXFLAGS_EXTRAS := -O0 + include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -9,6 +9,8 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" class LibcxxSetDataFormatterTestCase(TestBase): @@ -42,10 +44,10 @@ "[3] = 3", "[6] = 6"]) - @add_test_categories(["libc++"]) - def test_with_run_command(self): + + def do_test_with_run_command(self,stdlib_type): """Test that that file and class static variables display correctly.""" - self.build() + self.build(dictionary={stdlib_type: "1"}) (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False)) @@ -121,8 +123,16 @@ '[1] = "a very long string is right here"', '[2] = "c"']) + @add_test_categories(["libstdcxx"]) + def test_with_run_command_libstdcpp(self): + self.do_test_with_run_command(USE_LIBSTDCPP) + @add_test_categories(["libc++"]) - def test_ref_and_ptr(self): + def test_with_run_command_libcpp(self): + self.do_test_with_run_command(USE_LIBCPP) + + + def do_test_ref_and_ptr(self,stdlib_type): """Test that the data formatters work on ref and ptr.""" self.build() (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( @@ -136,3 +146,12 @@ self.expect("expr ptr", substrs=["size=7"]) + @add_test_categories(["libstdcxx"]) + def test_ref_and_ptr_libstdcpp(self): + self.do_test_ref_and_ptr(USE_LIBSTDCPP) + + @add_test_categories(["libc++"]) + def test_ref_and_ptr_libcpp(self): + self.do_test_ref_and_ptr(USE_LIBCPP) + + diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp new file mode 100644 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) + arg = 0; + if (!arg) + arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::set &ref, std::set *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::set ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::set ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp deleted file mode 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -void by_ref_and_ptr(std::set &ref, std::set *ptr) -{ - // Stop here to check by ref and ptr - return; -} - -int main() -{ - std::set ii; - thefoo_rw(1); // Set break point at this line. - - ii.insert(0); - ii.insert(1); - ii.insert(2); - ii.insert(3); - ii.insert(4); - ii.insert(5); - thefoo_rw(1); // Set break point at this line. - - ii.insert(6); - thefoo_rw(1); // Set break point at this line. - - by_ref_and_ptr(ii, &ii); - - ii.clear(); - thefoo_rw(1); // Set break point at this line. - - std::set ss; - thefoo_rw(1); // Set break point at this line. - - ss.insert("a"); - ss.insert("a very long string is right here"); - thefoo_rw(1); // Set break point at this line. - - ss.insert("b"); - ss.insert("c"); - thefoo_rw(1); // Set break point at this line. - - ss.erase("b"); - thefoo_rw(1); // Set break point at this line. - - return 0; -}