[Lldb-commits] [lldb] r136123 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/value/linked_list/TestValueAPILinkedList.py

Johnny Chen johnny.chen at apple.com
Tue Jul 26 13:20:13 PDT 2011


Author: johnny
Date: Tue Jul 26 15:20:13 2011
New Revision: 136123

URL: http://llvm.org/viewvc/llvm-project?rev=136123&view=rev
Log:
The test function to determine whether we have reached the end of the list was
too complex in the test case.  We can just simply test that the SBValue object
is a valid object and it does not correspond to a null pointer in order to say
that EOL has not been reached.

Modify the test case and the lldb.py docstring to have a more compact test
function.

Modified:
    lldb/trunk/scripts/Python/modify-python-lldb.py
    lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py

Modified: lldb/trunk/scripts/Python/modify-python-lldb.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=136123&r1=136122&r2=136123&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/modify-python-lldb.py (original)
+++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue Jul 26 15:20:13 2011
@@ -103,22 +103,15 @@
 
         For example,
 
-        # Test function to determine end of list.
         def eol(val):
-            if not val:
+            \'\'\'Test function to determine end of list.\'\'\'
+            # End of list is reached if either the value object is invalid
+            # or it corresponds to a null pointer.
+            if not val or int(val.GetValue(), 16) == 0:
                 return True
-            try:
-                # Test the semantics of the item we got.
-                id = val.GetChildMemberWithName("id")
-                if int(id.GetValue()) > 0:
-                    return False
-            except:
-                pass
-
-            # If we fall through to here.  It could be that exception
-            # occurred or the "id" child member does not qualify as a
-            # valid item. Return True for EOL.
-            return True
+
+            # Otherwise, return False.
+            return False
 
         # Get Frame #0.
         ...

Modified: lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py?rev=136123&r1=136122&r2=136123&view=diff
==============================================================================
--- lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py (original)
+++ lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Tue Jul 26 15:20:13 2011
@@ -55,22 +55,14 @@
         self.assertTrue(process, PROCESS_IS_VALID)
 
         def eol(val):
-            """Test to determine end of list."""
-            if not val:
+            """Test function to determine end of list."""
+            # End of list is reached if either the value object is invalid
+            # or it corresponds to a null pointer.
+            if not val or int(val.GetValue(), 16) == 0:
                 return True
-            try:
-                id = val.GetChildMemberWithName("id")
-                if int(id.GetValue()) > 0:
-                    return False
-            except:
-                #exc_type, exc_value, exc_tb = sys.exc_info()
-                #traceback.print_exception(exc_type, exc_value, exc_tb)
-                pass
-
-            # If we fall through to here.  It could be that exception
-            # occurred or the "id" child member does not qualify as a
-            # valid item. Return True for EOL.
-            return True
+
+            # Otherwise, return False.
+            return False
 
         # Get Frame #0.
         self.assertTrue(process.GetState() == lldb.eStateStopped)
@@ -90,12 +82,15 @@
         cvf = lldbutil.ChildVisitingFormatter(indent_child=2)
         for t in task_head.linked_list_iter('next', eol):
             self.assertTrue(t, VALID_VARIABLE)
-            list.append(int(t.GetChildMemberWithName("id").GetValue()))
+            # Make sure that 'next' corresponds to an SBValue with pointer type.
+            self.assertTrue(t.TypeIsPointerType())
             if self.TraceOn():
                 print cvf.format(t)
+            list.append(int(t.GetChildMemberWithName("id").GetValue()))
 
         # Sanity checks that the we visited all the items (no more, no less).
-        #print "list:", list
+        if self.TraceOn():
+            print "visited IDs:", list
         self.assertTrue(visitedIDs == list)
         
 if __name__ == '__main__':





More information about the lldb-commits mailing list