Esempio n. 1
0
        public static ArrayInfo GetArrayInfo(CachedSnapshot data, BytesAndOffset arrayData, int iTypeDescriptionArrayType)
        {
            var virtualMachineInformation = data.virtualMachineInformation;
            var arrayInfo = new ArrayInfo();

            arrayInfo.baseAddress          = 0;
            arrayInfo.arrayTypeDescription = iTypeDescriptionArrayType;


            arrayInfo.header = arrayData;
            arrayInfo.data   = arrayInfo.header.Add(virtualMachineInformation.arrayHeaderSize);
            ulong bounds;

            arrayInfo.header.Add(virtualMachineInformation.arrayBoundsOffsetInHeader).TryReadPointer(out bounds);

            if (bounds == 0)
            {
                arrayInfo.length = arrayInfo.header.Add(virtualMachineInformation.arraySizeOffsetInHeader).ReadInt32();
                arrayInfo.rank   = new int[1] {
                    arrayInfo.length
                };
            }
            else
            {
                var cursor = data.managedHeapSections.Find(bounds, virtualMachineInformation);
                int rank   = data.typeDescriptions.GetRank(iTypeDescriptionArrayType);
                arrayInfo.rank   = new int[rank];
                arrayInfo.length = 1;
                for (int i = 0; i != rank; i++)
                {
                    var l = cursor.ReadInt32();
                    arrayInfo.length *= l;
                    arrayInfo.rank[i] = l;
                    cursor            = cursor.Add(8);
                }
            }

            arrayInfo.elementTypeDescription = data.typeDescriptions.baseOrElementTypeIndex[iTypeDescriptionArrayType];
            if (arrayInfo.elementTypeDescription == -1) //We currently do not handle uninitialized types as such override the type, making it return pointer size
            {
                arrayInfo.elementTypeDescription = iTypeDescriptionArrayType;
            }
            if (data.typeDescriptions.HasFlag(arrayInfo.elementTypeDescription, TypeFlags.kValueType))
            {
                arrayInfo.elementSize = data.typeDescriptions.size[arrayInfo.elementTypeDescription];
            }
            else
            {
                arrayInfo.elementSize = virtualMachineInformation.pointerSize;
            }
            return(arrayInfo);
        }
Esempio n. 2
0
        public ObjectData GetArrayElement(CachedSnapshot snapshot, ArrayInfo ai, int index, bool expandToTarget)
        {
            switch (m_dataType)
            {
            case ObjectDataType.Array:
            case ObjectDataType.ReferenceArray:
                break;

            default:
                Debug.Log("Requesting an array element on an invalid data type");
                return(invalid);
            }
            ObjectData o = new ObjectData();

            o.m_Parent = new ObjectDataParent(this, -1, index, expandToTarget);
            o.SetManagedType(snapshot, ai.elementTypeDescription);
            o.m_data.managed.objectPtr = m_data.managed.objectPtr;
            o.m_dataType        = TypeToSubDataType(snapshot, ai.elementTypeDescription);
            o.managedObjectData = ai.GetArrayElement(index);
            return(o);
        }