[Lldb-commits] [lldb] r205450 - rdar://16424649

Enrico Granata egranata at apple.com
Wed Apr 2 11:55:30 PDT 2014


Author: enrico
Date: Wed Apr  2 13:55:29 2014
New Revision: 205450

URL: http://llvm.org/viewvc/llvm-project?rev=205450&view=rev
Log:
rdar://16424649

Clean up the DynamicValueTestCase

Namely, I split off the part of the test that validates child counts to a separate test


Added:
    lldb/trunk/test/functionalities/dynamic_value_child_count/
    lldb/trunk/test/functionalities/dynamic_value_child_count/Makefile
    lldb/trunk/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py
    lldb/trunk/test/functionalities/dynamic_value_child_count/pass-to-base.cpp
Modified:
    lldb/trunk/test/lang/cpp/dynamic-value/TestDynamicValue.py
    lldb/trunk/test/lang/cpp/dynamic-value/pass-to-base.cpp

Added: lldb/trunk/test/functionalities/dynamic_value_child_count/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/dynamic_value_child_count/Makefile?rev=205450&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/dynamic_value_child_count/Makefile (added)
+++ lldb/trunk/test/functionalities/dynamic_value_child_count/Makefile Wed Apr  2 13:55:29 2014
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := pass-to-base.cpp
+
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py?rev=205450&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py (added)
+++ lldb/trunk/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py Wed Apr  2 13:55:29 2014
@@ -0,0 +1,94 @@
+"""
+Test that dynamic values update their child count correctly
+"""
+
+import os, time
+import re
+import unittest2
+import lldb, lldbutil
+from lldbtest import *
+
+class DynamicValueChildCountTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    @python_api_test
+    @dsym_test
+    @expectedFailurei386("to be figured out")
+    def test_get_dynamic_vals_with_dsym(self):
+        """Test fetching C++ dynamic values from pointers & references."""
+        self.buildDsym(dictionary=self.getBuildFlags())
+        self.do_get_dynamic_vals()
+
+    @expectedFailureLinux # FIXME: This needs to be root-caused.  It looks like the DWARF info is anticipating the derived class assignment.
+    @python_api_test
+    @dwarf_test
+    @expectedFailurei386("to be figured out")
+    def test_get_dynamic_vals_with_dwarf(self):
+        """Test fetching C++ dynamic values from pointers & references."""
+        self.buildDwarf(dictionary=self.getBuildFlags())
+        self.do_get_dynamic_vals()
+
+    def setUp(self):
+        # Call super's setUp().                                                                                                           
+        TestBase.setUp(self)
+
+        # Find the line number to break for main.c.                                                                                       
+
+        self.main_third_call_line = line_number('pass-to-base.cpp',
+                                                       '// Break here and check b has 0 children')
+        self.main_fourth_call_line = line_number('pass-to-base.cpp',
+                                                       '// Break here and check b still has 0 children')
+        self.main_fifth_call_line = line_number('pass-to-base.cpp',
+                                                       '// Break here and check b has one child now')
+        self.main_sixth_call_line = line_number('pass-to-base.cpp',
+                                                       '// Break here and check b has 0 children again')
+
+
+
+
+    def do_get_dynamic_vals(self):
+        """Get argument vals for the call stack when stopped on a breakpoint."""
+        exe = os.path.join(os.getcwd(), "a.out")
+
+        # Create a target from the debugger.
+
+        target = self.dbg.CreateTarget (exe)
+        self.assertTrue(target, VALID_TARGET)
+
+        # Set up our breakpoints:
+
+        third_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_third_call_line)
+        self.assertTrue(third_call_bpt,
+                        VALID_BREAKPOINT)
+        fourth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_fourth_call_line)
+        self.assertTrue(fourth_call_bpt,
+                        VALID_BREAKPOINT)
+        fifth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_fifth_call_line)
+        self.assertTrue(fifth_call_bpt,
+                        VALID_BREAKPOINT)
+        sixth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_sixth_call_line)
+        self.assertTrue(sixth_call_bpt,
+                        VALID_BREAKPOINT)
+
+        # Now launch the process, and do not stop at the entry point.
+        process = target.LaunchSimple (None, None, self.get_process_working_directory())
+
+        self.assertTrue(process.GetState() == lldb.eStateStopped,
+                        PROCESS_STOPPED)
+
+        b = self.frame().FindVariable("b").GetDynamicValue(lldb.eDynamicCanRunTarget)
+        self.assertTrue(b.GetNumChildren() == 0, "b has 0 children")
+        self.runCmd("continue")
+        self.assertTrue(b.GetNumChildren() == 0, "b still has 0 children")
+        self.runCmd("continue")
+        self.assertTrue(b.GetNumChildren() != 0, "b now has 1 child")
+        self.runCmd("continue")
+        self.assertTrue(b.GetNumChildren() == 0, "b didn't go back to 0 children")
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Added: lldb/trunk/test/functionalities/dynamic_value_child_count/pass-to-base.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/dynamic_value_child_count/pass-to-base.cpp?rev=205450&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/dynamic_value_child_count/pass-to-base.cpp (added)
+++ lldb/trunk/test/functionalities/dynamic_value_child_count/pass-to-base.cpp Wed Apr  2 13:55:29 2014
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <memory>
+
+class BaseClass
+{
+public:
+    BaseClass();
+    virtual ~BaseClass() { }
+};
+
+class DerivedClass : public BaseClass
+{
+public:
+    DerivedClass();
+    virtual ~DerivedClass() { }
+protected:
+    int mem;
+};
+
+BaseClass::BaseClass()
+{
+}
+
+DerivedClass::DerivedClass() : BaseClass()
+{
+    mem = 101;
+}
+
+int
+main (int argc, char **argv)
+{
+  BaseClass *b = nullptr; // Break here and check b has 0 children
+  b = new DerivedClass();  // Break here and check b still has 0 children
+  b = nullptr;  // Break here and check b has one child now
+  return 0; // Break here and check b has 0 children again
+}

Modified: lldb/trunk/test/lang/cpp/dynamic-value/TestDynamicValue.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/dynamic-value/TestDynamicValue.py?rev=205450&r1=205449&r2=205450&view=diff
==============================================================================
--- lldb/trunk/test/lang/cpp/dynamic-value/TestDynamicValue.py (original)
+++ lldb/trunk/test/lang/cpp/dynamic-value/TestDynamicValue.py Wed Apr  2 13:55:29 2014
@@ -40,15 +40,6 @@ class DynamicValueTestCase(TestBase):
         self.main_second_call_line = line_number('pass-to-base.cpp',
                                                        '// Break here and get real address of reallyA.')
 
-        self.main_third_call_line = line_number('pass-to-base.cpp',
-                                                       '// Break here and check b has 0 children')
-        self.main_fourth_call_line = line_number('pass-to-base.cpp',
-                                                       '// Break here and check b still has 0 children')
-        self.main_fifth_call_line = line_number('pass-to-base.cpp',
-                                                       '// Break here and check b has one child now')
-
-
-
 
     def examine_value_object_of_this_ptr (self, this_static, this_dynamic, dynamic_location):
 
@@ -129,15 +120,6 @@ class DynamicValueTestCase(TestBase):
         second_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_second_call_line)
         self.assertTrue(second_call_bpt,
                         VALID_BREAKPOINT)
-        third_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_third_call_line)
-        self.assertTrue(third_call_bpt,
-                        VALID_BREAKPOINT)
-        fourth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_fourth_call_line)
-        self.assertTrue(fourth_call_bpt,
-                        VALID_BREAKPOINT)
-        fifth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_fifth_call_line)
-        self.assertTrue(fifth_call_bpt,
-                        VALID_BREAKPOINT)
 
         # Now launch the process, and do not stop at the entry point.
         process = target.LaunchSimple (None, None, self.get_process_working_directory())
@@ -251,20 +233,6 @@ class DynamicValueTestCase(TestBase):
         self.assertTrue (anotherA_loc == reallyA_loc)
         self.assertTrue (anotherA_value.GetTypeName().find ('B') == -1)
 
-        self.runCmd("continue")
-#        self.runCmd("frame select 0")
-#        self.runCmd("frame variable")
-        b = self.frame().FindVariable("b").GetDynamicValue(lldb.eDynamicCanRunTarget)
-        self.assertTrue(b.GetNumChildren() == 0, "b has 0 children")
-        self.runCmd("continue")
-#        self.runCmd("frame select 0")
-#        self.runCmd("frame variable")
-        self.assertTrue(b.GetNumChildren() == 0, "b still has 0 children")
-        self.runCmd("continue")
-#        self.runCmd("frame select 0")
-#        self.runCmd("frame variable")
-        self.assertTrue(b.GetNumChildren() != 0, "b now has 1 child")
-
 if __name__ == '__main__':
     import atexit
     lldb.SBDebugger.Initialize()

Modified: lldb/trunk/test/lang/cpp/dynamic-value/pass-to-base.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/dynamic-value/pass-to-base.cpp?rev=205450&r1=205449&r2=205450&view=diff
==============================================================================
--- lldb/trunk/test/lang/cpp/dynamic-value/pass-to-base.cpp (original)
+++ lldb/trunk/test/lang/cpp/dynamic-value/pass-to-base.cpp Wed Apr  2 13:55:29 2014
@@ -52,31 +52,6 @@ private:
 
 static A* my_global_A_ptr;
 
-class BaseClass
-{
-public:
-    BaseClass();
-    virtual ~BaseClass() { }
-};
-
-class DerivedClass : public BaseClass
-{
-public:
-    DerivedClass();
-    virtual ~DerivedClass() { }
-protected:
-    int mem;
-};
-
-BaseClass::BaseClass()
-{
-}
-
-DerivedClass::DerivedClass() : BaseClass()
-{
-    mem = 101;
-}
-
 int
 main (int argc, char **argv)
 {
@@ -90,8 +65,5 @@ main (int argc, char **argv)
   A reallyA (500);
   myB.doSomething (reallyA);  // Break here and get real address of reallyA.
 
-  BaseClass *b = nullptr; // Break here and check b has 0 children
-  b = new DerivedClass();  // Break here and check b still has 0 children
-  b = nullptr;  // Break here and check b has one child now
   return 0;
 }





More information about the lldb-commits mailing list