diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module')
69 files changed, 1169 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/basic/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/basic/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/basic/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/basic/TestImportStdModule.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/basic/TestImportStdModule.py new file mode 100644 index 00000000000..19e02ca84c9 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/basic/TestImportStdModule.py @@ -0,0 +1,56 @@ +""" +Test importing the 'std' C++ module and evaluate expressions with it. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class ImportStdModule(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + # Activate importing of std module. + self.runCmd("settings set target.import-std-module true") + # Calling some normal std functions that return non-template types. + self.expect("expr std::abs(-42)", substrs=['(int) $0 = 42']) + self.expect("expr std::div(2, 1).quot", substrs=['(int) $1 = 2']) + # Using types from std. + self.expect("expr (std::size_t)33U", substrs=['(size_t) $2 = 33']) + # Calling templated functions that return non-template types. + self.expect("expr char char_a = 'b'; char char_b = 'a'; std::swap(char_a, char_b); char_a", + substrs=["(char) $3 = 'a'"]) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test_non_cpp_language(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + # Activate importing of std module. + self.runCmd("settings set target.import-std-module true") + # These languages don't support C++ modules, so they shouldn't + # be able to evaluate the expression. + self.expect("expr -l C -- std::abs(-42)", error=True) + self.expect("expr -l C99 -- std::abs(-42)", error=True) + self.expect("expr -l C11 -- std::abs(-42)", error=True) + self.expect("expr -l ObjC -- std::abs(-42)", error=True) diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/basic/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/basic/main.cpp new file mode 100644 index 00000000000..2f6d078daa3 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/basic/main.cpp @@ -0,0 +1,7 @@ +// We need to import any std module. It doesn't matter which one. +#include <iostream> + +int main(int argc, char **argv) { + std::cout << "Test" << std::endl; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/conflicts/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/conflicts/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/conflicts/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py new file mode 100644 index 00000000000..2abaece27fe --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py @@ -0,0 +1,36 @@ +""" +Test importing the 'std' C++ module and check if we can handle +prioritizing the conflicting functions from debug info and std +module. + +See also import-std-module/basic/TestImportStdModule.py for +the same test on a 'clean' code base without conflicts. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestImportStdModuleConflicts(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + self.expect("expr std::abs(-42)", substrs=['(int) $0 = 42']) + self.expect("expr std::div(2, 1).quot", substrs=['(int) $1 = 2']) + self.expect("expr (std::size_t)33U", substrs=['(size_t) $2 = 33']) + self.expect("expr char char_a = 'b'; char char_b = 'a'; std::swap(char_a, char_b); char_a", + substrs=["(char) $3 = 'a'"]) diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/conflicts/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/conflicts/main.cpp new file mode 100644 index 00000000000..e49b862a36c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/conflicts/main.cpp @@ -0,0 +1,10 @@ +#include <cstdlib> +#include <utility> + +int main(int argc, char **argv) { + std::size_t f = argc; + f = std::abs(argc); + f = std::div(argc * 2, argc).quot; + std::swap(f, f); + return f; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-basic/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-basic/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-basic/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-basic/TestBasicDeque.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-basic/TestBasicDeque.py new file mode 100644 index 00000000000..0ede19e8350 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-basic/TestBasicDeque.py @@ -0,0 +1,41 @@ +""" +Test basic std::list functionality. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestBasicDeque(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) + self.expect("expr (int)a.front()", substrs=['(int) $1 = 3']) + self.expect("expr (int)a.back()", substrs=['(int) $2 = 2']) + + self.expect("expr std::sort(a.begin(), a.end())") + self.expect("expr (int)a.front()", substrs=['(int) $3 = 1']) + self.expect("expr (int)a.back()", substrs=['(int) $4 = 3']) + + self.expect("expr std::reverse(a.begin(), a.end())") + self.expect("expr (int)a.front()", substrs=['(int) $5 = 3']) + self.expect("expr (int)a.back()", substrs=['(int) $6 = 1']) + + self.expect("expr (int)(*a.begin())", substrs=['(int) $7 = 3']) + self.expect("expr (int)(*a.rbegin())", substrs=['(int) $8 = 1']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-basic/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-basic/main.cpp new file mode 100644 index 00000000000..5bed55674bf --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-basic/main.cpp @@ -0,0 +1,6 @@ +#include <deque> + +int main(int argc, char **argv) { + std::deque<int> a = {3, 1, 2}; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-dbg-info-content/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-dbg-info-content/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-dbg-info-content/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDeque.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDeque.py new file mode 100644 index 00000000000..eeea34819dd --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDeque.py @@ -0,0 +1,37 @@ +""" +Test std::deque functionality with a decl from dbg info as content. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestDbgInfoContentDeque(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) + self.expect("expr (int)a.front().a", substrs=['(int) $1 = 3']) + self.expect("expr (int)a.back().a", substrs=['(int) $2 = 2']) + + self.expect("expr std::reverse(a.begin(), a.end())") + self.expect("expr (int)a.front().a", substrs=['(int) $3 = 2']) + self.expect("expr (int)a.back().a", substrs=['(int) $4 = 3']) + + self.expect("expr (int)(a.begin()->a)", substrs=['(int) $5 = 2']) + self.expect("expr (int)(a.rbegin()->a)", substrs=['(int) $6 = 3']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-dbg-info-content/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-dbg-info-content/main.cpp new file mode 100644 index 00000000000..f8fd1fb2dd9 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/deque-dbg-info-content/main.cpp @@ -0,0 +1,10 @@ +#include <deque> + +struct Foo { + int a; +}; + +int main(int argc, char **argv) { + std::deque<Foo> a = {{3}, {1}, {2}}; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-basic/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-basic/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-basic/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-basic/TestBasicForwardList.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-basic/TestBasicForwardList.py new file mode 100644 index 00000000000..528d555e0af --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-basic/TestBasicForwardList.py @@ -0,0 +1,34 @@ +""" +Test basic std::forward_list functionality. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestBasicForwardList(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (size_t)std::distance(a.begin(), a.end())", substrs=['(size_t) $0 = 3']) + self.expect("expr (int)a.front()", substrs=['(int) $1 = 3']) + + self.expect("expr a.sort()") + self.expect("expr (int)a.front()", substrs=['(int) $2 = 1']) + + self.expect("expr (int)(*a.begin())", substrs=['(int) $3 = 1']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-basic/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-basic/main.cpp new file mode 100644 index 00000000000..4f5e30f0629 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-basic/main.cpp @@ -0,0 +1,6 @@ +#include <forward_list> + +int main(int argc, char **argv) { + std::forward_list<int> a = {3, 1, 2}; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-dbg-info-content/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-dbg-info-content/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-dbg-info-content/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardList.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardList.py new file mode 100644 index 00000000000..a2fc5598930 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardList.py @@ -0,0 +1,31 @@ +""" +Test std::forward_list functionality with a decl from debug info as content. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestDbgInfoContentForwardList(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (size_t)std::distance(a.begin(), a.end())", substrs=['(size_t) $0 = 3']) + self.expect("expr (int)a.front().a", substrs=['(int) $1 = 3']) + + self.expect("expr (int)(a.begin()->a)", substrs=['(int) $2 = 3']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-dbg-info-content/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-dbg-info-content/main.cpp new file mode 100644 index 00000000000..b1ffc4b24cd --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/forward_list-dbg-info-content/main.cpp @@ -0,0 +1,10 @@ +#include <forward_list> + +struct Foo { + int a; +}; + +int main(int argc, char **argv) { + std::forward_list<Foo> a = {{3}, {1}, {2}}; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-basic/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-basic/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-basic/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-basic/TestBasicList.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-basic/TestBasicList.py new file mode 100644 index 00000000000..154c8ed7bd0 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-basic/TestBasicList.py @@ -0,0 +1,41 @@ +""" +Test basic std::list functionality. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestBasicList(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) + self.expect("expr (int)a.front()", substrs=['(int) $1 = 3']) + self.expect("expr (int)a.back()", substrs=['(int) $2 = 2']) + + self.expect("expr a.sort()") + self.expect("expr (int)a.front()", substrs=['(int) $3 = 1']) + self.expect("expr (int)a.back()", substrs=['(int) $4 = 3']) + + self.expect("expr std::reverse(a.begin(), a.end())") + self.expect("expr (int)a.front()", substrs=['(int) $5 = 3']) + self.expect("expr (int)a.back()", substrs=['(int) $6 = 1']) + + self.expect("expr (int)(*a.begin())", substrs=['(int) $7 = 3']) + self.expect("expr (int)(*a.rbegin())", substrs=['(int) $8 = 1']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-basic/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-basic/main.cpp new file mode 100644 index 00000000000..e54719a02fb --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-basic/main.cpp @@ -0,0 +1,6 @@ +#include <list> + +int main(int argc, char **argv) { + std::list<int> a = {3, 1, 2}; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-dbg-info-content/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-dbg-info-content/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-dbg-info-content/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentList.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentList.py new file mode 100644 index 00000000000..713ec1abb85 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentList.py @@ -0,0 +1,38 @@ +""" +Test basic std::list functionality but with a declaration from +the debug info (the Foo struct) as content. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestDbgInfoContentList(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) + self.expect("expr (int)a.front().a", substrs=['(int) $1 = 3']) + self.expect("expr (int)a.back().a", substrs=['(int) $2 = 2']) + + self.expect("expr std::reverse(a.begin(), a.end())") + self.expect("expr (int)a.front().a", substrs=['(int) $3 = 2']) + self.expect("expr (int)a.back().a", substrs=['(int) $4 = 3']) + + self.expect("expr (int)(a.begin()->a)", substrs=['(int) $5 = 2']) + self.expect("expr (int)(a.rbegin()->a)", substrs=['(int) $6 = 3']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-dbg-info-content/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-dbg-info-content/main.cpp new file mode 100644 index 00000000000..3cfb35f8c6b --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/list-dbg-info-content/main.cpp @@ -0,0 +1,10 @@ +#include <list> + +struct Foo { + int a; +}; + +int main(int argc, char **argv) { + std::list<Foo> a = {{3}, {1}, {2}}; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/no-std-module/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/no-std-module/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/no-std-module/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/no-std-module/TestMissingStdModule.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/no-std-module/TestMissingStdModule.py new file mode 100644 index 00000000000..f4d3d1fd492 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/no-std-module/TestMissingStdModule.py @@ -0,0 +1,40 @@ +""" +Test that importing the std module on a compile unit +that doesn't use the std module will not break LLDB. + +It's not really specified at the moment what kind of +error we should report back to the user in this +situation. Currently Clang will just complain that +the std module doesn't exist or can't be loaded. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class STLTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + # Activate importing of std module. + self.runCmd("settings set target.import-std-module true") + + # Run some commands that should all fail without our std module. + self.expect("expr std::abs(-42)", error=True) + self.expect("expr std::div(2, 1).quot", error=True) + self.expect("expr (std::size_t)33U", error=True) + self.expect("expr char a = 'b'; char b = 'a'; std::swap(a, b); a", + error=True) diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/no-std-module/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/no-std-module/main.cpp new file mode 100644 index 00000000000..c93e9d0ec8a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/no-std-module/main.cpp @@ -0,0 +1,5 @@ +// We don't import any std module here. + +int main(int argc, char **argv) { + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/queue/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/queue/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/queue/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/queue/TestQueue.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/queue/TestQueue.py new file mode 100644 index 00000000000..aad1b11719b --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/queue/TestQueue.py @@ -0,0 +1,47 @@ +""" +Tests std::queue functionality. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestQueue(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + # Test std::queue functionality with a std::deque. + self.expect("expr q_deque.pop()") + self.expect("expr q_deque.push({4})") + self.expect("expr (size_t)q_deque.size()", substrs=['(size_t) $0 = 1']) + self.expect("expr (int)q_deque.front().i", substrs=['(int) $1 = 4']) + self.expect("expr (int)q_deque.back().i", substrs=['(int) $2 = 4']) + self.expect("expr q_deque.empty()", substrs=['(bool) $3 = false']) + self.expect("expr q_deque.pop()") + self.expect("expr q_deque.emplace(5)") + self.expect("expr (int)q_deque.front().i", substrs=['(int) $4 = 5']) + + # Test std::queue functionality with a std::list. + self.expect("expr q_list.pop()") + self.expect("expr q_list.push({4})") + self.expect("expr (size_t)q_list.size()", substrs=['(size_t) $5 = 1']) + self.expect("expr (int)q_list.front().i", substrs=['(int) $6 = 4']) + self.expect("expr (int)q_list.back().i", substrs=['(int) $7 = 4']) + self.expect("expr q_list.empty()", substrs=['(bool) $8 = false']) + self.expect("expr q_list.pop()") + self.expect("expr q_list.emplace(5)") + self.expect("expr (int)q_list.front().i", substrs=['(int) $9 = 5']) diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/queue/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/queue/main.cpp new file mode 100644 index 00000000000..66e8f02c273 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/queue/main.cpp @@ -0,0 +1,16 @@ +#include <deque> +#include <list> +#include <queue> + +struct C { + // Constructor for testing emplace. + C(int i) : i(i) {}; + int i; +}; + +int main(int argc, char **argv) { + // std::deque is the default container. + std::queue<C> q_deque({{1}}); + std::queue<C, std::list<C>> q_list({{1}}); + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr-dbg-info-content/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr-dbg-info-content/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr-dbg-info-content/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContent.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContent.py new file mode 100644 index 00000000000..028798f72f3 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContent.py @@ -0,0 +1,33 @@ +""" +Test std::shared_ptr functionality with a class from debug info as content. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestSharedPtrDbgInfoContent(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (int)s->a", substrs=['(int) $0 = 3']) + self.expect("expr (int)(s->a = 5)", substrs=['(int) $1 = 5']) + self.expect("expr (int)s->a", substrs=['(int) $2 = 5']) + self.expect("expr (bool)s", substrs=['(bool) $3 = true']) + self.expect("expr s.reset()") + self.expect("expr (bool)s", substrs=['(bool) $4 = false']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr-dbg-info-content/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr-dbg-info-content/main.cpp new file mode 100644 index 00000000000..73664f1c83a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr-dbg-info-content/main.cpp @@ -0,0 +1,11 @@ +#include <memory> + +struct Foo { + int a; +}; + +int main(int argc, char **argv) { + std::shared_ptr<Foo> s(new Foo); + s->a = 3; + return s->a; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr/TestSharedPtr.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr/TestSharedPtr.py new file mode 100644 index 00000000000..6f1e7b12d1f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr/TestSharedPtr.py @@ -0,0 +1,33 @@ +""" +Test basic std::shared_ptr functionality. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestSharedPtr(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (int)*s", substrs=['(int) $0 = 3']) + self.expect("expr (int)(*s = 5)", substrs=['(int) $1 = 5']) + self.expect("expr (int)*s", substrs=['(int) $2 = 5']) + self.expect("expr (bool)s", substrs=['(bool) $3 = true']) + self.expect("expr s.reset()") + self.expect("expr (bool)s", substrs=['(bool) $4 = false']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr/main.cpp new file mode 100644 index 00000000000..cb81754087f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/shared_ptr/main.cpp @@ -0,0 +1,7 @@ +#include <memory> + +int main(int argc, char **argv) { + std::shared_ptr<int> s(new int); + *s = 3; + return *s; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/stack/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/stack/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/stack/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/stack/TestStack.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/stack/TestStack.py new file mode 100644 index 00000000000..1c2e5da54ed --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/stack/TestStack.py @@ -0,0 +1,49 @@ +""" +Tests std::stack functionality. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestStack(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + # Test std::stack functionality with a std::deque. + self.expect("expr s_deque.pop()") + self.expect("expr s_deque.push({4})") + self.expect("expr (size_t)s_deque.size()", substrs=['(size_t) $0 = 3']) + self.expect("expr (int)s_deque.top().i", substrs=['(int) $1 = 4']) + self.expect("expr s_deque.emplace(5)") + self.expect("expr (int)s_deque.top().i", substrs=['(int) $2 = 5']) + + # Test std::stack functionality with a std::vector. + self.expect("expr s_vector.pop()") + self.expect("expr s_vector.push({4})") + self.expect("expr (size_t)s_vector.size()", substrs=['(size_t) $3 = 3']) + self.expect("expr (int)s_vector.top().i", substrs=['(int) $4 = 4']) + self.expect("expr s_vector.emplace(5)") + self.expect("expr (int)s_vector.top().i", substrs=['(int) $5 = 5']) + + # Test std::stack functionality with a std::list. + self.expect("expr s_list.pop()") + self.expect("expr s_list.push({4})") + self.expect("expr (size_t)s_list.size()", substrs=['(size_t) $6 = 3']) + self.expect("expr (int)s_list.top().i", substrs=['(int) $7 = 4']) + self.expect("expr s_list.emplace(5)") + self.expect("expr (int)s_list.top().i", substrs=['(int) $8 = 5']) diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/stack/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/stack/main.cpp new file mode 100644 index 00000000000..0ce94990733 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/stack/main.cpp @@ -0,0 +1,17 @@ +#include <list> +#include <stack> +#include <vector> + +struct C { + // Constructor for testing emplace. + C(int i) : i(i) {}; + int i; +}; + +int main(int argc, char **argv) { + // std::deque is the default container. + std::stack<C> s_deque({{1}, {2}, {3}}); + std::stack<C, std::vector<C>> s_vector({{1}, {2}, {3}}); + std::stack<C, std::list<C>> s_list({{1}, {2}, {3}}); + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile new file mode 100644 index 00000000000..e04d73ea487 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile @@ -0,0 +1,10 @@ +LEVEL = ../../../make +# We don't have any standard include directories, so we can't +# parse the test_common.h header we usually inject as it includes +# system headers. +NO_TEST_COMMON_H := 1 + +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXXFLAGS += -I $(SRCDIR)/root/usr/include/c++/include/ -I $(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++ -nostdlib++ +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py new file mode 100644 index 00000000000..dfd90e80e45 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py @@ -0,0 +1,34 @@ +""" +Test that we respect the sysroot when building the std module. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +import os + +class ImportStdModule(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + sysroot = os.path.join(os.getcwd(), "root") + + # Set the sysroot. + self.runCmd("platform select --sysroot '" + sysroot + "' host", CURRENT_EXECUTABLE_SET) + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + # Call our custom function in our sysroot std module. + # If this gives us the correct result, then we used the sysroot. + self.expect("expr std::myabs(-42)", substrs=['(int) $0 = 42']) diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp new file mode 100644 index 00000000000..2fbc76b9a76 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp @@ -0,0 +1,6 @@ +#include <algorithm> + +int main(int argc, char **argv) { + libc_struct s; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/include/algorithm b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/include/algorithm new file mode 100644 index 00000000000..e8cbcca8e84 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/include/algorithm @@ -0,0 +1,7 @@ +#include "libc_header.h" + +namespace std { + int myabs(int i) { + return i < 0 ? -i : i; + } +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/include/module.modulemap b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/include/module.modulemap new file mode 100644 index 00000000000..0eb48492a65 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/include/module.modulemap @@ -0,0 +1,3 @@ +module std { + module "algorithm" { header "algorithm" export * } +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/libc_header.h b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/libc_header.h new file mode 100644 index 00000000000..47525c9db34 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/libc_header.h @@ -0,0 +1 @@ +struct libc_struct {}; diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr-dbg-info-content/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr-dbg-info-content/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr-dbg-info-content/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py new file mode 100644 index 00000000000..c321d8022e1 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py @@ -0,0 +1,33 @@ +""" +Test std::unique_ptr functionality with a decl from debug info as content. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestUniquePtrDbgInfoContent(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (int)s->a", substrs=['(int) $0 = 3']) + self.expect("expr (int)(s->a = 5)", substrs=['(int) $1 = 5']) + self.expect("expr (int)s->a", substrs=['(int) $2 = 5']) + self.expect("expr (bool)s", substrs=['(bool) $3 = true']) + self.expect("expr s.reset()") + self.expect("expr (bool)s", substrs=['(bool) $4 = false']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr-dbg-info-content/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr-dbg-info-content/main.cpp new file mode 100644 index 00000000000..73664f1c83a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr-dbg-info-content/main.cpp @@ -0,0 +1,11 @@ +#include <memory> + +struct Foo { + int a; +}; + +int main(int argc, char **argv) { + std::shared_ptr<Foo> s(new Foo); + s->a = 3; + return s->a; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr/TestUniquePtr.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr/TestUniquePtr.py new file mode 100644 index 00000000000..295ec512327 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr/TestUniquePtr.py @@ -0,0 +1,33 @@ +""" +Test basic std::unique_ptr functionality. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestUniquePtr(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (int)*s", substrs=['(int) $0 = 3']) + self.expect("expr (int)(*s = 5)", substrs=['(int) $1 = 5']) + self.expect("expr (int)*s", substrs=['(int) $2 = 5']) + self.expect("expr (bool)s", substrs=['(bool) $3 = true']) + self.expect("expr s.reset()") + self.expect("expr (bool)s", substrs=['(bool) $4 = false']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr/main.cpp new file mode 100644 index 00000000000..cb81754087f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/unique_ptr/main.cpp @@ -0,0 +1,7 @@ +#include <memory> + +int main(int argc, char **argv) { + std::shared_ptr<int> s(new int); + *s = 3; + return *s; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/TestBasicVector.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/TestBasicVector.py new file mode 100644 index 00000000000..deaf8f0cb75 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/TestBasicVector.py @@ -0,0 +1,57 @@ +""" +Test basic std::vector functionality. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestBasicVector(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) + self.expect("expr (int)a.front()", substrs=['(int) $1 = 3']) + self.expect("expr (int)a[1]", substrs=['(int) $2 = 1']) + self.expect("expr (int)a.back()", substrs=['(int) $3 = 2']) + + self.expect("expr std::sort(a.begin(), a.end())") + self.expect("expr (int)a.front()", substrs=['(int) $4 = 1']) + self.expect("expr (int)a[1]", substrs=['(int) $5 = 2']) + self.expect("expr (int)a.back()", substrs=['(int) $6 = 3']) + + self.expect("expr std::reverse(a.begin(), a.end())") + self.expect("expr (int)a.front()", substrs=['(int) $7 = 3']) + self.expect("expr (int)a[1]", substrs=['(int) $8 = 2']) + self.expect("expr (int)a.back()", substrs=['(int) $9 = 1']) + + self.expect("expr (int)(*a.begin())", substrs=['(int) $10 = 3']) + self.expect("expr (int)(*a.rbegin())", substrs=['(int) $11 = 1']) + + self.expect("expr a.pop_back()") + self.expect("expr (int)a.back()", substrs=['(int) $12 = 2']) + self.expect("expr (size_t)a.size()", substrs=['(size_t) $13 = 2']) + + self.expect("expr (int)a.at(0)", substrs=['(int) $14 = 3']) + + self.expect("expr a.push_back(4)") + self.expect("expr (int)a.back()", substrs=['(int) $15 = 4']) + self.expect("expr (size_t)a.size()", substrs=['(size_t) $16 = 3']) + + self.expect("expr a.emplace_back(5)") + self.expect("expr (int)a.back()", substrs=['(int) $17 = 5']) + self.expect("expr (size_t)a.size()", substrs=['(size_t) $18 = 4']) diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/main.cpp new file mode 100644 index 00000000000..edf130d4748 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/main.cpp @@ -0,0 +1,6 @@ +#include <vector> + +int main(int argc, char **argv) { + std::vector<int> a = {3, 1, 2}; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-bool/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-bool/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-bool/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-bool/TestBoolVector.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-bool/TestBoolVector.py new file mode 100644 index 00000000000..0ab52695faf --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-bool/TestBoolVector.py @@ -0,0 +1,34 @@ +""" +Test basic std::vector<bool> functionality. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestBoolVector(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 4']) + self.expect("expr (bool)a.front()", substrs=['(bool) $1 = false']) + self.expect("expr (bool)a[1]", substrs=['(bool) $2 = true']) + self.expect("expr (bool)a.back()", substrs=['(bool) $3 = true']) + + self.expect("expr (bool)(*a.begin())", substrs=['(bool) $4 = false']) + self.expect("expr (bool)(*a.rbegin())", substrs=['(bool) $5 = true']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-bool/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-bool/main.cpp new file mode 100644 index 00000000000..9554401cf50 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-bool/main.cpp @@ -0,0 +1,6 @@ +#include <vector> + +int main(int argc, char **argv) { + std::vector<bool> a = {0, 1, 0, 1}; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-dbg-info-content/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-dbg-info-content/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-dbg-info-content/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVector.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVector.py new file mode 100644 index 00000000000..c89265f2cd3 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVector.py @@ -0,0 +1,47 @@ +""" +Test basic std::vector functionality but with a declaration from +the debug info (the Foo struct) as content. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestDbgInfoContentVector(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) + self.expect("expr (int)a.front().a", substrs=['(int) $1 = 3']) + self.expect("expr (int)a[1].a", substrs=['(int) $2 = 1']) + self.expect("expr (int)a.back().a", substrs=['(int) $3 = 2']) + + self.expect("expr std::reverse(a.begin(), a.end())") + self.expect("expr (int)a.front().a", substrs=['(int) $4 = 2']) + + self.expect("expr (int)(a.begin()->a)", substrs=['(int) $5 = 2']) + self.expect("expr (int)(a.rbegin()->a)", substrs=['(int) $6 = 3']) + + self.expect("expr a.pop_back()") + self.expect("expr (int)a.back().a", substrs=['(int) $7 = 1']) + self.expect("expr (size_t)a.size()", substrs=['(size_t) $8 = 2']) + + self.expect("expr (int)a.at(0).a", substrs=['(int) $9 = 2']) + + self.expect("expr a.push_back({4})") + self.expect("expr (int)a.back().a", substrs=['(int) $10 = 4']) + self.expect("expr (size_t)a.size()", substrs=['(size_t) $11 = 3']) diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-dbg-info-content/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-dbg-info-content/main.cpp new file mode 100644 index 00000000000..24c3fec75d2 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-dbg-info-content/main.cpp @@ -0,0 +1,10 @@ +#include <vector> + +struct Foo { + int a; +}; + +int main(int argc, char **argv) { + std::vector<Foo> a = {{3}, {1}, {2}}; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-of-vectors/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-of-vectors/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-of-vectors/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectors.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectors.py new file mode 100644 index 00000000000..2b82e1a039a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectors.py @@ -0,0 +1,30 @@ +""" +Test std::vector functionality when it's contents are vectors. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestVectorOfVectors(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 2']) + self.expect("expr (int)a.front().front()", substrs=['(int) $1 = 1']) + self.expect("expr (int)a[1][1]", substrs=['(int) $2 = 2']) + self.expect("expr (int)a.back().at(0)", substrs=['(int) $3 = 3']) diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-of-vectors/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-of-vectors/main.cpp new file mode 100644 index 00000000000..b5ada909e43 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-of-vectors/main.cpp @@ -0,0 +1,6 @@ +#include <vector> + +int main(int argc, char **argv) { + std::vector<std::vector<int> > a = {{1, 2, 3}, {3, 2, 1}}; + return 0; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr-dbg-info-content/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr-dbg-info-content/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr-dbg-info-content/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtr.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtr.py new file mode 100644 index 00000000000..0acd54e803c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtr.py @@ -0,0 +1,33 @@ +""" +Test std::weak_ptr functionality with a decl from debug info as content. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestDbgInfoContentWeakPtr(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (int)w.lock()->a", substrs=['(int) $0 = 3']) + self.expect("expr (int)(w.lock()->a = 5)", substrs=['(int) $1 = 5']) + self.expect("expr (int)w.lock()->a", substrs=['(int) $2 = 5']) + self.expect("expr w.use_count()", substrs=['(long) $3 = 1']) + self.expect("expr w.reset()") + self.expect("expr w.use_count()", substrs=['(long) $4 = 0']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr-dbg-info-content/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr-dbg-info-content/main.cpp new file mode 100644 index 00000000000..d2c5a6258a5 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr-dbg-info-content/main.cpp @@ -0,0 +1,12 @@ +#include <memory> + +struct Foo { + int a; +}; + +int main(int argc, char **argv) { + std::shared_ptr<Foo> s(new Foo); + s->a = 3; + std::weak_ptr<Foo> w = s; + return s->a; // Set break point at this line. +} diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr/Makefile new file mode 100644 index 00000000000..01718d86aa7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make +USE_LIBCPP := 1 +CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS) +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr/TestWeakPtr.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr/TestWeakPtr.py new file mode 100644 index 00000000000..6b8b9ceb7aa --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr/TestWeakPtr.py @@ -0,0 +1,33 @@ +""" +Test basic std::weak_ptr functionality. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestSharedPtr(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # FIXME: This should work on more setups, so remove these + # skipIf's in the future. + @add_test_categories(["libc++"]) + @skipIf(compiler=no_match("clang")) + @skipIf(oslist=no_match(["linux"])) + @skipIf(debug_info=no_match(["dwarf"])) + def test(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + self.runCmd("settings set target.import-std-module true") + + self.expect("expr (int)*w.lock()", substrs=['(int) $0 = 3']) + self.expect("expr (int)(*w.lock() = 5)", substrs=['(int) $1 = 5']) + self.expect("expr (int)*w.lock()", substrs=['(int) $2 = 5']) + self.expect("expr w.use_count()", substrs=['(long) $3 = 1']) + self.expect("expr w.reset()") + self.expect("expr w.use_count()", substrs=['(long) $4 = 0']) + diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr/main.cpp new file mode 100644 index 00000000000..13479eb9496 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/weak_ptr/main.cpp @@ -0,0 +1,8 @@ +#include <memory> + +int main(int argc, char **argv) { + std::shared_ptr<int> s(new int); + *s = 3; + std::weak_ptr<int> w = s; + return *s; // Set break point at this line. +} |