danilashtefan updated this revision to Diff 387084.
danilashtefan added a comment.
Some naming corrections
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113760/new/
https://reviews.llvm.org/D113760
Files:
lldb/examples/synthetic/gnu_libstdcpp.py
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/Makefile
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp
@@ -0,0 +1,78 @@
+#include
+#include
+#include
+
+using std::string;
+
+#define intstr_map std::unordered_map
+#define intstr_mmap std::unordered_multimap
+
+#define int_set std::unordered_set
+#define str_set std::unordered_set
+#define int_mset std::unordered_multiset
+#define str_mset std::unordered_multiset
+
+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() {
+ intstr_map map;
+ map.emplace(1, "hello");
+ map.emplace(2, "world");
+ map.emplace(3, "this");
+ map.emplace(4, "is");
+ map.emplace(5, "me");
+ thefoo_rw(); // Set break point at this line.
+
+ intstr_mmap mmap;
+ mmap.emplace(1, "hello");
+ mmap.emplace(2, "hello");
+ mmap.emplace(2, "world");
+ mmap.emplace(3, "this");
+ mmap.emplace(3, "this");
+ mmap.emplace(3, "this");
+ thefoo_rw(); // Set break point at this line.
+
+ int_set iset;
+ iset.emplace(1);
+ iset.emplace(2);
+ iset.emplace(3);
+ iset.emplace(4);
+ iset.emplace(5);
+ thefoo_rw(); // Set break point at this line.
+
+ str_set sset;
+ sset.emplace("hello");
+ sset.emplace("world");
+ sset.emplace("this");
+ sset.emplace("is");
+ sset.emplace("me");
+ thefoo_rw(); // Set break point at this line.
+
+ int_mset imset;
+ imset.emplace(1);
+ imset.emplace(2);
+ imset.emplace(2);
+ imset.emplace(3);
+ imset.emplace(3);
+ imset.emplace(3);
+ thefoo_rw(); // Set break point at this line.
+
+ str_mset smset;
+ smset.emplace("hello");
+ smset.emplace("world");
+ smset.emplace("world");
+ smset.emplace("is");
+ smset.emplace("is");
+ thefoo_rw(); // Set break point at this line.
+
+ return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -0,0 +1,78 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class GenericUnorderedDataFormatterTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.namespace = 'std'
+
+@add_test_categories(["libstdcxx"])
+def test_with_run_command(self):
+self.build()
+self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_source_regexp(
+self, "Set break point at this line.")
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# The stop reason of the thread should be breakpoint.
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+# This is the function to remove the custom formats in order to have a
+# clean slate for the next test case.
+def cleanup():
+self.runCmd('type format clear', check=False)
+self.runCmd('type summary clear', check=False)
+self.runCmd('type filter clear', check=False)
+self.runCmd('type synth clear', check=False)
+self.runCmd(
+"settings set target.max-children-count 256",
+check=False)
+
+# Execute the cleanup function during test case tear down.
+self.addTearDownHook(cleanup)
+
+ns = self.namespace
+self.look_for_content_and_continue(
+"map", ['%s::unordered_map' %
+ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+
+self.look_for_content_and_continue(
+"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"',
+ 'first = 2', 'second = "hello"'])
+
+self.look_for_content_and_conti