forked from OSchip/llvm-project
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. llvm-svn: 134096
This commit is contained in:
parent
1b8b9419ba
commit
6999f86617
|
@ -53,7 +53,7 @@ public:
|
||||||
GetChildIndexForName (bool omit_empty_base_classes, const char *name);
|
GetChildIndexForName (bool omit_empty_base_classes, const char *name);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IsPointerType ();
|
IsAPointerType ();
|
||||||
|
|
||||||
SBType
|
SBType
|
||||||
GetPointeeType ();
|
GetPointeeType ();
|
||||||
|
|
|
@ -165,7 +165,7 @@ SBType::GetChildIndexForName (bool omit_empty_base_classes, const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SBType::IsPointerType ()
|
SBType::IsAPointerType ()
|
||||||
{
|
{
|
||||||
return ClangASTContext::IsPointerType (m_type);
|
return ClangASTContext::IsPointerType (m_type);
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ SBType
|
||||||
SBType::GetPointeeType ()
|
SBType::GetPointeeType ()
|
||||||
{
|
{
|
||||||
void *pointee_type = NULL;
|
void *pointee_type = NULL;
|
||||||
if (IsPointerType ())
|
if (IsAPointerType ())
|
||||||
{
|
{
|
||||||
pointee_type = ClangASTType::GetPointeeType (m_type);
|
pointee_type = ClangASTType::GetPointeeType (m_type);
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ SBType::GetDescription (SBStream &description)
|
||||||
const char *name = GetName();
|
const char *name = GetName();
|
||||||
uint64_t byte_size = GetByteSize();
|
uint64_t byte_size = GetByteSize();
|
||||||
uint64_t num_children = GetNumberChildren (true);
|
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);
|
description.Printf ("type_name: %s, size: %d bytes", (name != NULL ? name : "<unknown type name>"), byte_size);
|
||||||
if (is_ptr)
|
if (is_ptr)
|
||||||
|
|
|
@ -353,8 +353,13 @@ SBValue::SetValueFromCString (const char *value_str)
|
||||||
SBValue
|
SBValue
|
||||||
SBValue::GetChildAtIndex (uint32_t idx)
|
SBValue::GetChildAtIndex (uint32_t idx)
|
||||||
{
|
{
|
||||||
lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
|
if (m_opaque_sp)
|
||||||
return GetChildAtIndex (idx, use_dynamic_value);
|
{
|
||||||
|
lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
|
||||||
|
return GetChildAtIndex (idx, use_dynamic_value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return GetChildAtIndex (idx, eNoDynamicValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
SBValue
|
SBValue
|
||||||
|
@ -416,8 +421,13 @@ SBValue::GetIndexOfChildWithName (const char *name)
|
||||||
SBValue
|
SBValue
|
||||||
SBValue::GetChildMemberWithName (const char *name)
|
SBValue::GetChildMemberWithName (const char *name)
|
||||||
{
|
{
|
||||||
lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
|
if (m_opaque_sp)
|
||||||
return GetChildMemberWithName (name, use_dynamic_value);
|
{
|
||||||
|
lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
|
||||||
|
return GetChildMemberWithName (name, use_dynamic_value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return GetChildMemberWithName (name, eNoDynamicValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
SBValue
|
SBValue
|
||||||
|
|
|
@ -297,6 +297,9 @@ class APIDefaultConstructorTestCase(TestBase):
|
||||||
if self.TraceOn():
|
if self.TraceOn():
|
||||||
print obj
|
print obj
|
||||||
self.assertFalse(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
|
@python_api_test
|
||||||
def test_SBValue(self):
|
def test_SBValue(self):
|
||||||
|
@ -304,6 +307,9 @@ class APIDefaultConstructorTestCase(TestBase):
|
||||||
if self.TraceOn():
|
if self.TraceOn():
|
||||||
print obj
|
print obj
|
||||||
self.assertFalse(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
|
@python_api_test
|
||||||
def test_SBValueList(self):
|
def test_SBValueList(self):
|
||||||
|
@ -311,6 +317,9 @@ class APIDefaultConstructorTestCase(TestBase):
|
||||||
if self.TraceOn():
|
if self.TraceOn():
|
||||||
print obj
|
print obj
|
||||||
self.assertFalse(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__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -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())
|
||||||
|
|
|
@ -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)
|
|
@ -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)
|
Loading…
Reference in New Issue