diff --git a/lldb/test/array_types/TestArrayTypes.py b/lldb/test/array_types/TestArrayTypes.py index e83c9455d2d9..b3e1b0bcfc4a 100644 --- a/lldb/test/array_types/TestArrayTypes.py +++ b/lldb/test/array_types/TestArrayTypes.py @@ -195,6 +195,18 @@ class ArrayTypesTestCase(TestBase): 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 diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index befc773f2adb..08ee7bfe1598 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -814,6 +814,8 @@ class TestBase(unittest2.TestCase): 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 @@ class TestBase(unittest2.TestCase): 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') diff --git a/lldb/test/lldbutil.py b/lldb/test/lldbutil.py index 2d20927d49a0..b4a6e40bdcab 100644 --- a/lldb/test/lldbutil.py +++ b/lldb/test/lldbutil.py @@ -83,6 +83,27 @@ def StopReasonString(enum): 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