[Lldb-commits] [lldb] r151962 - in /lldb/trunk: examples/summaries/cocoa/CFBitVector.py examples/summaries/cocoa/objc_runtime.py scripts/Python/finish-swig-Python-LLDB.sh scripts/Python/interface/SBAddress.i scripts/Python/interface/SBData.i source/Core/FormatManager.cpp source/Core/ValueObject.cpp source/Interpreter/ScriptInterpreterPython.cpp test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py test/functionalities/data-formatter/data-formatter-objc/main.m test/python_api/sbdata/TestSBData.py

Enrico Granata egranata at apple.com
Fri Mar 2 16:45:57 PST 2012


Author: enrico
Date: Fri Mar  2 18:45:57 2012
New Revision: 151962

URL: http://llvm.org/viewvc/llvm-project?rev=151962&view=rev
Log:
added a new formatter for CF(Mutable)BitVector
fixed a few potential NULL-pointer derefs in ValueObject
we have a way to provide docstrings for properties we add to the SWIG layer - a few of these properties have a docstring already, more will come in future commits
added a new bunch of properties to SBData to make it more natural and Python-like to access the data they contain

Added:
    lldb/trunk/examples/summaries/cocoa/CFBitVector.py
Modified:
    lldb/trunk/examples/summaries/cocoa/objc_runtime.py
    lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh
    lldb/trunk/scripts/Python/interface/SBAddress.i
    lldb/trunk/scripts/Python/interface/SBData.i
    lldb/trunk/source/Core/FormatManager.cpp
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
    lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
    lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m
    lldb/trunk/test/python_api/sbdata/TestSBData.py

Added: lldb/trunk/examples/summaries/cocoa/CFBitVector.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/cocoa/CFBitVector.py?rev=151962&view=auto
==============================================================================
--- lldb/trunk/examples/summaries/cocoa/CFBitVector.py (added)
+++ lldb/trunk/examples/summaries/cocoa/CFBitVector.py Fri Mar  2 18:45:57 2012
@@ -0,0 +1,162 @@
+# summary provider for CF(Mutable)BitVector
+import lldb
+import ctypes
+import objc_runtime
+import metrics
+
+# first define some utility functions
+def byte_index(abs_pos):
+	return abs_pos/8
+
+def bit_index(abs_pos):
+	return abs_pos & 7
+
+def get_bit(byte,index):
+	if index < 0 or index > 7:
+		return None
+	return (byte >> (7-index)) & 1
+
+def grab_array_item_data(pointer,index):
+	return pointer.GetPointeeData(index,1)
+
+statistics = metrics.Metrics()
+statistics.add_metric('invalid_isa')
+statistics.add_metric('invalid_pointer')
+statistics.add_metric('unknown_class')
+statistics.add_metric('code_notrun')
+
+# despite the similary to synthetic children providers, these classes are not
+# trying to provide anything but a summary for a CF*BitVector, so they need not
+# obey the interface specification for synthetic children providers
+class CFBitVectorKnown_SummaryProvider:
+	def adjust_for_architecture(self):
+		self.is_64_bit = self.sys_params.is_64_bit
+		self.is_little = self.sys_params.is_little
+		self.pointer_size = self.sys_params.pointer_size
+		self.cfruntime_size = 16 if self.is_64_bit else 8
+
+	def __init__(self, valobj, params):
+		self.valobj = valobj;
+		self.sys_params = params
+		self.update();
+
+	def update(self):
+		self.adjust_for_architecture();
+		self.id_type = self.valobj.GetType().GetBasicType(lldb.eBasicTypeObjCID)
+		if self.is_64_bit:
+			self.NSUInteger = self.valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedLong)
+		else:
+			self.NSUInteger = self.valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedInt)
+		self.charptr_type = self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar).GetPointerType()
+		self.uiint_size = self.NSUInteger.GetByteSize()
+
+	# we skip the CFRuntimeBase
+	# then the next CFIndex is the count
+	# then we skip another CFIndex and then we get at a byte array
+	# that wraps the individual bits
+
+	def contents(self):
+		count_vo = self.valobj.CreateChildAtOffset("count",self.cfruntime_size,
+													self.NSUInteger)
+		count = count_vo.GetValueAsUnsigned(0)
+		if count == 0:
+			return '(empty)'
+		
+		array_vo = self.valobj.CreateChildAtOffset("data",
+													self.cfruntime_size+2*self.uiint_size,
+													self.charptr_type)
+		
+		data_list = []
+		cur_byte_pos = None
+		for i in range(0,count):
+			if cur_byte_pos == None:
+				cur_byte_pos = byte_index(i)
+				cur_byte = grab_array_item_data(array_vo,cur_byte_pos)
+				cur_byte_val = cur_byte.uint8[0]
+			else:
+				byte_pos = byte_index(i)
+				# do not fetch the pointee data every single time through
+				if byte_pos != cur_byte_pos:
+					cur_byte_pos = byte_pos
+					cur_byte = grab_array_item_data(array_vo,cur_byte_pos)
+					cur_byte_val = cur_byte.uint8[0]
+			bit = get_bit(cur_byte_val,bit_index(i))
+			if (i % 4) == 0:
+				data_list.append(' ')
+			if bit == 1:
+				data_list.append('1')
+			else:
+				data_list.append('0')
+		return ''.join(data_list)
+
+
+class CFBitVectorUnknown_SummaryProvider:
+	def adjust_for_architecture(self):
+		self.is_64_bit = (self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8)
+		self.is_little = (self.valobj.GetTarget().GetProcess().GetByteOrder() == lldb.eByteOrderLittle)
+		self.pointer_size = self.valobj.GetTarget().GetProcess().GetAddressByteSize()
+
+	def __init__(self, valobj):
+		self.valobj = valobj;
+		self.update()
+
+	def update(self):
+		self.adjust_for_architecture();
+		self.id_type = self.valobj.GetType().GetBasicType(lldb.eBasicTypeObjCID)
+
+	def contents(self):
+		return '*** unknown class *** very bad thing *** find out my name ***'
+
+
+def GetSummary_Impl(valobj):
+	global statistics
+	class_data = objc_runtime.ObjCRuntime(valobj)
+	if class_data.is_valid() == False:
+		statistics.metric_hit('invalid_pointer',valobj)
+		wrapper = None
+		return
+	class_data = class_data.read_class_data()
+	if class_data.is_valid() == False:
+		statistics.metric_hit('invalid_isa',valobj)
+		wrapper = None
+		return
+	if class_data.is_kvo():
+		class_data = class_data.get_superclass()
+	if class_data.is_valid() == False:
+		statistics.metric_hit('invalid_isa',valobj)
+		wrapper = None
+		return
+
+	name_string = class_data.class_name()
+	if name_string == '__NSCFType':
+		# CFBitVectorRef does not expose an actual NSWrapper type, so we have to check that this is
+		# an NSCFType and then check we are a pointer-to CFBitVectorRef
+		valobj_type = valobj.GetType()
+		if valobj_type.IsValid() and valobj_type.IsPointerType():
+			pointee_type = valobj_type.GetPointeeType()
+			if pointee_type.GetName() == '__CFBitVector' or pointee_type.GetName() == '__CFMutableBitVector':
+				wrapper = CFBitVectorKnown_SummaryProvider(valobj, class_data.sys_params)
+				statistics.metric_hit('code_notrun',valobj)
+			else:
+				wrapper = CFBitVectorUnknown_SummaryProvider(valobj)
+				print pointee_type.GetName()
+	else:
+		wrapper = CFBitVectorUnknown_SummaryProvider(valobj)
+		print name_string
+		statistics.metric_hit('unknown_class',str(valobj) + " seen as " + name_string)
+	return wrapper;
+
+def CFBitVector_SummaryProvider (valobj,dict):
+	provider = GetSummary_Impl(valobj);
+	if provider != None:
+	    #try:
+	    summary = provider.contents();
+	    #except:
+	    #    summary = None
+	    if summary == None or summary == '':
+	        summary = 'no valid bitvector here'
+	    return summary
+	return ''
+
+def __lldb_init_module(debugger,dict):
+	debugger.HandleCommand("type summary add -F CFBitVector.CFBitVector_SummaryProvider CFBitVectorRef CFMutableBitVectorRef")

Modified: lldb/trunk/examples/summaries/cocoa/objc_runtime.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/cocoa/objc_runtime.py?rev=151962&r1=151961&r2=151962&view=diff
==============================================================================
--- lldb/trunk/examples/summaries/cocoa/objc_runtime.py (original)
+++ lldb/trunk/examples/summaries/cocoa/objc_runtime.py Fri Mar  2 18:45:57 2012
@@ -407,6 +407,9 @@
 runtime_version = cache.Cache()
 os_version = cache.Cache()
 
+# TODO: make more extensive use of this class in the individual formatters
+# instead of recalculating the same information - since we are building this object
+# it makes sense to pass it around to the formatters
 class SystemParameters:
 	def __init__(self,valobj):
 		self.adjust_for_architecture(valobj)
@@ -432,6 +435,7 @@
 		else:
 			self.is_lion = Utilities.check_is_osx_lion(valobj.GetTarget())
 			os_version.add_item(pid,self.is_lion)
+		self.cfruntime_size = 16 if self.is_64_bit else 8
 
 isa_cache = cache.Cache()
 

Modified: lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh?rev=151962&r1=151961&r2=151962&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh (original)
+++ lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh Fri Mar  2 18:45:57 2012
@@ -410,6 +410,20 @@
     fi
 fi
 
+if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFBitVector.py" ]
+then
+    if [ $Debug == 1 ]
+    then
+        echo "Copying CFBitVector.py to ${framework_python_dir}"
+    fi
+    cp "${SRC_ROOT}/examples/summaries/cocoa/CFBitVector.py" "${framework_python_dir}"
+else
+    if [ $Debug == 1 ]
+    then
+        echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFBitVector.py"
+    fi
+fi
+
 if [ -f "${SRC_ROOT}/examples/summaries/cocoa/Selector.py" ]
 then
     if [ $Debug == 1 ]

Modified: lldb/trunk/scripts/Python/interface/SBAddress.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBAddress.i?rev=151962&r1=151961&r2=151962&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBAddress.i (original)
+++ lldb/trunk/scripts/Python/interface/SBAddress.i Fri Mar  2 18:45:57 2012
@@ -160,35 +160,35 @@
             return '0x%x' % int(self)
 
         __swig_getmethods__["module"] = GetModule
-        if _newclass: x = property(GetModule, None)
+        if _newclass: module = property(GetModule, None, doc='Returns the same result as GetModule()')
 
         __swig_getmethods__["compile_unit"] = GetCompileUnit
-        if _newclass: x = property(GetCompileUnit, None)
+        if _newclass: compile_unit = property(GetCompileUnit, None, doc='Returns the same result as GetCompileUnit()')
 
         __swig_getmethods__["line_entry"] = GetLineEntry
-        if _newclass: x = property(GetLineEntry, None)
+        if _newclass: line_entry = property(GetLineEntry, None, doc='Returns the same result as GetLineEntry()')
 
         __swig_getmethods__["function"] = GetFunction
-        if _newclass: x = property(GetFunction, None)
+        if _newclass: function = property(GetFunction, None, doc='Returns the same result as GetFunction()')
 
         __swig_getmethods__["block"] = GetBlock
-        if _newclass: x = property(GetBlock, None)
+        if _newclass: block = property(GetBlock, None, doc='Returns the same result as GetBlock()')
 
         __swig_getmethods__["symbol"] = GetSymbol
-        if _newclass: x = property(GetSymbol, None)
+        if _newclass: symbol = property(GetSymbol, None, doc='Returns the same result as GetSymbol()')
 
         __swig_getmethods__["offset"] = GetOffset
-        if _newclass: x = property(GetOffset, None)
+        if _newclass: offset = property(GetOffset, None, doc='Returns the same result as GetOffset()')
 
         __swig_getmethods__["section"] = GetSection
-        if _newclass: x = property(GetSection, None)
+        if _newclass: section = property(GetSection, None, doc='Returns the same result as GetSection()')
 
         __swig_getmethods__["file_addr"] = GetFileAddress
-        if _newclass: x = property(GetFileAddress, None)
+        if _newclass: file_addr = property(GetFileAddress, None, doc='Returns the same result as GetFileAddress()')
 
         __swig_getmethods__["load_addr"] = __get_load_addr_property__
         __swig_setmethods__["load_addr"] = __set_load_addr_property__
-        if _newclass: x = property(__get_load_addr_property__, __set_load_addr_property__)
+        if _newclass: load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='Returns a corresponding load address, resolving this SBAddress via lldb.target')
 
     %}
 

Modified: lldb/trunk/scripts/Python/interface/SBData.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBData.i?rev=151962&r1=151961&r2=151962&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBData.i (original)
+++ lldb/trunk/scripts/Python/interface/SBData.i Fri Mar  2 18:45:57 2012
@@ -134,12 +134,164 @@
     SetDataFromDoubleArray (double* array, size_t array_len);
 
     %pythoncode %{
+        
+        class read_data_helper:
+            def __init__(self, sbdata, readerfunc, item_size):
+                self.sbdata = sbdata
+                self.readerfunc = readerfunc
+                self.item_size = item_size
+            def __getitem__(self,key):
+                if isinstance(key,slice):
+                    list = []
+                    for x in range(*key.indices(self.__len__())):
+                        list.append(self.__getitem__(x))
+                    return list
+                if not (isinstance(key,(int,long))):
+                    raise TypeError('must be int')
+                key = key * self.item_size # SBData uses byte-based indexes, but we want to use itemsize-based indexes here
+                error = SBError()
+                my_data = self.readerfunc(self.sbdata,error,key)
+                if error.Fail():
+                    raise IndexError(error.GetCString())
+                else:
+                    return my_data
+            def __len__(self):
+                return self.sbdata.GetByteSize()/self.item_size
+            def all(self):
+                return self[0:len(self)]
+        
+        def _make_helper(self, sbdata, getfunc, itemsize):
+            return self.read_data_helper(sbdata, getfunc, itemsize)
+            
+        def _make_helper_uint8(self):
+            return self._make_helper(self, SBData.GetUnsignedInt8, 1)
+
+        def _make_helper_uint16(self):
+            return self._make_helper(self, SBData.GetUnsignedInt16, 2)
+
+        def _make_helper_uint32(self):
+            return self._make_helper(self, SBData.GetUnsignedInt32, 4)
+
+        def _make_helper_uint64(self):
+            return self._make_helper(self, SBData.GetUnsignedInt64, 8)
+
+        def _make_helper_sint8(self):
+            return self._make_helper(self, SBData.GetSignedInt8, 1)
+
+        def _make_helper_sint16(self):
+            return self._make_helper(self, SBData.GetSignedInt16, 2)
+
+        def _make_helper_sint32(self):
+            return self._make_helper(self, SBData.GetSignedInt32, 4)
+
+        def _make_helper_sint64(self):
+            return self._make_helper(self, SBData.GetSignedInt64, 8)
+
+        def _make_helper_float(self):
+            return self._make_helper(self, SBData.GetFloat, 4)
+
+        def _make_helper_double(self):
+            return self._make_helper(self, SBData.GetDouble, 8)
+        
+        def _read_all_uint8(self):
+            return self._make_helper_uint8().all()
+
+        def _read_all_uint16(self):
+            return self._make_helper_uint16().all()
+            
+        def _read_all_uint32(self):
+            return self._make_helper_uint32().all()
+            
+        def _read_all_uint64(self):
+            return self._make_helper_uint64().all()
+            
+        def _read_all_sint8(self):
+            return self._make_helper_sint8().all()
+            
+        def _read_all_sint16(self):
+            return self._make_helper_sint16().all()
+            
+        def _read_all_sint32(self):
+            return self._make_helper_sint32().all()
+            
+        def _read_all_sint64(self):
+            return self._make_helper_sint64().all()
+            
+        def _read_all_float(self):
+            return self._make_helper_float().all()
+            
+        def _read_all_double(self):
+            return self._make_helper_double().all()
+
+        __swig_getmethods__["uint8"] = _make_helper_uint8
+        if _newclass: uint8 = property(_make_helper_uint8, None, doc='Returns an array-like object out of which you can read uint8 values')
+        
+        __swig_getmethods__["uint16"] = _make_helper_uint16
+        if _newclass: uint16 = property(_make_helper_uint16, None, doc='Returns an array-like object out of which you can read uint16 values')
+        
+        __swig_getmethods__["uint32"] = _make_helper_uint32
+        if _newclass: uint32 = property(_make_helper_uint32, None, doc='Returns an array-like object out of which you can read uint32 values')
+        
+        __swig_getmethods__["uint64"] = _make_helper_uint64
+        if _newclass: uint64 = property(_make_helper_uint64, None, doc='Returns an array-like object out of which you can read uint64 values')
+
+        __swig_getmethods__["sint8"] = _make_helper_sint8
+        if _newclass: sint8 = property(_make_helper_sint8, None, doc='Returns an array-like object out of which you can read sint8 values')
+        
+        __swig_getmethods__["sint16"] = _make_helper_sint16
+        if _newclass: sint16 = property(_make_helper_sint16, None, doc='Returns an array-like object out of which you can read sint16 values')
+        
+        __swig_getmethods__["sint32"] = _make_helper_sint32
+        if _newclass: sint32 = property(_make_helper_sint32, None, doc='Returns an array-like object out of which you can read sint32 values')
+        
+        __swig_getmethods__["sint64"] = _make_helper_sint64
+        if _newclass: sint64 = property(_make_helper_sint64, None, doc='Returns an array-like object out of which you can read sint64 values')
+        
+        __swig_getmethods__["float"] = _make_helper_float
+        if _newclass: float = property(_make_helper_float, None, doc='Returns an array-like object out of which you can read float values')
+
+        __swig_getmethods__["double"] = _make_helper_double
+        if _newclass: double = property(_make_helper_double, None, doc='Returns an array-like object out of which you can read double values')
+                  
+        __swig_getmethods__["uint8s"] = _read_all_uint8
+        if _newclass: uint8s = property(_read_all_uint8, None, doc='Returns an array with all the contents of this SBData represented as uint8 values')
+        
+        __swig_getmethods__["uint16s"] = _read_all_uint16
+        if _newclass: uint16s = property(_read_all_uint16, None, doc='Returns an array with all the contents of this SBData represented as uint16 values')
+        
+        __swig_getmethods__["uint32s"] = _read_all_uint32
+        if _newclass: uint32s = property(_read_all_uint32, None, doc='Returns an array with all the contents of this SBData represented as uint32 values')
+        
+        __swig_getmethods__["uint64s"] = _read_all_uint64
+        if _newclass: uint64s = property(_read_all_uint64, None, doc='Returns an array with all the contents of this SBData represented as uint64 values')
+
+        __swig_getmethods__["sint8s"] = _read_all_sint8
+        if _newclass: sint8s = property(_read_all_sint8, None, doc='Returns an array with all the contents of this SBData represented as sint8 values')
+        
+        __swig_getmethods__["sint16s"] = _read_all_sint16
+        if _newclass: sint16s = property(_read_all_sint16, None, doc='Returns an array with all the contents of this SBData represented as sint16 values')
+        
+        __swig_getmethods__["sint32s"] = _read_all_sint32
+        if _newclass: sint32s = property(_read_all_sint32, None, doc='Returns an array with all the contents of this SBData represented as sint32 values')
+        
+        __swig_getmethods__["sint64s"] = _read_all_sint64
+        if _newclass: sint64s = property(_read_all_sint64, None, doc='Returns an array with all the contents of this SBData represented as sint64 values')
+        
+        __swig_getmethods__["floats"] = _read_all_float
+        if _newclass: floats = property(_read_all_float, None, doc='Returns an array with all the contents of this SBData represented as float values')
+
+        __swig_getmethods__["doubles"] = _read_all_double
+        if _newclass: doubles = property(_read_all_double, None, doc='Returns an array with all the contents of this SBData represented as double values')
+                  
+    %}
+    
+    %pythoncode %{
         __swig_getmethods__["byte_order"] = GetByteOrder
         __swig_setmethods__["byte_order"] = SetByteOrder
-        if _newclass: x = property(GetByteOrder, SetByteOrder)
+        if _newclass: byte_order = property(GetByteOrder, SetByteOrder, doc='Allows getting and setting the endianness of this SBData object')
         
         __swig_getmethods__["size"] = GetByteSize
-        if _newclass: x = property(GetByteSize, None)
+        if _newclass: size = property(GetByteSize, None, doc='Returns the size (in bytes) of the contents of this SBData object')
         
     %}
 

Modified: lldb/trunk/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=151962&r1=151961&r2=151962&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/Core/FormatManager.cpp Fri Mar  2 18:45:57 2012
@@ -885,6 +885,9 @@
 
     AddSummary(appkit_category_sp, "@\"${var.month%d}/${var.day%d}/${var.year%d} ${var.hour%d}:${var.minute%d}:${var.second}\"", ConstString("CFGregorianDate"), appkit_flags);
     
+    AddScriptSummary(appkit_category_sp, "CFBitVector.CFBitVector_SummaryProvider", ConstString("CFBitVectorRef"), appkit_flags);
+    AddScriptSummary(appkit_category_sp, "CFBitVector.CFBitVector_SummaryProvider", ConstString("CFMutableBitVectorRef"), appkit_flags);
+
     TypeCategoryImpl::SharedPointer vectors_category_sp = GetCategory(m_vectortypes_category_name);
 
     TypeSummaryImpl::Flags vector_flags;

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=151962&r1=151961&r2=151962&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Mar  2 18:45:57 2012
@@ -2221,24 +2221,26 @@
                                                            final_task_on_target ? final_task_on_target : &dummy_final_task_on_target);
     
     if (!final_task_on_target || *final_task_on_target == ValueObject::eNothing)
-    {
         return ret_val;
-    }
-    if (ret_val.get() && *final_value_type == ePlain) // I can only deref and takeaddress of plain objects
+
+    if (ret_val.get() && ((final_value_type ? *final_value_type : dummy_final_value_type) == ePlain)) // I can only deref and takeaddress of plain objects
     {
-        if (*final_task_on_target == ValueObject::eDereference)
+        if ( (final_task_on_target ? *final_task_on_target : dummy_final_task_on_target) == ValueObject::eDereference)
         {
             Error error;
             ValueObjectSP final_value = ret_val->Dereference(error);
             if (error.Fail() || !final_value.get())
             {
-                *reason_to_stop = ValueObject::eDereferencingFailed;
-                *final_value_type = ValueObject::eInvalid;
+                if (reason_to_stop)
+                    *reason_to_stop = ValueObject::eDereferencingFailed;
+                if (final_value_type)
+                    *final_value_type = ValueObject::eInvalid;
                 return ValueObjectSP();
             }
             else
             {
-                *final_task_on_target = ValueObject::eNothing;
+                if (final_task_on_target)
+                    *final_task_on_target = ValueObject::eNothing;
                 return final_value;
             }
         }
@@ -2248,13 +2250,16 @@
             ValueObjectSP final_value = ret_val->AddressOf(error);
             if (error.Fail() || !final_value.get())
             {
-                *reason_to_stop = ValueObject::eTakingAddressFailed;
-                *final_value_type = ValueObject::eInvalid;
+                if (reason_to_stop)
+                    *reason_to_stop = ValueObject::eTakingAddressFailed;
+                if (final_value_type)
+                    *final_value_type = ValueObject::eInvalid;
                 return ValueObjectSP();
             }
             else
             {
-                *final_task_on_target = ValueObject::eNothing;
+                if (final_task_on_target)
+                    *final_task_on_target = ValueObject::eNothing;
                 return final_value;
             }
         }

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=151962&r1=151961&r2=151962&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Mar  2 18:45:57 2012
@@ -282,7 +282,7 @@
     // WARNING: temporary code that loads Cocoa formatters - this should be done on a per-platform basis rather than loading the whole set
     // and letting the individual formatter classes exploit APIs to check whether they can/cannot do their task
     run_string.Clear();
-    run_string.Printf ("run_one_line (%s, 'import CFString, CFArray, CFDictionary, NSData, NSMachPort, NSSet, NSNotification, NSException, CFBag, CFBinaryHeap, NSURL, NSBundle, NSNumber, NSDate, NSIndexSet, Selector')", m_dictionary_name.c_str());
+    run_string.Printf ("run_one_line (%s, 'import CFString, CFArray, CFDictionary, NSData, NSMachPort, NSSet, NSNotification, NSException, CFBag, CFBinaryHeap, NSURL, NSBundle, NSNumber, NSDate, NSIndexSet, Selector, CFBitVector')", m_dictionary_name.c_str());
     PyRun_SimpleString (run_string.GetData());
 
     int new_count = Debugger::TestDebuggerRefCount();

Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=151962&r1=151961&r2=151962&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Fri Mar  2 18:45:57 2012
@@ -302,6 +302,8 @@
                     '@"Europe/Rome"',
                     '@"Europe/Paris"'])
 
+        self.expect('frame variable mut_bv',
+                    substrs = ['(CFMutableBitVectorRef) mut_bv = ', '1110 0110 1011 0000 1101 1010 1000 1111 0011 0101 1101 0001 00'])
 
         self.expect('frame variable cupertino_ns home_ns europe_ns',
                     substrs = ['@"America/Los_Angeles"',

Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m?rev=151962&r1=151961&r2=151962&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m Fri Mar  2 18:45:57 2012
@@ -598,6 +598,36 @@
 	HIRect hi_rect = {{3,5},{4,6}};
 	
 	SEL foo_selector = @selector(foo_selector_impl);
+	
+	CFMutableBitVectorRef mut_bv = CFBitVectorCreateMutable(NULL, 64);
+	CFBitVectorSetCount(mut_bv, 50);
+    CFBitVectorSetBitAtIndex(mut_bv, 0, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 1, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 2, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 5, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 6, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 8, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 10, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 11, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 16, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 17, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 19, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 20, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 22, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 24, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 28, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 29, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 30, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 30, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 31, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 34, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 35, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 37, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 39, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 40, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 41, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 43, 1);
+    CFBitVectorSetBitAtIndex(mut_bv, 47, 1);
 
 	Molecule *molecule = [Molecule new];
 

Modified: lldb/trunk/test/python_api/sbdata/TestSBData.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/sbdata/TestSBData.py?rev=151962&r1=151961&r2=151962&view=diff
==============================================================================
--- lldb/trunk/test/python_api/sbdata/TestSBData.py (original)
+++ lldb/trunk/test/python_api/sbdata/TestSBData.py Fri Mar  2 18:45:57 2012
@@ -129,12 +129,9 @@
         if self.TraceOn():
             print data
 
-        offset = 0
-        self.assertTrue(data.GetUnsignedInt32(error, offset) == 8, 'then foo[1].a == 8')
-        offset += 4
-        self.assertTrue(data.GetUnsignedInt32(error, offset) == 7, 'then foo[1].b == 7')
-        offset += 4
-        self.assertTrue(fabs(data.GetFloat(error, offset) - 3.14) < 1, 'foo[1].c == 3.14')
+        self.assertTrue(data.uint32[0] == 8, 'then foo[1].a == 8')
+        self.assertTrue(data.uint32[1] == 7, 'then foo[1].b == 7')
+        self.assertTrue(fabs(data.float[2] - 3.14) < 1, 'foo[1].c == 3.14') # exploiting that sizeof(uint32) == sizeof(float)
 
         self.runCmd("n")
 
@@ -218,13 +215,13 @@
         # 11619 (Allow creating SBData values from arrays or primitives in Python)
 
         data2 = lldb.SBData.CreateDataFromCString(process.GetByteOrder(),process.GetAddressByteSize(),'hello!')
-        self.assertTrue(data2.GetUnsignedInt8(error,0) == 104, 'h == 104')
-        self.assertTrue(data2.GetUnsignedInt8(error,1) == 101, 'e == 101')
-        self.assertTrue(data2.GetUnsignedInt8(error,2) == 108, 'l == 108')
+        self.assertTrue(data2.uint8[0] == 104, 'h == 104')
+        self.assertTrue(data2.uint8[1] == 101, 'e == 101')
+        self.assertTrue(data2.uint8[2] == 108, 'l == 108')
         self.assertTrue(data2.GetUnsignedInt8(error,3) == 108, 'l == 108')
-        self.assertTrue(data2.GetUnsignedInt8(error,4) == 111, 'o == 111')
+        self.assertTrue(data2.uint8[4] == 111, 'o == 111')
         self.assertTrue(data2.GetUnsignedInt8(error,5) == 33, '! == 33')
-        self.assertTrue(data2.GetUnsignedInt8(error,6) == 0, 'binary 0 terminator')
+        self.assertTrue(data2.uint8[6] == 0, 'binary 0 terminator')
         
         data2 = lldb.SBData.CreateDataFromUInt64Array(process.GetByteOrder(),process.GetAddressByteSize(),[1,2,3,4,5])
         self.assertTrue(data2.GetUnsignedInt64(error,0) == 1, 'data2[0] = 1')
@@ -233,15 +230,15 @@
         self.assertTrue(data2.GetUnsignedInt64(error,24) == 4, 'data2[3] = 4')
         self.assertTrue(data2.GetUnsignedInt64(error,32) == 5, 'data2[4] = 5')
         
+        self.assertTrue(data2.uint64s == [1,2,3,4,5], 'read_data_helper failure: data2 == [1,2,3,4,5]')
+
         data2 = lldb.SBData.CreateDataFromSInt32Array(process.GetByteOrder(),process.GetAddressByteSize(),[2, -2])
-        self.assertTrue(data2.GetSignedInt32(error,0) == 2, 'signed32 data2[0] = 2')
-        self.assertTrue(data2.GetSignedInt32(error,4) == -2, 'signed32 data2[1] = -2')
+        self.assertTrue(data2.sint32[0:2] == [2,-2], 'signed32 data2 = [2,-2]')
         
         data2.Append(lldb.SBData.CreateDataFromSInt64Array(process.GetByteOrder(),process.GetAddressByteSize(),[2, -2]))
         self.assertTrue(data2.GetSignedInt32(error,0) == 2, 'signed32 data2[0] = 2')
         self.assertTrue(data2.GetSignedInt32(error,4) == -2, 'signed32 data2[1] = -2')
-        self.assertTrue(data2.GetSignedInt64(error,8) == 2, 'signed64 data2[0] = 2')
-        self.assertTrue(data2.GetSignedInt64(error,16) == -2, 'signed64 data2[1] = -2')
+        self.assertTrue(data2.sint64[1:3] == [2,-2], 'signed64 data2 = [2,-2]')
         
         data2 = lldb.SBData.CreateDataFromUInt32Array(process.GetByteOrder(),process.GetAddressByteSize(),[1,2,3,4,5])
         self.assertTrue(data2.GetUnsignedInt32(error,0) == 1, '32-bit data2[0] = 1')
@@ -273,6 +270,14 @@
         self.assertTrue(data2.GetUnsignedInt64(error,24) == 4, 'set data2[3] = 4')
         self.assertTrue(data2.GetUnsignedInt64(error,32) == 5, 'set data2[4] = 5')
 
+        self.assertTrue(data2.uint64[0] == 1, 'read_data_helper failure: set data2[0] = 1')
+        self.assertTrue(data2.uint64[1] == 2, 'read_data_helper failure: set data2[1] = 2')
+        self.assertTrue(data2.uint64[2] == 3, 'read_data_helper failure: set data2[2] = 3')
+        self.assertTrue(data2.uint64[3] == 4, 'read_data_helper failure: set data2[3] = 4')
+        self.assertTrue(data2.uint64[4] == 5, 'read_data_helper failure: set data2[4] = 5')
+
+        self.assertTrue(data2.uint64[0:2] == [1,2], 'read_data_helper failure: set data2[0:2] = [1,2]')
+
         data2.SetDataFromSInt32Array([2, -2])
         self.assertTrue(data2.GetSignedInt32(error,0) == 2, 'set signed32 data2[0] = 2')
         self.assertTrue(data2.GetSignedInt32(error,4) == -2, 'set signed32 data2[1] = -2')
@@ -288,11 +293,21 @@
         self.assertTrue(data2.GetUnsignedInt32(error,12) == 4, 'set 32-bit data2[3] = 4')
         self.assertTrue(data2.GetUnsignedInt32(error,16) == 5, 'set 32-bit data2[4] = 5')
         
+        self.assertTrue(data2.uint32[0] == 1, 'read_data_helper failure: set 32-bit data2[0] = 1')
+        self.assertTrue(data2.uint32[1] == 2, 'read_data_helper failure: set 32-bit data2[1] = 2')
+        self.assertTrue(data2.uint32[2] == 3, 'read_data_helper failure: set 32-bit data2[2] = 3')
+        self.assertTrue(data2.uint32[3] == 4, 'read_data_helper failure: set 32-bit data2[3] = 4')
+        self.assertTrue(data2.uint32[4] == 5, 'read_data_helper failure: set 32-bit data2[4] = 5')
+
         data2.SetDataFromDoubleArray([3.14,6.28,2.71])
         self.assertTrue( fabs(data2.GetDouble(error,0) - 3.14) < 0.5, 'set double data2[0] = 3.14')
         self.assertTrue( fabs(data2.GetDouble(error,8) - 6.28) < 0.5, 'set double data2[1] = 6.28')
         self.assertTrue( fabs(data2.GetDouble(error,16) - 2.71) < 0.5, 'set double data2[2] = 2.71')
 
+        self.assertTrue( fabs(data2.double[0] - 3.14) < 0.5, 'read_data_helper failure: set double data2[0] = 3.14')
+        self.assertTrue( fabs(data2.double[1] - 6.28) < 0.5, 'read_data_helper failure: set double data2[1] = 6.28')
+        self.assertTrue( fabs(data2.double[2] - 2.71) < 0.5, 'read_data_helper failure: set double data2[2] = 2.71')
+
 if __name__ == '__main__':
     import atexit
     lldb.SBDebugger.Initialize()





More information about the lldb-commits mailing list