summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-06-29 21:19:39 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-06-29 21:19:39 +0000
commit6999f86617f371784be2b6f8d2ae38c8030dfd31 (patch)
tree02cbdbc515bda5998169028d22c01ea29d7ee011
parent1b8b9419bab268fcbd78022669a30433b40ad875 (diff)
downloadbcm5719-llvm-6999f86617f371784be2b6f8d2ae38c8030dfd31.tar.gz
bcm5719-llvm-6999f86617f371784be2b6f8d2ae38c8030dfd31.zip
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
-rw-r--r--lldb/include/lldb/API/SBType.h2
-rw-r--r--lldb/source/API/SBType.cpp6
-rw-r--r--lldb/source/API/SBValue.cpp18
-rw-r--r--lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py9
-rw-r--r--lldb/test/python_api/default-constructor/sb_type.py19
-rw-r--r--lldb/test/python_api/default-constructor/sb_value.py35
-rw-r--r--lldb/test/python_api/default-constructor/sb_valuelist.py12
7 files changed, 93 insertions, 8 deletions
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 97af8d21336..1dc330d6adb 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -53,7 +53,7 @@ public:
GetChildIndexForName (bool omit_empty_base_classes, const char *name);
bool
- IsPointerType ();
+ IsAPointerType ();
SBType
GetPointeeType ();
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index da37f6730ed..4f20124d22f 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -165,7 +165,7 @@ SBType::GetChildIndexForName (bool omit_empty_base_classes, const char *name)
}
bool
-SBType::IsPointerType ()
+SBType::IsAPointerType ()
{
return ClangASTContext::IsPointerType (m_type);
}
@@ -174,7 +174,7 @@ SBType
SBType::GetPointeeType ()
{
void *pointee_type = NULL;
- if (IsPointerType ())
+ if (IsAPointerType ())
{
pointee_type = ClangASTType::GetPointeeType (m_type);
}
@@ -187,7 +187,7 @@ SBType::GetDescription (SBStream &description)
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)
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 376bd624a54..801d15d060f 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -353,8 +353,13 @@ SBValue::SetValueFromCString (const char *value_str)
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::GetIndexOfChildWithName (const char *name)
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
diff --git a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
index f46ce835abf..f49a3a20d72 100644
--- a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
+++ b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
@@ -297,6 +297,9 @@ class APIDefaultConstructorTestCase(TestBase):
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 @@ class APIDefaultConstructorTestCase(TestBase):
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 @@ class APIDefaultConstructorTestCase(TestBase):
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__':
diff --git a/lldb/test/python_api/default-constructor/sb_type.py b/lldb/test/python_api/default-constructor/sb_type.py
new file mode 100644
index 00000000000..689b48cbddf
--- /dev/null
+++ b/lldb/test/python_api/default-constructor/sb_type.py
@@ -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())
+
diff --git a/lldb/test/python_api/default-constructor/sb_value.py b/lldb/test/python_api/default-constructor/sb_value.py
new file mode 100644
index 00000000000..f3929a6cb29
--- /dev/null
+++ b/lldb/test/python_api/default-constructor/sb_value.py
@@ -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)
diff --git a/lldb/test/python_api/default-constructor/sb_valuelist.py b/lldb/test/python_api/default-constructor/sb_valuelist.py
new file mode 100644
index 00000000000..6d659097c18
--- /dev/null
+++ b/lldb/test/python_api/default-constructor/sb_valuelist.py
@@ -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)
OpenPOWER on IntegriCloud