[Lldb-commits] [lldb] r359779 - Add std::stack and std::queue support to CxxModuleHandler

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu May 2 04:25:51 PDT 2019


Author: teemperor
Date: Thu May  2 04:25:50 2019
New Revision: 359779

URL: http://llvm.org/viewvc/llvm-project?rev=359779&view=rev
Log:
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

Added:
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/Makefile
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/TestQueue.py
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/main.cpp
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/Makefile
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/TestStack.py
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/main.cpp
Modified:
    lldb/trunk/source/Symbol/CxxModuleHandler.cpp

Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/Makefile?rev=359779&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/Makefile (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/Makefile Thu May  2 04:25:50 2019
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+USE_LIBCPP := 1
+CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS)
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/TestQueue.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/TestQueue.py?rev=359779&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/TestQueue.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/TestQueue.py Thu May  2 04:25:50 2019
@@ -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'])

Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/main.cpp?rev=359779&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/main.cpp (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/main.cpp Thu May  2 04:25:50 2019
@@ -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.
+}

Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/Makefile?rev=359779&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/Makefile (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/Makefile Thu May  2 04:25:50 2019
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+USE_LIBCPP := 1
+CXXFLAGS += $(MANDATORY_CXXMODULE_BUILD_CFLAGS)
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/TestStack.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/TestStack.py?rev=359779&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/TestStack.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/TestStack.py Thu May  2 04:25:50 2019
@@ -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'])

Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/main.cpp?rev=359779&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/main.cpp (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/main.cpp Thu May  2 04:25:50 2019
@@ -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.
+}

Modified: lldb/trunk/source/Symbol/CxxModuleHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CxxModuleHandler.cpp?rev=359779&r1=359778&r2=359779&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/CxxModuleHandler.cpp (original)
+++ lldb/trunk/source/Symbol/CxxModuleHandler.cpp Thu May  2 04:25:50 2019
@@ -24,6 +24,8 @@ CxxModuleHandler::CxxModuleHandler(ASTIm
       "deque",
       "forward_list",
       "list",
+      "queue",
+      "stack",
       "vector",
       // pointers
       "shared_ptr",




More information about the lldb-commits mailing list