[Lldb-commits] [lldb] r130323 - in /lldb/trunk/test/python_api/lldbutil: TestLLDBIterator.py main.cpp

Johnny Chen johnny.chen at apple.com
Wed Apr 27 12:29:39 PDT 2011


Author: johnny
Date: Wed Apr 27 14:29:39 2011
New Revision: 130323

URL: http://llvm.org/viewvc/llvm-project?rev=130323&view=rev
Log:
Add another test case for lldb_iter(), this time using SBTarget to get at its SBBreakpoint containees.

Modified:
    lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py
    lldb/trunk/test/python_api/lldbutil/main.cpp

Modified: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py?rev=130323&r1=130322&r2=130323&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original)
+++ lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Wed Apr 27 14:29:39 2011
@@ -16,21 +16,27 @@
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
-        # Find the line number to break inside main().
-        self.line = line_number('main.cpp', '// Set break point at this line.')
+        # Find the line numbers to break inside main().
+        self.line1 = line_number('main.cpp', '// Set break point at this line.')
+        self.line2 = line_number('main.cpp', '// And that line.')
 
-    def test_lldb_iter(self):
-        """Test lldb_iter works correctly."""
+    def test_lldb_iter_1(self):
+        """Test lldb_iter works correctly for SBTarget -> SBModule."""
         self.buildDefault()
-        self.lldb_iter_test()
+        self.lldb_iter_1()
 
-    def lldb_iter_test(self):
+    def test_lldb_iter_2(self):
+        """Test lldb_iter works correctly for SBTarget -> SBBreakpoint."""
+        self.buildDefault()
+        self.lldb_iter_2()
+
+    def lldb_iter_1(self):
         exe = os.path.join(os.getcwd(), "a.out")
 
         target = self.dbg.CreateTarget(exe)
         self.assertTrue(target.IsValid(), VALID_TARGET)
 
-        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
+        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1)
         self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
 
         # Now launch the process, and do not stop at entry point.
@@ -56,6 +62,35 @@
             self.assertTrue(yours[i].GetUUIDString() == mine[i].GetUUIDString(),
                             "UUID of yours[%d] and mine[%d] matches" % (i, i))
 
+    def lldb_iter_2(self):
+        exe = os.path.join(os.getcwd(), "a.out")
+
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target.IsValid(), VALID_TARGET)
+
+        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1)
+        self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line2)
+        self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+
+        self.assertTrue(target.GetNumBreakpoints() == 2)
+
+        from lldbutil import lldb_iter, get_description
+        yours = []
+        for i in range(target.GetNumBreakpoints()):
+            yours.append(target.GetBreakpointAtIndex(i))
+        mine = []
+        for m in lldb_iter(target, 'GetNumBreakpoints', 'GetBreakpointAtIndex'):
+            mine.append(m)
+
+        self.assertTrue(len(yours) == len(mine))
+        for i in range(len(yours)):
+            if self.TraceOn():
+                print "yours[%d]='%s'" % (i, get_description(yours[i]))
+                print "mine[%d]='%s'" % (i, get_description(mine[i]))
+            self.assertTrue(yours[i].GetID() == mine[i].GetID(),
+                            "ID of yours[%d] and mine[%d] matches" % (i, i))
+
 
 if __name__ == '__main__':
     import atexit

Modified: lldb/trunk/test/python_api/lldbutil/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/main.cpp?rev=130323&r1=130322&r2=130323&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/main.cpp (original)
+++ lldb/trunk/test/python_api/lldbutil/main.cpp Wed Apr 27 14:29:39 2011
@@ -82,7 +82,7 @@
     uint32_t thread_mask_3 = (1u << thread_index_3);
 
     // Make a mask that will keep all threads alive
-    mask_access (eAssign, thread_mask_1 | thread_mask_2 | thread_mask_3);
+    mask_access (eAssign, thread_mask_1 | thread_mask_2 | thread_mask_3); // And that line.
 
     // Create 3 threads
     err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1);





More information about the lldb-commits mailing list