[Lldb-commits] [lldb] r118197 - in /lldb/trunk/test: array_types/TestArrayTypes.py lldbtest.py lldbutil.py

Johnny Chen johnny.chen at apple.com
Wed Nov 3 14:37:58 PDT 2010


Author: johnny
Date: Wed Nov  3 16:37:58 2010
New Revision: 118197

URL: http://llvm.org/viewvc/llvm-project?rev=118197&view=rev
Log:
Add a test for Python API SBValue.GetValueType() inside TestArrayTypes.py for a
local variable and an argument variable.

Add ValueTypeString() utility function into lldbutil.py which converts the enum
into a human readable string.

Modify TestBase.DebugSBValue() to also dump the value type of an SBValue object.

Modified:
    lldb/trunk/test/array_types/TestArrayTypes.py
    lldb/trunk/test/lldbtest.py
    lldb/trunk/test/lldbutil.py

Modified: lldb/trunk/test/array_types/TestArrayTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=118197&r1=118196&r2=118197&view=diff
==============================================================================
--- lldb/trunk/test/array_types/TestArrayTypes.py (original)
+++ lldb/trunk/test/array_types/TestArrayTypes.py Wed Nov  3 16:37:58 2010
@@ -195,6 +195,18 @@
         self.assertTrue(long(child5.GetValue(frame), 0) == 6,
                         "long_6[5] == 6")
 
+        # Last, check that "long_6" has a value type of eValueTypeVariableLocal
+        # and "argc" has eValueTypeVariableArgument.
+        from lldbutil import ValueTypeString
+        self.assertTrue(variable.GetValueType() == lldb.eValueTypeVariableLocal,
+                        "Variable 'long_6' should have '%s' value type." %
+                        ValueTypeString(lldb.eValueTypeVariableLocal))
+        argc = frame.LookupVar("argc")
+        self.DebugSBValue(frame, argc)
+        self.assertTrue(argc.GetValueType() == lldb.eValueTypeVariableArgument,
+                        "Variable 'argc' should have '%s' value type." %
+                        ValueTypeString(lldb.eValueTypeVariableArgument))
+
 
 if __name__ == '__main__':
     import atexit

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=118197&r1=118196&r2=118197&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Nov  3 16:37:58 2010
@@ -814,6 +814,8 @@
 
     def DebugSBValue(self, frame, val):
         """Debug print a SBValue object, if traceAlways is True."""
+        from lldbutil import ValueTypeString
+
         if not traceAlways:
             return
 
@@ -823,6 +825,7 @@
         err.write('\t' + "ByteSize      -> " + str(val.GetByteSize())       + '\n')
         err.write('\t' + "NumChildren   -> " + str(val.GetNumChildren())    + '\n')
         err.write('\t' + "Value         -> " + str(val.GetValue(frame))     + '\n')
+        err.write('\t' + "ValueType     -> " + ValueTypeString(val.GetValueType()) + '\n')
         err.write('\t' + "Summary       -> " + str(val.GetSummary(frame))   + '\n')
         err.write('\t' + "IsPointerType -> " + str(val.TypeIsPointerType()) + '\n')
         err.write('\t' + "Location      -> " + val.GetLocation(frame)       + '\n')

Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=118197&r1=118196&r2=118197&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Wed Nov  3 16:37:58 2010
@@ -83,6 +83,27 @@
     else:
         raise Exception("Unknown stopReason enum")
 
+def ValueTypeString(enum):
+    """Returns the valueType string given an enum."""
+    if enum == lldb.eValueTypeInvalid:
+        return "invalid"
+    elif enum == lldb.eValueTypeVariableGlobal:
+        return "global_variable"
+    elif enum == lldb.eValueTypeVariableStatic:
+        return "static_variable"
+    elif enum == lldb.eValueTypeVariableArgument:
+        return "argument_variable"
+    elif enum == lldb.eValueTypeVariableLocal:
+        return "local_variable"
+    elif enum == lldb.eValueTypeRegister:
+        return "register"
+    elif enum == lldb.eValueTypeRegisterSet:
+        return "register_set"
+    elif enum == lldb.eValueTypeConstResult:
+        return "constant_result"
+    else:
+        raise Exception("Unknown valueType enum")
+
 
 # ==================================================
 # Utility functions related to Threads and Processes





More information about the lldb-commits mailing list