[Lldb-commits] [lldb] r134096 - in /lldb/trunk: include/lldb/API/SBType.h source/API/SBType.cpp source/API/SBValue.cpp test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py test/python_api/default-constructor/sb_type.py test/python_api/default-constructor/sb_value.py test/python_api/default-constructor/sb_valuelist.py
Johnny Chen
johnny.chen at apple.com
Wed Jun 29 14:19:39 PDT 2011
Author: johnny
Date: Wed Jun 29 16:19:39 2011
New Revision: 134096
URL: http://llvm.org/viewvc/llvm-project?rev=134096&view=rev
Log:
Add fuzz calls to SBType, SBValue, and SBValueList.
Fixed crashes for SBValue fuzz calls.
And change 'bool SBType::IsPointerType(void)' to
'bool SBType::IsAPointerType(void)' to avoid name collision with the static 'bool SBType::IsPointerType(void *)'
function, which SWIG cannot handle.
Added:
lldb/trunk/test/python_api/default-constructor/sb_type.py
lldb/trunk/test/python_api/default-constructor/sb_value.py
lldb/trunk/test/python_api/default-constructor/sb_valuelist.py
Modified:
lldb/trunk/include/lldb/API/SBType.h
lldb/trunk/source/API/SBType.cpp
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
Modified: lldb/trunk/include/lldb/API/SBType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=134096&r1=134095&r2=134096&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBType.h (original)
+++ lldb/trunk/include/lldb/API/SBType.h Wed Jun 29 16:19:39 2011
@@ -53,7 +53,7 @@
GetChildIndexForName (bool omit_empty_base_classes, const char *name);
bool
- IsPointerType ();
+ IsAPointerType ();
SBType
GetPointeeType ();
Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=134096&r1=134095&r2=134096&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Wed Jun 29 16:19:39 2011
@@ -165,7 +165,7 @@
}
bool
-SBType::IsPointerType ()
+SBType::IsAPointerType ()
{
return ClangASTContext::IsPointerType (m_type);
}
@@ -174,7 +174,7 @@
SBType::GetPointeeType ()
{
void *pointee_type = NULL;
- if (IsPointerType ())
+ if (IsAPointerType ())
{
pointee_type = ClangASTType::GetPointeeType (m_type);
}
@@ -187,7 +187,7 @@
const char *name = GetName();
uint64_t byte_size = GetByteSize();
uint64_t num_children = GetNumberChildren (true);
- bool is_ptr = IsPointerType ();
+ bool is_ptr = IsAPointerType ();
description.Printf ("type_name: %s, size: %d bytes", (name != NULL ? name : "<unknown type name>"), byte_size);
if (is_ptr)
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=134096&r1=134095&r2=134096&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Wed Jun 29 16:19:39 2011
@@ -353,8 +353,13 @@
SBValue
SBValue::GetChildAtIndex (uint32_t idx)
{
- lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
- return GetChildAtIndex (idx, use_dynamic_value);
+ if (m_opaque_sp)
+ {
+ lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
+ return GetChildAtIndex (idx, use_dynamic_value);
+ }
+ else
+ return GetChildAtIndex (idx, eNoDynamicValues);
}
SBValue
@@ -416,8 +421,13 @@
SBValue
SBValue::GetChildMemberWithName (const char *name)
{
- lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
- return GetChildMemberWithName (name, use_dynamic_value);
+ if (m_opaque_sp)
+ {
+ lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
+ return GetChildMemberWithName (name, use_dynamic_value);
+ }
+ else
+ return GetChildMemberWithName (name, eNoDynamicValues);
}
SBValue
Modified: lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py?rev=134096&r1=134095&r2=134096&view=diff
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py (original)
+++ lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py Wed Jun 29 16:19:39 2011
@@ -297,6 +297,9 @@
if self.TraceOn():
print obj
self.assertFalse(obj)
+ # Do fuzz testing on the invalid obj, it should not crash lldb.
+ import sb_type
+ sb_type.fuzz_obj(obj)
@python_api_test
def test_SBValue(self):
@@ -304,6 +307,9 @@
if self.TraceOn():
print obj
self.assertFalse(obj)
+ # Do fuzz testing on the invalid obj, it should not crash lldb.
+ import sb_value
+ sb_value.fuzz_obj(obj)
@python_api_test
def test_SBValueList(self):
@@ -311,6 +317,9 @@
if self.TraceOn():
print obj
self.assertFalse(obj)
+ # Do fuzz testing on the invalid obj, it should not crash lldb.
+ import sb_valuelist
+ sb_valuelist.fuzz_obj(obj)
if __name__ == '__main__':
Added: lldb/trunk/test/python_api/default-constructor/sb_type.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_type.py?rev=134096&view=auto
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_type.py (added)
+++ lldb/trunk/test/python_api/default-constructor/sb_type.py Wed Jun 29 16:19:39 2011
@@ -0,0 +1,19 @@
+"""
+Fuzz tests an object after the default construction to make sure it does not crash lldb.
+"""
+
+import sys
+import lldb
+
+def fuzz_obj(obj):
+ obj.GetName()
+ obj.GetByteSize()
+ #obj.GetEncoding(5)
+ obj.GetNumberChildren(True)
+ member = lldb.SBTypeMember()
+ obj.GetChildAtIndex(True, 0, member)
+ obj.GetChildIndexForName(True, "_member_field")
+ obj.IsAPointerType()
+ obj.GetPointeeType()
+ obj.GetDescription(lldb.SBStream())
+
Added: lldb/trunk/test/python_api/default-constructor/sb_value.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_value.py?rev=134096&view=auto
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_value.py (added)
+++ lldb/trunk/test/python_api/default-constructor/sb_value.py Wed Jun 29 16:19:39 2011
@@ -0,0 +1,35 @@
+"""
+Fuzz tests an object after the default construction to make sure it does not crash lldb.
+"""
+
+import sys
+import lldb
+
+def fuzz_obj(obj):
+ obj.GetError()
+ obj.GetName()
+ obj.GetTypeName()
+ obj.GetByteSize()
+ obj.IsInScope()
+ obj.GetFormat()
+ obj.SetFormat(lldb.eFormatBoolean)
+ obj.GetValue()
+ obj.GetValueType()
+ obj.GetValueDidChange()
+ obj.GetSummary()
+ obj.GetObjectDescription()
+ obj.GetLocation()
+ obj.SetValueFromCString("my_new_value")
+ obj.GetChildAtIndex(1)
+ obj.GetChildAtIndex(2, lldb.eNoDynamicValues)
+ obj.GetIndexOfChildWithName("my_first_child")
+ obj.GetChildMemberWithName("my_first_child")
+ obj.GetChildMemberWithName("my_first_child", lldb.eNoDynamicValues)
+ obj.GetNumChildren()
+ obj.GetOpaqueType()
+ obj.Dereference()
+ obj.TypeIsPointerType()
+ stream = lldb.SBStream()
+ obj.GetDescription(stream)
+ obj.GetExpressionPath(stream)
+ obj.GetExpressionPath(stream, True)
Added: lldb/trunk/test/python_api/default-constructor/sb_valuelist.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_valuelist.py?rev=134096&view=auto
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_valuelist.py (added)
+++ lldb/trunk/test/python_api/default-constructor/sb_valuelist.py Wed Jun 29 16:19:39 2011
@@ -0,0 +1,12 @@
+"""
+Fuzz tests an object after the default construction to make sure it does not crash lldb.
+"""
+
+import sys
+import lldb
+
+def fuzz_obj(obj):
+ obj.Append(lldb.SBValue())
+ obj.GetSize()
+ obj.GetValueAtIndex(100)
+ obj.FindValueObjectByUID(200)
More information about the lldb-commits
mailing list