summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-05-02 11:25:50 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-05-02 11:25:50 +0000
commit9a0acdf65e7fc390c7a9b085f7aa89bd8baaf0ee (patch)
tree5de35547352dcb9ad435f563587306e93e863e38 /lldb/packages/Python/lldbsuite/test
parent929f639eb81bbb079c9b768a7f2b95f0262362c1 (diff)
downloadbcm5719-llvm-9a0acdf65e7fc390c7a9b085f7aa89bd8baaf0ee.tar.gz
bcm5719-llvm-9a0acdf65e7fc390c7a9b085f7aa89bd8baaf0ee.zip
Add std::stack and std::queue support to CxxModuleHandler
Reviewers: aprantl, shafik Reviewed By: aprantl, shafik Subscribers: lldb-commits Tags: #c_modules_in_lldb, #lldb Differential Revision: https://reviews.llvm.org/D61305 llvm-svn: 359779
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/Makefile5
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/TestQueue.py47
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/main.cpp16
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/Makefile5
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/TestStack.py49
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/main.cpp17
6 files changed, 139 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/Makefile b/lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/Makefile
new file mode 100644
index 00000000000..01718d86aa7
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/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/expression_command/import-std-module/queue/TestQueue.py b/lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/TestQueue.py
new file mode 100644
index 00000000000..aad1b11719b
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/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/expression_command/import-std-module/queue/main.cpp b/lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/main.cpp
new file mode 100644
index 00000000000..66e8f02c273
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/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/expression_command/import-std-module/stack/Makefile b/lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/Makefile
new file mode 100644
index 00000000000..01718d86aa7
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/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/expression_command/import-std-module/stack/TestStack.py b/lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/TestStack.py
new file mode 100644
index 00000000000..1c2e5da54ed
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/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/expression_command/import-std-module/stack/main.cpp b/lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/main.cpp
new file mode 100644
index 00000000000..0ce94990733
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/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.
+}
OpenPOWER on IntegriCloud