diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/Makefile similarity index 82% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/Makefile index b016f006747da..e78030cbf7528 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/Makefile @@ -1,5 +1,4 @@ CXX_SOURCES := main.cpp CXXFLAGS_EXTRAS := -std=c++11 -USE_LIBCPP := 1 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py similarity index 84% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py index c6592ede03147..92904e4b64526 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py @@ -9,18 +9,15 @@ from lldbsuite.test import lldbutil -class LibCxxAtomicTestCase(TestBase): +class StdAtomicTestCase(TestBase): def get_variable(self, name): var = self.frame().FindVariable(name) var.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) var.SetPreferSyntheticValue(True) return var - @skipIf(compiler=["gcc"]) - @add_test_categories(["libc++"]) - def test(self): - """Test that std::atomic as defined by libc++ is correctly printed by LLDB""" - self.build() + def do_test(self): + """Test that std::atomic is correctly printed by LLDB""" self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( @@ -66,3 +63,15 @@ def test(self): self.expect( "frame var p.child.parent", substrs=["p.child.parent = {\n Value = 0x"] ) + + @skipIf(compiler=["gcc"]) + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @skipIf(compiler=["gcc"]) + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/main.cpp similarity index 51% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/main.cpp index 760d2384a772b..ee77a880a0c5d 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/main.cpp @@ -6,28 +6,26 @@ struct Child { // This should point to the parent which in turn owns this // child instance. This cycle should not cause LLDB to infinite loop // during printing. - std::atomic parent{nullptr}; + std::atomic parent{nullptr}; }; struct Parent { Child child; }; struct S { - int x = 1; - int y = 2; + int x = 1; + int y = 2; }; -int main () -{ - std::atomic s; - s.store(S()); - std::atomic i; - i.store(5); +int main() { + std::atomic s; + s.store(S()); + std::atomic i; + i.store(5); - Parent p; - // Let the child node know what its parent is. - p.child.parent = &p; + Parent p; + // Let the child node know what its parent is. + p.child.parent = &p; - return 0; // Set break point at this line. + return 0; // Set break point at this line. } - diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/Makefile similarity index 82% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/Makefile index 57540fc1a2816..ac12cb120f853 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/Makefile @@ -1,6 +1,4 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 - CXXFLAGS_EXTRAS := -std=c++20 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/TestDataFormatterStdChrono.py similarity index 97% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/TestDataFormatterStdChrono.py index 0737a5bc7e6eb..eb5686a51023d 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/TestDataFormatterStdChrono.py @@ -2,20 +2,16 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxChronoDataFormatterTestCase(TestBase): - @add_test_categories(["libc++"]) - @skipIf(compiler="clang", compiler_version=["<", "17.0"]) - def test_with_run_command(self): +class StdChronoDataFormatterTestCase(TestBase): + def do_test(self): """Test that that file and class static variables display correctly.""" isNotWindowsHost = lldbplatformutil.getHostPlatform() != "windows" - self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "break here", lldb.SBFileSpec("main.cpp", False) ) @@ -433,3 +429,15 @@ def test_with_run_command(self): "ymwdl_2024_last_tuesday_january = year=2024 month=January weekday=Tuesday index=last" ], ) + + @skipIf(compiler="clang", compiler_version=["<", "17.0"]) + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @skipIf(compiler="clang", compiler_version=["<", "17.0"]) + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/Makefile similarity index 82% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/Makefile index b016f006747da..e78030cbf7528 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/Makefile @@ -1,5 +1,4 @@ CXX_SOURCES := main.cpp CXXFLAGS_EXTRAS := -std=c++11 -USE_LIBCPP := 1 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/TestDataFormatterStdFunction.py similarity index 87% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/TestDataFormatterStdFunction.py index 80461b996328f..cbcda40ddd1bd 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/TestDataFormatterStdFunction.py @@ -2,14 +2,13 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibCxxFunctionTestCase(TestBase): +class StdFunctionTestCase(TestBase): # Run frame var for a variable twice. Verify we do not hit the cache # the first time but do the second time. def run_frame_var_check_cache_use( @@ -34,10 +33,8 @@ def run_frame_var_check_cache_use( substrs=["lldb_private::CompileUnit::FindFunction"], ) - @add_test_categories(["libc++"]) - def test(self): - """Test that std::function as defined by libc++ is correctly printed by LLDB""" - self.build() + def do_test(self): + """Test that std::function is correctly printed by LLDB""" self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( @@ -82,3 +79,13 @@ def test(self): self.expect( "frame variable f5", substrs=["f5 = Function = Bar::add_num(int) const"] ) + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/main.cpp new file mode 100644 index 0000000000000..86ab18fd9cc43 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/main.cpp @@ -0,0 +1,43 @@ +#include + +int foo(int x, int y) { return x + y - 1; } + +struct Bar { + int operator()() { return 66; } + int add_num(int i) const { return i + 3; } + int add_num2(int i) { + std::function add_num2_f = [](int x) { return x + 1; }; + + return add_num2_f(i); // Set break point at this line. + } +}; + +int foo2() { + auto f = [](int x) { return x + 1; }; + + std::function foo2_f = f; + + return foo2_f(10); // Set break point at this line. +} + +int main(int argc, char *argv[]) { + int acc = 42; + std::function f1 = foo; + std::function f2 = [acc, f1](int x) -> int { + return x + f1(acc, x); + }; + + auto f = [](int x, int y) { return x + y; }; + auto g = [](int x, int y) { return x * y; }; + std::function f3 = argc % 2 ? f : g; + + Bar bar1; + std::function f4(bar1); + std::function f5 = &Bar::add_num; + + int foo2_result = foo2(); + int bar_add_num2_result = bar1.add_num2(10); + + return f1(acc, acc) + f2(acc) + f3(acc + 1, acc + 2) + f4() + + f5(bar1, 10); // Set break point at this line. +} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/Makefile similarity index 75% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/Makefile index 680e1abfbef58..99998b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/Makefile @@ -1,4 +1,3 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/TestDataFormatterStdInitializerList.py similarity index 78% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/TestDataFormatterStdInitializerList.py index b8a1dd3569d77..09ad19140077f 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/TestDataFormatterStdInitializerList.py @@ -2,7 +2,6 @@ Test lldb data formatter subsystem. """ - import re import lldb from lldbsuite.test.decorators import * @@ -10,11 +9,9 @@ from lldbsuite.test import lldbutil -class InitializerListTestCase(TestBase): - @add_test_categories(["libc++"]) - def test(self): +class StdInitializerListTestCase(TestBase): + def do_test(self): """Test that that file and class static variables display correctly.""" - self.build() self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( @@ -39,3 +36,13 @@ def test(self): "frame variable ils", substrs=['[4] = "surprise it is a long string!! yay!!"'], ) + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/main.cpp new file mode 100644 index 0000000000000..a9d159e0be28a --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/main.cpp @@ -0,0 +1,11 @@ +#include +#include +#include + +int main() { + std::initializer_list ili{1, 2, 3, 4, 5}; + std::initializer_list ils{ + "1", "2", "3", "4", "surprise it is a long string!! yay!!"}; + + return 0; // Set break point at this line. +} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile similarity index 80% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile index 564cbada74e08..a149c7f81bfab 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile @@ -1,6 +1,4 @@ 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/iterator/TestDataFormatterLibccIterator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterIterator.py similarity index 90% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterIterator.py index c43ee46fb658a..b95775df6dbb6 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterIterator.py @@ -2,14 +2,13 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxIteratorDataFormatterTestCase(TestBase): +class StdIteratorDataFormatterTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -17,10 +16,8 @@ def setUp(self): self.line = line_number("main.cpp", "// Set break point at this line.") self.namespace = "std" - @add_test_categories(["libc++"]) - def test_with_run_command(self): - """Test that libc++ iterators format properly.""" - self.build() + def do_test(self): + """Test that STL iterators format properly.""" self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( @@ -84,3 +81,13 @@ def cleanup(): self.expect("frame variable siumI.first", substrs=["second"], matching=False) self.expect("frame variable siumI.second", substrs=["second = 137"]) self.expect("frame variable siumI.second", substrs=["first"], matching=False) + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile similarity index 75% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile index 680e1abfbef58..99998b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile @@ -1,4 +1,3 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterMap.py similarity index 97% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterMap.py index b2b83a3b46114..2ba2dbc6ec176 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterMap.py @@ -2,14 +2,13 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxMapDataFormatterTestCase(TestBase): +class StdMapDataFormatterTestCase(TestBase): def setUp(self): TestBase.setUp(self) ns = "ndk" if lldbplatformutil.target_is_android() else "" @@ -22,10 +21,8 @@ def check_pair(self, first_value, second_value): ] return ValueCheck(children=pair_children) - @add_test_categories(["libc++"]) - def test_with_run_command(self): + def do_test(self): """Test that that file and class static variables display correctly.""" - self.build() self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( @@ -326,3 +323,13 @@ def cleanup(): lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ss", substrs=["%s::map" % ns, "size=0", "{}"]) + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/main.cpp new file mode 100644 index 0000000000000..91bdf0b58d9e4 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/main.cpp @@ -0,0 +1,80 @@ +#include +#include + +#define intint_map std::map +#define strint_map std::map +#define intstr_map std::map +#define strstr_map std::map + +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; +} + +int main() { + intint_map ii; + + ii[0] = 0; // Set break point at this line. + ii[1] = 1; + + intint_map::iterator it = ii.begin(); + intint_map::const_iterator const_it = ii.cbegin(); + std::printf("%d %d\n", it->second, const_it->second); + + thefoo_rw(1); // Set break point at this line. + ii[2] = 0; + ii[3] = 1; + thefoo_rw(1); // Set break point at this line. + ii[4] = 0; + ii[5] = 1; + ii[6] = 0; + ii[7] = 1; + thefoo_rw(1); // Set break point at this line. + ii[85] = 1234567; + + ii.clear(); + + strint_map si; + thefoo_rw(1); // Set break point at this line. + + si["zero"] = 0; + thefoo_rw(1); // Set break point at this line. + si["one"] = 1; + si["two"] = 2; + si["three"] = 3; + thefoo_rw(1); // Set break point at this line. + si["four"] = 4; + + si.clear(); + thefoo_rw(1); // Set break point at this line. + + intstr_map is; + thefoo_rw(1); // Set break point at this line. + is[85] = "goofy"; + is[1] = "is"; + is[2] = "smart"; + is[3] = "!!!"; + thefoo_rw(1); // Set break point at this line. + + is.clear(); + thefoo_rw(1); // Set break point at this line. + + strstr_map ss; + thefoo_rw(1); // Set break point at this line. + + ss["ciao"] = "hello"; + ss["casa"] = "house"; + ss["gatto"] = "cat"; + thefoo_rw(1); // Set break point at this line. + ss["a Mac.."] = "..is always a Mac!"; + + ss.clear(); + thefoo_rw(1); // Set break point at this line. + return 0; +} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile similarity index 75% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile index d87cf7d402787..99998b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile @@ -1,4 +1,3 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 -include Makefile.rules +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py similarity index 72% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py index 53eaf5a23cc07..5966e59f20dad 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py @@ -2,14 +2,13 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class TestDataFormatterLibcxxQueue(TestBase): +class TestDataFormatterStdQueue(TestBase): def setUp(self): TestBase.setUp(self) self.namespace = "std" @@ -26,16 +25,27 @@ def check_variable(self, name): self.assertTrue(ch.IsValid()) self.assertEqual(ch.GetValueAsSigned(), i + 1) - @expectedFailureAll( - bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android" - ) - @add_test_categories(["libc++"]) - def test(self): + def do_test(self): """Test that std::queue is displayed correctly""" - self.build() lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp", False) ) self.check_variable("q1") self.check_variable("q2") + + @expectedFailureAll( + bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android" + ) + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @expectedFailureAll( + bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android" + ) + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp similarity index 54% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp index f3b5f32817970..406b437914932 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp @@ -2,8 +2,8 @@ #include int main() { - std::queue q1{{1,2,3,4,5}}; - std::queue> q2{{1,2,3,4,5}}; + std::queue q1{{1, 2, 3, 4, 5}}; + std::queue> q2{{1, 2, 3, 4, 5}}; int ret = q1.size() + q2.size(); // break here return ret; } diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/Makefile similarity index 81% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/Makefile index 20c9cf06b1a63..4f79c0a900c3a 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/Makefile @@ -1,7 +1,4 @@ CXX_SOURCES := main.cpp - -USE_LIBCPP := 1 - CXXFLAGS_EXTRAS := -std=c++20 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/TestDataFormatterStdRangesRefView.py similarity index 84% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/TestDataFormatterStdRangesRefView.py index 9b5194be91e78..aa753ffeaa6fb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/TestDataFormatterStdRangesRefView.py @@ -8,7 +8,7 @@ from lldbsuite.test import lldbutil -class LibcxxRangesRefViewDataFormatterTestCase(TestBase): +class StdRangesRefViewDataFormatterTestCase(TestBase): def check_string_vec_children(self): return [ ValueCheck(name="[0]", summary='"First"'), @@ -27,12 +27,8 @@ def check_string_vec_ref_view(self): def check_foo(self): return ValueCheck(name="vec", children=self.check_string_vec_children()) - @add_test_categories(["libc++"]) - @skipIf(compiler=no_match("clang")) - @skipIf(compiler="clang", compiler_version=["<", "16.0"]) - def test_with_run_command(self): + def do_test(self): """Test that std::ranges::ref_view is formatted correctly when printed.""" - self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "Break here", lldb.SBFileSpec("main.cpp", False) ) @@ -69,3 +65,17 @@ def test_with_run_command(self): ) ], ) + + @skipIf(compiler=no_match("clang")) + @skipIf(compiler="clang", compiler_version=["<", "16.0"]) + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @skipIf(compiler=no_match("clang")) + @skipIf(compiler="clang", compiler_version=["<", "16.0"]) + @add_test_categories(["libstdcxx"]) + def test_libstdcpp(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py index 03e18ff4335e5..5f80bc8b38b9b 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -2,7 +2,6 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -137,7 +136,7 @@ def test_with_run_command_libcpp(self): def do_test_ref_and_ptr(self, stdlib_type): """Test that the data formatters work on ref and ptr.""" - self.build() + self.build(dictionary={stdlib_type: "1"}) (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( self, "Stop here to check by ref and ptr.", diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile similarity index 92% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile index c1c8b4a2a0a53..ece665a0fd5b7 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile @@ -1,7 +1,5 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 - # We need debug info tuning for lldb in order to emit the preferred name for # std::string. See https://reviews.llvm.org/D145803. CXXFLAGS_EXTRAS := -std=c++14 -glldb diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py similarity index 91% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py index 61c050b3bfa01..d8390b757bb11 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py @@ -1,8 +1,7 @@ """ -Test lldb data formatter for libc++ std::shared_ptr. +Test lldb data formatter for std::shared_ptr. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -10,11 +9,8 @@ class TestCase(TestBase): - @add_test_categories(["libc++"]) - def test_shared_ptr_variables(self): + def do_test(self): """Test `frame variable` output for `std::shared_ptr` types.""" - self.build() - lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp") ) @@ -96,3 +92,13 @@ def test_shared_ptr_variables(self): self.expect_var_path("ptr_node->next->value", value="2") self.expect_var_path("(*ptr_node).value", value="1") self.expect_var_path("(*(*ptr_node).next).value", value="2") + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/Makefile similarity index 83% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/Makefile index 3c4f9b45f41de..344f9e1d7fd7b 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/Makefile @@ -1,6 +1,5 @@ -USE_LIBCPP := 1 - CXX_SOURCES := main.cpp + CXXFLAGS_EXTRAS := -std=c++20 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/TestDataFormatterStdSpan.py similarity index 88% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/TestDataFormatterStdSpan.py index 42efe415b6acf..e8868fb0e11a4 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/TestDataFormatterStdSpan.py @@ -8,7 +8,7 @@ from lldbsuite.test import lldbutil -class LibcxxSpanDataFormatterTestCase(TestBase): +class StdSpanDataFormatterTestCase(TestBase): def findVariable(self, name): var = self.frame().FindVariable(name) self.assertTrue(var.IsValid()) @@ -44,11 +44,8 @@ def check_numbers(self, var_name): self.expect_var_path(f"{var_name}[3]", type="int", value="1234") self.expect_var_path(f"{var_name}[4]", type="int", value="12345") - @add_test_categories(["libc++"]) - @skipIf(compiler="clang", compiler_version=["<", "11.0"]) - def test_with_run_command(self): + def do_test(self): """Test that std::span variables are formatted correctly when printed.""" - self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "break here", lldb.SBFileSpec("main.cpp", False) ) @@ -160,9 +157,18 @@ def test_with_run_command(self): @add_test_categories(["libc++"]) @skipIf(compiler="clang", compiler_version=["<", "11.0"]) - def test_ref_and_ptr(self): + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + @skipIf(compiler="clang", compiler_version=["<", "11.0"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() + + def do_test_ref_and_ptr(self): """Test that std::span is correctly formatted when passed by ref and ptr""" - self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "Stop here to check by ref", lldb.SBFileSpec("main.cpp", False) ) @@ -173,3 +179,15 @@ def test_ref_and_ptr(self): # The pointer should just show the right number of elements: self.expect("frame variable ptr", patterns=["ptr = 0x[0-9a-f]+ size=5"]) + + @add_test_categories(["libc++"]) + @skipIf(compiler="clang", compiler_version=["<", "11.0"]) + def test_ref_and_ptr_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test_ref_and_ptr() + + @add_test_categories(["libstdcxx"]) + @skipIf(compiler="clang", compiler_version=["<", "11.0"]) + def test_ref_and_ptr_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test_ref_and_ptr() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/Makefile similarity index 82% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/Makefile index c7c91da728d1e..7025148aa9eb5 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/Makefile @@ -1,6 +1,4 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 - CXXFLAGS_EXTRAS := -std=c++11 -O0 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/TestDataFormatterStdStringView.py similarity index 93% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/TestDataFormatterStdStringView.py index 3883395f23924..4d7c745475720 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/TestDataFormatterStdStringView.py @@ -10,7 +10,7 @@ from lldbsuite.test import lldbutil -class LibcxxStringViewDataFormatterTestCase(TestBase): +class StdStringViewDataFormatterTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -20,16 +20,10 @@ def setUp(self): "main.cpp", "// Break here to look at bad string view." ) - @add_test_categories(["libc++"]) - @expectedFailureAll( - bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android" - ) # Inline namespace is randomly ignored as Clang due to broken lookup inside # the std namespace. - @expectedFailureAll(debug_info="gmodules") - def test_with_run_command(self): + def do_test(self): """Test that that file and class static variables display correctly.""" - self.build() self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( @@ -160,3 +154,19 @@ def cleanup(): broken_obj = self.frame().GetValueForVariablePath("in_str_view") self.assertEqual(broken_obj.GetSummary(), "Summary Unavailable") + + @expectedFailureAll( + bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android" + ) + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @expectedFailureAll( + bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android" + ) + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/valarray/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile similarity index 73% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/valarray/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile index c5df567e01a2a..99998b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/valarray/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile @@ -1,5 +1,3 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 - include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/TestDataFormatterLibcxxTuple.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterTuple.py similarity index 77% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/TestDataFormatterLibcxxTuple.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterTuple.py index 5b6dfaf5e5d9d..01a7beb0667a1 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/TestDataFormatterLibcxxTuple.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterTuple.py @@ -2,23 +2,20 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class TestDataFormatterLibcxxTuple(TestBase): +class TestDataFormatterStdTuple(TestBase): def setUp(self): TestBase.setUp(self) self.line = line_number("main.cpp", "// break here") self.namespace = "std" - @add_test_categories(["libc++"]) - def test(self): + def do_test(self): """Test that std::tuple is displayed correctly""" - self.build() lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp", False) ) @@ -43,3 +40,13 @@ def test(self): "}", ], ) + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/main.cpp index beb44cd960005..1ef59bbc6146b 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/main.cpp @@ -1,5 +1,5 @@ -#include #include +#include int main() { std::tuple<> empty; diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/Makefile similarity index 92% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/Makefile index c1c8b4a2a0a53..ece665a0fd5b7 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/Makefile @@ -1,7 +1,5 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 - # We need debug info tuning for lldb in order to emit the preferred name for # std::string. See https://reviews.llvm.org/D145803. CXXFLAGS_EXTRAS := -std=c++14 -glldb diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/TestDataFormatterUniquePtr.py similarity index 93% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/TestDataFormatterUniquePtr.py index 25a1cd82a4baa..673f453b18bbe 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/TestDataFormatterUniquePtr.py @@ -1,8 +1,7 @@ """ -Test lldb data formatter for libc++ std::unique_ptr. +Test lldb data formatter for std::unique_ptr. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -32,11 +31,8 @@ def make_expected_basic_string_ptr(self) -> str: "std::default_delete, std::allocator > > >" ) - @add_test_categories(["libc++"]) - def test_unique_ptr_variables(self): + def do_test(self): """Test `frame variable` output for `std::unique_ptr` types.""" - self.build() - lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp") ) @@ -121,3 +117,13 @@ def test_unique_ptr_variables(self): self.expect_var_path("ptr_node->next->value", value="2") self.expect_var_path("(*ptr_node).value", value="1") self.expect_var_path("(*(*ptr_node).next).value", value="2") + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/main.cpp similarity index 96% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/main.cpp index afdddf0bbaf16..16e2ad614dcb8 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/main.cpp @@ -15,7 +15,7 @@ struct NodeU { // representation when the type of the second element is an empty class. So // we need a deleter class with a dummy data member to trigger the other path. struct NonEmptyIntDeleter { - void operator()(int* ptr) { delete ptr; } + void operator()(int *ptr) { delete ptr; } int dummy_ = 9999; }; diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/Makefile new file mode 100644 index 0000000000000..99998b20bcb05 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/TestDataFormatterLibccUnorderedMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMapIterator.py similarity index 91% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/TestDataFormatterLibccUnorderedMap.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMapIterator.py index bf103aa78baba..f908136f288fb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/TestDataFormatterLibccUnorderedMap.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMapIterator.py @@ -8,7 +8,7 @@ from lldbsuite.test import lldbutil -class LibcxxUnorderedMapDataFormatterTestCase(TestBase): +class StdUnorderedMapIteratorDataFormatterTestCase(TestBase): def check_ptr_or_ref(self, var_name: str): var = self.frame().FindVariable(var_name) self.assertTrue(var) @@ -32,12 +32,10 @@ def check_ptr_ptr(self, var_name: str): self.assertEqual(pair.GetChildAtIndex(0).summary, '"Hello"') self.assertEqual(pair.GetChildAtIndex(1).summary, '"World"') - @add_test_categories(["libc++"]) - def test_iterator_formatters(self): + def do_test(self): """Test that std::unordered_map related structures are formatted correctly when printed. Currently only tests format of std::unordered_map iterators. """ - self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "Break here", lldb.SBFileSpec("main.cpp", False) ) @@ -113,3 +111,13 @@ def test_iterator_formatters(self): self.check_ptr_ptr("ptr4") self.check_ptr_ptr("ptr5") self.check_ptr_ptr("ptr6") + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/Makefile new file mode 100644 index 0000000000000..99998b20bcb05 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/valarray/TestDataFormatterLibcxxValarray.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/TestDataFormatterStdValarray.py similarity index 94% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/valarray/TestDataFormatterLibcxxValarray.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/TestDataFormatterStdValarray.py index 613546b50a770..1fdfa6bfdbf33 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/valarray/TestDataFormatterLibcxxValarray.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/TestDataFormatterStdValarray.py @@ -2,18 +2,15 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxChronoDataFormatterTestCase(TestBase): - @add_test_categories(["libc++"]) - def test_with_run_command(self): +class StdValarrayDataFormatterTestCase(TestBase): + def do_test(self): """Test that that file and class static variables display correctly.""" - self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "break here", lldb.SBFileSpec("main.cpp", False) ) @@ -179,3 +176,13 @@ def test_with_run_command(self): error=True, substrs=['array index 3 is not valid for "(indirect_array) ia"'], ) + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/valarray/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/valarray/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile similarity index 82% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile index 7eeff7407804d..8783ac3ad8a4e 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile @@ -1,6 +1,4 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 - CXXFLAGS_EXTRAS := -std=c++17 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py similarity index 77% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py index 47e07a5ce3f5b..3b19b1fac5bc2 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py @@ -2,27 +2,15 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxVariantDataFormatterTestCase(TestBase): - @add_test_categories(["libc++"]) - ## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions - ## with -std=c++17. - @skipIf( - oslist=no_match(["macosx"]), compiler="clang", compiler_version=["<", "7.0"] - ) - ## We are skipping gcc version less that 5.1 since this test requires -std=c++17 - @skipIf(compiler="gcc", compiler_version=["<", "5.1"]) - ## std::get is unavailable for std::variant before macOS 10.14 - @skipIf(macos_version=["<", "10.14"]) - def test_with_run_command(self): +class StdVariantDataFormatterTestCase(TestBase): + def do_test(self): """Test that that file and class static variables display correctly.""" - self.build() (self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp", False) @@ -86,3 +74,31 @@ def test_with_run_command(self): "frame variable v_300_types_no_value", substrs=["v_300_types_no_value = No Value"], ) + + ## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions + ## with -std=c++17. + @skipIf( + oslist=no_match(["macosx"]), compiler="clang", compiler_version=["<", "7.0"] + ) + ## We are skipping gcc version less that 5.1 since this test requires -std=c++17 + @skipIf(compiler="gcc", compiler_version=["<", "5.1"]) + ## std::get is unavailable for std::variant before macOS 10.14 + @skipIf(macos_version=["<", "10.14"]) + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + ## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions + ## with -std=c++17. + @skipIf( + oslist=no_match(["macosx"]), compiler="clang", compiler_version=["<", "7.0"] + ) + ## We are skipping gcc version less that 5.1 since this test requires -std=c++17 + @skipIf(compiler="gcc", compiler_version=["<", "5.1"]) + ## std::get is unavailable for std::variant before macOS 10.14 + @skipIf(macos_version=["<", "10.14"]) + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/main.cpp new file mode 100644 index 0000000000000..b136b05d3abd7 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/main.cpp @@ -0,0 +1,93 @@ +#include +#include +#include + +// If we have libc++ 4.0 or greater we should have +// According to libc++ C++1z status page +// https://libcxx.llvm.org/cxx1z_status.html +#if _LIBCPP_VERSION >= 4000 +#include +#define HAVE_VARIANT 1 +#else +#define HAVE_VARIANT 0 +#endif + +struct S { + operator int() { throw 42; } +}; + +int main() { + bool has_variant = HAVE_VARIANT; + + printf("%d\n", has_variant); // break here + +#if HAVE_VARIANT == 1 + std::variant v1; + std::variant &v1_ref = v1; + std::variant v2; + std::variant v3; + std::variant> v_v1; + std::variant v_no_value; + // The next variant has 300 types, meaning the type index does not fit in + // a byte and must be `unsigned short` instead of `unsigned char` when + // using the unstable libc++ ABI. With stable libc++ ABI, the type index + // is always just `unsigned int`. + std::variant< + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int, int, int, int> + v_300_types_no_value; + + v1 = 12; // v contains int + v_v1 = v1; + int i = std::get(v1); + printf("%d\n", i); // break here + + v2 = 2.0; + double d = std::get(v2); + printf("%f\n", d); + + v3 = 'A'; + char c = std::get(v3); + printf("%d\n", c); + + // Checking v1 above and here to make sure we done maintain the incorrect + // state when we change its value. + v1 = 2.0; + d = std::get(v1); + printf("%f\n", d); // break here + + try { + v_no_value.emplace<0>(S()); + } catch (...) { + } + + printf("%zu\n", v_no_value.index()); + + try { + v_300_types_no_value.emplace<0>(S()); + } catch (...) { + } + + printf("%zu\n", v_300_types_no_value.index()); +#endif + + return 0; // break here +} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile new file mode 100644 index 0000000000000..8046b0bca5533 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp +include Makefile.rules + diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterVBool.py similarity index 87% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterVBool.py index 24dddee62e1e7..425b30d925835 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterVBool.py @@ -2,24 +2,21 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxVBoolDataFormatterTestCase(TestBase): +class StdVBoolDataFormatterTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break at. self.line = line_number("main.cpp", "// Set break point at this line.") - @add_test_categories(["libc++"]) - def test_with_run_command(self): + def do_test(self): """Test that that file and class static variables display correctly.""" - self.build() self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( @@ -74,3 +71,13 @@ def cleanup(): "[48] = true", ], ) + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/main.cpp new file mode 100644 index 0000000000000..0f0c6560121e5 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/main.cpp @@ -0,0 +1,64 @@ +#include +#include + +int main() { + std::vector vBool; + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(true); + + printf("size: %d", (int)vBool.size()); // Set break point at this line. + return 0; +} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/Makefile new file mode 100644 index 0000000000000..99998b20bcb05 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/TestDataFormatterVector.py similarity index 90% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/TestDataFormatterVector.py index 13341a9b274be..63d2c29f7ea54 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/TestDataFormatterVector.py @@ -2,14 +2,13 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxVectorDataFormatterTestCase(TestBase): +class StdVectorDataFormatterTestCase(TestBase): def check_numbers(self, var_name, show_ptr=False): patterns = [] substrs = [ @@ -52,10 +51,8 @@ def check_numbers(self, var_name, show_ptr=False): self.expect("frame variable " + var_name + "[2]", substrs=["123"]) self.expect("frame variable " + var_name + "[3]", substrs=["1234"]) - @add_test_categories(["libc++"]) - def test_with_run_command(self): + def do_test(self): """Test that that file and class static variables display correctly.""" - self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "break here", lldb.SBFileSpec("main.cpp", False) ) @@ -171,9 +168,17 @@ def cleanup(): self.expect("frame variable strings", substrs=["vector has 0 items"]) @add_test_categories(["libc++"]) - def test_ref_and_ptr(self): + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() + + def do_test_ref_and_ptr(self): """Test that that file and class static variables display correctly.""" - self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "Stop here to check by ref", lldb.SBFileSpec("main.cpp", False) ) @@ -186,3 +191,13 @@ def test_ref_and_ptr(self): self.expect("frame variable ptr", substrs=["ptr =", " size=7"]) self.expect("expression ptr", substrs=["$", "size=7"]) + + @add_test_categories(["libc++"]) + def test_ref_and_ptr_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test_ref_and_ptr() + + @add_test_categories(["libstdcxx"]) + def test_ref_and_ptr_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test_ref_and_ptr() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/main.cpp new file mode 100644 index 0000000000000..19cd1893bd22a --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/main.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +typedef std::vector int_vect; +typedef std::vector string_vect; + +template +void by_ref_and_ptr(std::vector &ref, std::vector *ptr) { + // Stop here to check by ref + return; +} + +int main() { + int_vect numbers; + (numbers.push_back(1)); // break here + (numbers.push_back(12)); // break here + (numbers.push_back(123)); + (numbers.push_back(1234)); + (numbers.push_back(12345)); // break here + (numbers.push_back(123456)); + (numbers.push_back(1234567)); + by_ref_and_ptr(numbers, &numbers); + + printf("break here"); + numbers.clear(); + + (numbers.push_back(7)); // break here + + string_vect strings; + (strings.push_back(std::string("goofy"))); + (strings.push_back(std::string("is"))); + (strings.push_back(std::string("smart"))); + printf("break here"); + (strings.push_back(std::string("!!!"))); + + printf("break here"); + strings.clear(); + + return 0; // break here +} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp deleted file mode 100644 index ef7c97470652f..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include - -int foo(int x, int y) { - return x + y - 1; -} - -struct Bar { - int operator()() { - return 66 ; - } - int add_num(int i) const { return i + 3 ; } - int add_num2(int i) { - std::function add_num2_f = [](int x) { - return x+1; - }; - - return add_num2_f(i); // Set break point at this line. - } -} ; - -int foo2() { - auto f = [](int x) { - return x+1; - }; - - std::function foo2_f = f; - - return foo2_f(10); // Set break point at this line. -} - -int main (int argc, char *argv[]) -{ - int acc = 42; - std::function f1 = foo; - std::function f2 = [acc,f1] (int x) -> int { - return x+f1(acc,x); - }; - - auto f = [](int x, int y) { return x + y; }; - auto g = [](int x, int y) { return x * y; } ; - std::function f3 = argc %2 ? f : g ; - - Bar bar1 ; - std::function f4( bar1 ) ; - std::function f5 = &Bar::add_num; - - int foo2_result = foo2(); - int bar_add_num2_result = bar1.add_num2(10); - - return f1(acc,acc) + f2(acc) + f3(acc+1,acc+2) + f4() + f5(bar1, 10); // Set break point at this line. -} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile deleted file mode 100644 index 98af672c70fbe..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -CXX_SOURCES := main.cpp -CXXFLAGS_EXTRAS := -std=c++11 - -USE_LIBCPP := 1 - -include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp deleted file mode 100644 index 88fe273ae8e3e..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#include - -int main () -{ - std::initializer_list ili{1,2,3,4,5}; - std::initializer_list ils{"1","2","3","4","surprise it is a long string!! yay!!"}; - - return 0; // Set break point at this line. -} - diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile deleted file mode 100644 index 564cbada74e08..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -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/map/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/Makefile deleted file mode 100644 index 564cbada74e08..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -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/map/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp deleted file mode 100644 index 43ce6aeefd2a2..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include - -#define intint_map std::map -#define strint_map std::map -#define intstr_map std::map -#define strstr_map std::map - -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; -} - -int main() -{ - intint_map ii; - - ii[0] = 0; // Set break point at this line. - ii[1] = 1; - - intint_map::iterator it = ii.begin(); - intint_map::const_iterator const_it = ii.cbegin(); - std::printf("%d %d\n", it->second, const_it->second); - - thefoo_rw(1); // Set break point at this line. - ii[2] = 0; - ii[3] = 1; - thefoo_rw(1); // Set break point at this line. - ii[4] = 0; - ii[5] = 1; - ii[6] = 0; - ii[7] = 1; - thefoo_rw(1); // Set break point at this line. - ii[85] = 1234567; - - ii.clear(); - - strint_map si; - thefoo_rw(1); // Set break point at this line. - - si["zero"] = 0; - thefoo_rw(1); // Set break point at this line. - si["one"] = 1; - si["two"] = 2; - si["three"] = 3; - thefoo_rw(1); // Set break point at this line. - si["four"] = 4; - - si.clear(); - thefoo_rw(1); // Set break point at this line. - - intstr_map is; - thefoo_rw(1); // Set break point at this line. - is[85] = "goofy"; - is[1] = "is"; - is[2] = "smart"; - is[3] = "!!!"; - thefoo_rw(1); // Set break point at this line. - - is.clear(); - thefoo_rw(1); // Set break point at this line. - - strstr_map ss; - thefoo_rw(1); // Set break point at this line. - - ss["ciao"] = "hello"; - ss["casa"] = "house"; - ss["gatto"] = "cat"; - thefoo_rw(1); // Set break point at this line. - ss["a Mac.."] = "..is always a Mac!"; - - ss.clear(); - thefoo_rw(1); // Set break point at this line. - return 0; -} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp deleted file mode 100644 index 560ec692f30ed..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include -#include -#include - -// If we have libc++ 4.0 or greater we should have -// According to libc++ C++1z status page https://libcxx.llvm.org/cxx1z_status.html -#if _LIBCPP_VERSION >= 4000 -#include -#define HAVE_VARIANT 1 -#else -#define HAVE_VARIANT 0 -#endif - -struct S { - operator int() { throw 42; } -} ; - - -int main() -{ - bool has_variant = HAVE_VARIANT ; - - printf( "%d\n", has_variant ) ; // break here - -#if HAVE_VARIANT == 1 - std::variant v1; - std::variant &v1_ref = v1; - std::variant v2; - std::variant v3; - std::variant> v_v1 ; - std::variant v_no_value; - // The next variant has 300 types, meaning the type index does not fit in - // a byte and must be `unsigned short` instead of `unsigned char` when - // using the unstable libc++ ABI. With stable libc++ ABI, the type index - // is always just `unsigned int`. - std::variant< - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int> - v_300_types_no_value; - - v1 = 12; // v contains int - v_v1 = v1 ; - int i = std::get(v1); - printf( "%d\n", i ); // break here - - v2 = 2.0 ; - double d = std::get(v2) ; - printf( "%f\n", d ); - - v3 = 'A' ; - char c = std::get(v3) ; - printf( "%d\n", c ); - - // Checking v1 above and here to make sure we done maintain the incorrect - // state when we change its value. - v1 = 2.0; - d = std::get(v1) ; - printf( "%f\n", d ); // break here - - try { - v_no_value.emplace<0>(S()); - } catch( ... ) {} - - printf( "%zu\n", v_no_value.index() ) ; - - try { - v_300_types_no_value.emplace<0>(S()); - } catch (...) { - } - - printf("%zu\n", v_300_types_no_value.index()); -#endif - - return 0; // break here -} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp deleted file mode 100644 index 026cfc863f2c0..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include - -int main() -{ - std::vector vBool; - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(true); - - printf ("size: %d", (int) vBool.size()); // Set break point at this line. - return 0; -} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/Makefile deleted file mode 100644 index 564cbada74e08..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -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/vector/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp deleted file mode 100644 index 0e1dbe4f03e2b..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include -typedef std::vector int_vect; -typedef std::vector string_vect; - -template -void by_ref_and_ptr(std::vector &ref, std::vector *ptr) { - // Stop here to check by ref - return; -} - -int main() -{ - int_vect numbers; - (numbers.push_back(1)); // break here - (numbers.push_back(12)); // break here - (numbers.push_back(123)); - (numbers.push_back(1234)); - (numbers.push_back(12345)); // break here - (numbers.push_back(123456)); - (numbers.push_back(1234567)); - by_ref_and_ptr(numbers, &numbers); - - printf("break here"); - numbers.clear(); - - (numbers.push_back(7)); // break here - - string_vect strings; - (strings.push_back(std::string("goofy"))); - (strings.push_back(std::string("is"))); - (strings.push_back(std::string("smart"))); - printf("break here"); - (strings.push_back(std::string("!!!"))); - - printf("break here"); - strings.clear(); - - return 0; // break here -}