Add libc++ category to the remaining libc++ data formatters
authorPavel Labath <labath@google.com>
Wed, 12 Apr 2017 12:32:58 +0000 (12:32 +0000)
committerPavel Labath <labath@google.com>
Wed, 12 Apr 2017 12:32:58 +0000 (12:32 +0000)
llvm-svn: 300054

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

index 6a832e0..63eb5e0 100644 (file)
@@ -23,8 +23,7 @@ class LibCxxFunctionTestCase(TestBase):
         var.SetPreferSyntheticValue(True)
         return var
 
-    @skipIf(compiler="gcc")
-    @skipIfWindows  # libc++ not ported to Windows yet
+    @add_test_categories(["libc++"])
     def test(self):
         """Test that std::function as defined by libc++ is correctly printed by LLDB"""
         self.build()
@@ -36,9 +35,6 @@ class LibCxxFunctionTestCase(TestBase):
 
         self.runCmd("run", RUN_SUCCEEDED)
 
-        lldbutil.skip_if_library_missing(
-            self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
         # The stop reason of the thread should be breakpoint.
         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
                     substrs=['stopped',
index 5d23fce..9b4308f 100644 (file)
@@ -22,9 +22,10 @@ class LibcxxIteratorDataFormatterTestCase(TestBase):
         TestBase.setUp(self)
         # Find the line number to break at.
         self.line = line_number('main.cpp', '// Set break point at this line.')
+        ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+        self.namespace = 'std::__' + ns + '1'
 
-    @skipIf(compiler="gcc")
-    @skipIfWindows  # libc++ not ported to Windows yet
+    @add_test_categories(["libc++"])
     def test_with_run_command(self):
         """Test that libc++ iterators format properly."""
         self.build()
@@ -35,9 +36,6 @@ class LibcxxIteratorDataFormatterTestCase(TestBase):
 
         self.runCmd("run", RUN_SUCCEEDED)
 
-        lldbutil.skip_if_library_missing(
-            self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
         # The stop reason of the thread should be breakpoint.
         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
                     substrs=['stopped',
@@ -57,8 +55,6 @@ class LibcxxIteratorDataFormatterTestCase(TestBase):
         # Execute the cleanup function during test case tear down.
         self.addTearDownHook(cleanup)
 
-        self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
         self.expect('frame variable ivI', substrs=['item = 3'])
         self.expect('expr ivI', substrs=['item = 3'])
 
index e2e082c..e1ebbd5 100644 (file)
@@ -19,9 +19,8 @@ class LibcxxListDataFormatterTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    @skipIf(compiler="gcc")
-    @skipIfWindows  # libc++ not ported to Windows yet
-    @add_test_categories(["pyapi"])
+    @add_test_categories(["libc++"])
+    @expectedFailureAndroid(bugnumber="llvm.org/pr32592")
     @skipIfDarwin  # rdar://25499635
     def test_with_run_command(self):
         self.build()
@@ -40,8 +39,6 @@ class LibcxxListDataFormatterTestCase(TestBase):
         # Run the program, it should stop at breakpoint 1.
         process = target.LaunchSimple(
             None, None, self.get_process_working_directory())
-        lldbutil.skip_if_library_missing(
-            self, target, lldbutil.PrintableRegex("libc\+\+"))
         self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
         self.assertEqual(
             len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1)
index 7433a0b..fc4714e 100644 (file)
@@ -17,8 +17,12 @@ class LibcxxMapDataFormatterTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    @skipIf(compiler="gcc")
-    @skipIfWindows  # libc++ not ported to Windows yet
+    def setUp(self):
+        TestBase.setUp(self)
+        ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+        self.namespace = 'std::__' + ns + '1'
+
+    @add_test_categories(["libc++"])
     def test_with_run_command(self):
         """Test that that file and class static variables display correctly."""
         self.build()
@@ -30,9 +34,6 @@ class LibcxxMapDataFormatterTestCase(TestBase):
 
         self.runCmd("run", RUN_SUCCEEDED)
 
-        lldbutil.skip_if_library_missing(
-            self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
         # The stop reason of the thread should be breakpoint.
         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
                     substrs=['stopped',
@@ -52,16 +53,16 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         # Execute the cleanup function during test case tear down.
         self.addTearDownHook(cleanup)
 
-        self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
+        ns = self.namespace
         self.expect('frame variable ii',
-                    substrs=['size=0',
+                    substrs=['%s::map' % ns,
+                             'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable ii',
-                    substrs=['size=2',
+                    substrs=['%s::map' % ns, 'size=2',
                              '[0] = ',
                              'first = 0',
                              'second = 0',
@@ -72,7 +73,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable ii',
-                    substrs=['size=4',
+                    substrs=['%s::map' % ns, 'size=4',
                              '[2] = ',
                              'first = 2',
                              'second = 0',
@@ -83,7 +84,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect("frame variable ii",
-                    substrs=['size=8',
+                    substrs=['%s::map' % ns, 'size=8',
                              '[5] = ',
                              'first = 5',
                              'second = 0',
@@ -92,7 +93,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
                              'second = 1'])
 
         self.expect("p ii",
-                    substrs=['size=8',
+                    substrs=['%s::map' % ns, 'size=8',
                              '[5] = ',
                              'first = 5',
                              'second = 0',
@@ -124,17 +125,17 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         self.runCmd("continue")
 
         self.expect('frame variable ii',
-                    substrs=['size=0',
+                    substrs=['%s::map' % ns, 'size=0',
                              '{}'])
 
         self.expect('frame variable si',
-                    substrs=['size=0',
+                    substrs=['%s::map' % ns, 'size=0',
                              '{}'])
 
         self.runCmd("continue")
 
         self.expect('frame variable si',
-                    substrs=['size=1',
+                    substrs=['%s::map' % ns, 'size=1',
                              '[0] = ',
                              'first = \"zero\"',
                              'second = 0'])
@@ -142,7 +143,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect("frame variable si",
-                    substrs=['size=4',
+                    substrs=['%s::map' % ns, 'size=4',
                              '[0] = ',
                              'first = \"zero\"',
                              'second = 0',
@@ -157,7 +158,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
                              'second = 3'])
 
         self.expect("p si",
-                    substrs=['size=4',
+                    substrs=['%s::map' % ns, 'size=4',
                              '[0] = ',
                              'first = \"zero\"',
                              'second = 0',
@@ -192,19 +193,19 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable si',
-                    substrs=['size=0',
+                    substrs=['%s::map' % ns, 'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable is',
-                    substrs=['size=0',
+                    substrs=['%s::map' % ns, 'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect("frame variable is",
-                    substrs=['size=4',
+                    substrs=['%s::map' % ns, 'size=4',
                              '[0] = ',
                              'second = \"goofy\"',
                              'first = 85',
@@ -219,7 +220,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
                              'first = 3'])
 
         self.expect("p is",
-                    substrs=['size=4',
+                    substrs=['%s::map' % ns, 'size=4',
                              '[0] = ',
                              'second = \"goofy\"',
                              'first = 85',
@@ -254,19 +255,19 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable is',
-                    substrs=['size=0',
+                    substrs=['%s::map' % ns, 'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable ss',
-                    substrs=['size=0',
+                    substrs=['%s::map' % ns, 'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect("frame variable ss",
-                    substrs=['size=3',
+                    substrs=['%s::map' % ns, 'size=3',
                              '[0] = ',
                              'second = \"hello\"',
                              'first = \"ciao\"',
@@ -278,7 +279,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
                              'first = \"gatto\"'])
 
         self.expect("p ss",
-                    substrs=['size=3',
+                    substrs=['%s::map' % ns, 'size=3',
                              '[0] = ',
                              'second = \"hello\"',
                              'first = \"ciao\"',
@@ -309,5 +310,5 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable ss',
-                    substrs=['size=0',
+                    substrs=['%s::map' % ns, 'size=0',
                              '{}'])
index 66091e6..b28a7e6 100644 (file)
@@ -18,8 +18,12 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    @skipIfWindows  # libc++ not ported to Windows yet
-    @skipIf(compiler="gcc")
+    def setUp(self):
+        TestBase.setUp(self)
+        ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+        self.namespace = 'std::__' + ns + '1'
+
+    @add_test_categories(["libc++"])
     def test_with_run_command(self):
         """Test that that file and class static variables display correctly."""
         self.build()
@@ -31,9 +35,6 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
 
         self.runCmd("run", RUN_SUCCEEDED)
 
-        lldbutil.skip_if_library_missing(
-            self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
         # The stop reason of the thread should be breakpoint.
         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
                     substrs=['stopped',
@@ -53,16 +54,15 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
         # Execute the cleanup function during test case tear down.
         self.addTearDownHook(cleanup)
 
-        self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
+        multimap = self.namespace + "::multimap"
         self.expect('frame variable ii',
-                    substrs=['size=0',
+                    substrs=[multimap, 'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable ii',
-                    substrs=['size=2',
+                    substrs=[multimap, 'size=2',
                              '[0] = ',
                              'first = 0',
                              'second = 0',
@@ -73,7 +73,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable ii',
-                    substrs=['size=4',
+                    substrs=[multimap, 'size=4',
                              '[2] = ',
                              'first = 2',
                              'second = 0',
@@ -84,7 +84,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect("frame variable ii",
-                    substrs=['size=8',
+                    substrs=[multimap, 'size=8',
                              '[5] = ',
                              'first = 5',
                              'second = 0',
@@ -93,7 +93,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
                              'second = 1'])
 
         self.expect("p ii",
-                    substrs=['size=8',
+                    substrs=[multimap, 'size=8',
                              '[5] = ',
                              'first = 5',
                              'second = 0',
@@ -125,17 +125,17 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable ii',
-                    substrs=['size=0',
+                    substrs=[multimap, 'size=0',
                              '{}'])
 
         self.expect('frame variable si',
-                    substrs=['size=0',
+                    substrs=[multimap, 'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable si',
-                    substrs=['size=1',
+                    substrs=[multimap, 'size=1',
                              '[0] = ',
                              'first = \"zero\"',
                              'second = 0'])
@@ -143,7 +143,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect("frame variable si",
-                    substrs=['size=4',
+                    substrs=[multimap, 'size=4',
                              '[0] = ',
                              'first = \"zero\"',
                              'second = 0',
@@ -158,7 +158,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
                              'second = 3'])
 
         self.expect("p si",
-                    substrs=['size=4',
+                    substrs=[multimap, 'size=4',
                              '[0] = ',
                              'first = \"zero\"',
                              'second = 0',
@@ -193,19 +193,19 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable si',
-                    substrs=['size=0',
+                    substrs=[multimap, 'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable is',
-                    substrs=['size=0',
+                    substrs=[multimap, 'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect("frame variable is",
-                    substrs=['size=4',
+                    substrs=[multimap, 'size=4',
                              '[0] = ',
                              'second = \"goofy\"',
                              'first = 85',
@@ -220,7 +220,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
                              'first = 3'])
 
         self.expect("p is",
-                    substrs=['size=4',
+                    substrs=[multimap, 'size=4',
                              '[0] = ',
                              'second = \"goofy\"',
                              'first = 85',
@@ -255,19 +255,19 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable is',
-                    substrs=['size=0',
+                    substrs=[multimap, 'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable ss',
-                    substrs=['size=0',
+                    substrs=[multimap, 'size=0',
                              '{}'])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect("frame variable ss",
-                    substrs=['size=3',
+                    substrs=[multimap, 'size=3',
                              '[0] = ',
                              'second = \"hello\"',
                              'first = \"ciao\"',
@@ -279,7 +279,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
                              'first = \"gatto\"'])
 
         self.expect("p ss",
-                    substrs=['size=3',
+                    substrs=[multimap, 'size=3',
                              '[0] = ',
                              'second = \"hello\"',
                              'first = \"ciao\"',
@@ -310,5 +310,5 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect('frame variable ss',
-                    substrs=['size=0',
+                    substrs=[multimap, 'size=0',
                              '{}'])
index d40bce8..2f448e8 100644 (file)
@@ -17,8 +17,17 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    @skipIf(compiler="gcc")
-    @skipIfWindows  # libc++ not ported to Windows yet
+    def setUp(self):
+        TestBase.setUp(self)
+        ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+        self.namespace = 'std::__' + ns + '1'
+
+    def getVariableType(self, name):
+        var = self.frame().FindVariable(name)
+        self.assertTrue(var.IsValid())
+        return var.GetType().GetCanonicalType().GetName()
+
+    @add_test_categories(["libc++"])
     def test_with_run_command(self):
         """Test that that file and class static variables display correctly."""
         self.build()
@@ -30,9 +39,6 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
 
         self.runCmd("run", RUN_SUCCEEDED)
 
-        lldbutil.skip_if_library_missing(
-            self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
         # The stop reason of the thread should be breakpoint.
         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
                     substrs=['stopped',
@@ -52,7 +58,9 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
         # Execute the cleanup function during test case tear down.
         self.addTearDownHook(cleanup)
 
-        self.expect('image list', substrs=self.getLibcPlusPlusLibs())
+        ii_type = self.getVariableType("ii")
+        self.assertTrue(ii_type.startswith(self.namespace + "::multiset"),
+                        "Type: " + ii_type)
 
         self.expect("frame variable ii", substrs=["size=0", "{}"])
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
@@ -86,6 +94,9 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
         self.expect("frame variable ii", substrs=["size=0", "{}"])
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
         self.expect("frame variable ii", substrs=["size=0", "{}"])
+        ss_type = self.getVariableType("ss")
+        self.assertTrue(ss_type.startswith(self.namespace + "::multiset"),
+                        "Type: " + ss_type)
         self.expect("frame variable ss", substrs=["size=0", "{}"])
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
         self.expect(
index 2577000..fe42a5e 100644 (file)
@@ -707,7 +707,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   AddCXXSynthetic(
       cpp_category_sp, lldb_private::formatters::LibcxxFunctionFrontEndCreator,
       "std::function synthetic value provider",
-      ConstString("^std::__1::function<.+>$"), stl_synth_flags, true);
+      ConstString("^std::__(ndk)?1::function<.+>$"), stl_synth_flags, true);
 #endif
 }