[Lldb-commits] [lldb] r149447 - in /lldb/trunk: include/lldb/API/SBType.h scripts/Python/interface/SBType.i source/API/SBType.cpp test/python_api/default-constructor/sb_module.py test/python_api/default-constructor/sb_target.py test/python_api/default-constructor/sb_value.py

Greg Clayton gclayton at apple.com
Tue Jan 31 15:19:33 PST 2012


Author: gclayton
Date: Tue Jan 31 17:19:33 2012
New Revision: 149447

URL: http://llvm.org/viewvc/llvm-project?rev=149447&view=rev
Log:
Added fuzz testing for when we call API calls with an invalid object.
We previously weren't catching that SBValue::Cast(...) would crash
if we had an invalid (empty) SBValue object.

Cleaned up the SBType API a bit.


Modified:
    lldb/trunk/include/lldb/API/SBType.h
    lldb/trunk/scripts/Python/interface/SBType.i
    lldb/trunk/source/API/SBType.cpp
    lldb/trunk/test/python_api/default-constructor/sb_module.py
    lldb/trunk/test/python_api/default-constructor/sb_target.py
    lldb/trunk/test/python_api/default-constructor/sb_value.py

Modified: lldb/trunk/include/lldb/API/SBType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=149447&r1=149446&r2=149447&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBType.h (original)
+++ lldb/trunk/include/lldb/API/SBType.h Tue Jan 31 17:19:33 2012
@@ -138,8 +138,6 @@
     GetDescription (lldb::SBStream &description, 
                     lldb::DescriptionLevel description_level);
 
-protected:
-    
 #ifndef SWIG
     lldb::SBType &
     operator = (const lldb::SBType &rhs);
@@ -149,7 +147,11 @@
     
     bool
     operator != (lldb::SBType &rhs);
+#endif
     
+protected:
+    
+#ifndef SWIG
     lldb_private::TypeImpl &
     ref ();
     
@@ -157,7 +159,7 @@
     ref () const;
     
     void
-    reset(const lldb::TypeImplSP &type_impl_sp);
+    SetSP (const lldb::TypeImplSP &type_impl_sp);
 #endif
     
 

Modified: lldb/trunk/scripts/Python/interface/SBType.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBType.i?rev=149447&r1=149446&r2=149447&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBType.i (original)
+++ lldb/trunk/scripts/Python/interface/SBType.i Tue Jan 31 17:19:33 2012
@@ -131,6 +131,8 @@
 class SBType
 {
 public:
+    SBType ();
+
     SBType (const lldb::SBType &rhs);
 
     ~SBType ();

Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=149447&r1=149446&r2=149447&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Tue Jan 31 17:19:33 2012
@@ -84,7 +84,7 @@
 }
 
 void
-SBType::reset(const lldb::TypeImplSP &type_impl_sp)
+SBType::SetSP (const lldb::TypeImplSP &type_impl_sp)
 {
     m_opaque_sp = type_impl_sp;
 }
@@ -556,7 +556,7 @@
     SBType sb_type;
     if (m_opaque_ap.get())
     {
-        sb_type.reset (m_opaque_ap->GetTypeImpl());
+        sb_type.SetSP (m_opaque_ap->GetTypeImpl());
     }
     return sb_type;
 

Modified: lldb/trunk/test/python_api/default-constructor/sb_module.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_module.py?rev=149447&r1=149446&r2=149447&view=diff
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_module.py (original)
+++ lldb/trunk/test/python_api/default-constructor/sb_module.py Tue Jan 31 17:19:33 2012
@@ -23,4 +23,6 @@
         print symbol
     for symbol in obj:
         print symbol
-
+    obj.GetAddressByteSize()
+    obj.GetByteOrder()
+    obj.GetTriple()

Modified: lldb/trunk/test/python_api/default-constructor/sb_target.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_target.py?rev=149447&r1=149446&r2=149447&view=diff
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_target.py (original)
+++ lldb/trunk/test/python_api/default-constructor/sb_target.py Tue Jan 31 17:19:33 2012
@@ -49,6 +49,9 @@
     obj.EnableAllWatchpoints()
     obj.DisableAllWatchpoints()
     obj.DeleteAllWatchpoints()
+    obj.GetAddressByteSize()
+    obj.GetByteOrder()
+    obj.GetTriple()
     obj.WatchAddress(123, 8, True, True)
     obj.GetBroadcaster()
     obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief)

Modified: 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=149447&r1=149446&r2=149447&view=diff
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_value.py (original)
+++ lldb/trunk/test/python_api/default-constructor/sb_value.py Tue Jan 31 17:19:33 2012
@@ -7,6 +7,7 @@
 
 def fuzz_obj(obj):
     obj.GetError()
+    obj.GetID()
     obj.GetName()
     obj.GetTypeName()
     obj.GetByteSize()
@@ -37,3 +38,29 @@
     obj.WatchPointee(True, False, True)
     for child_val in obj:
         print child_val
+    error = lldb.SBError()
+    obj.GetValueAsSigned (error, 0)
+    obj.GetValueAsUnsigned (error, 0)
+    obj.GetValueAsSigned(0)
+    obj.GetValueAsUnsigned(0)
+    obj.GetDynamicValue (lldb.eNoDynamicValues)
+    obj.GetStaticValue ()
+    obj.IsDynamic()
+    invalid_type = lldb.SBType()
+    obj.CreateChildAtOffset ("a", 12, invalid_type)
+    obj.Cast (invalid_type)
+    obj.CreateValueFromExpression ("pt->x", "pt->x")
+    obj.CreateValueFromAddress ("x", 0x123, invalid_type)
+    invalid_data = lldb.SBData()
+    obj.CreateValueFromData ("x", invalid_data, invalid_type)
+    obj.GetValueForExpressionPath("[0]")
+    obj.AddressOf()
+    obj.GetLoadAddress()
+    obj.GetAddress()
+    obj.GetPointeeData (0, 1)
+    obj.GetData ()
+    obj.GetTarget()
+    obj.GetProcess()
+    obj.GetThread()
+    obj.GetFrame()
+    obj.GetType()





More information about the lldb-commits mailing list