예제 #1
0
        private uint GetByRefTypeIndex(TypeDesc pointeeType)
        {
            uint typeIndex;

            if (_byRefTypes.TryGetValue(pointeeType, out typeIndex))
            {
                return(typeIndex);
            }

            PointerTypeDescriptor descriptor = new PointerTypeDescriptor();

            descriptor.ElementType = GetVariableTypeIndex(pointeeType, false);
            descriptor.Is64Bit     = Is64Bit ? 1 : 0;
            descriptor.IsConst     = 0;
            descriptor.IsReference = 1;

            // Calling GetVariableTypeIndex may have filled in _byRefTypes
            if (_byRefTypes.TryGetValue(pointeeType, out typeIndex))
            {
                return(typeIndex);
            }

            typeIndex = _objectWriter.GetPointerTypeIndex(descriptor);
            _byRefTypes.Add(pointeeType, typeIndex);
            return(typeIndex);
        }
예제 #2
0
        private uint GetVariableTypeIndex(TypeDesc type, bool needsCompleteIndex)
        {
            uint variableTypeIndex = 0;

            if (type.IsPrimitive)
            {
                variableTypeIndex = GetPrimitiveTypeIndex(type);
            }
            else
            {
                type = DebuggerCanonicalize(type);

                if ((type.IsDefType && !type.IsValueType) || type.IsArray)
                {
                    // The type index of a variable/field of a reference type is wrapped
                    // in a pointer, as these fields are really pointer fields, and the data is on the heap
                    variableTypeIndex = 0;
                    if (_knownReferenceWrappedTypes.TryGetValue(type, out variableTypeIndex))
                    {
                        return(variableTypeIndex);
                    }
                    else
                    {
                        uint typeindex = GetTypeIndex(type, false);

                        PointerTypeDescriptor descriptor = new PointerTypeDescriptor();
                        descriptor.ElementType = typeindex;
                        descriptor.Is64Bit     = Is64Bit ? 1 : 0;
                        descriptor.IsConst     = 0;
                        descriptor.IsReference = 1;

                        variableTypeIndex = _objectWriter.GetPointerTypeIndex(descriptor);
                        _knownReferenceWrappedTypes[type] = variableTypeIndex;

                        return(variableTypeIndex);
                    }
                }
                else if (type.IsEnum)
                {
                    // Enum's use the LF_ENUM record as the variable type index, but it is required to also emit a regular structure record for them.

                    if (_enumTypes.TryGetValue(type, out variableTypeIndex))
                    {
                        return(variableTypeIndex);
                    }

                    variableTypeIndex = GetEnumTypeIndex(type);

                    GetTypeIndex(type, false); // Ensure regular structure record created

                    _enumTypes[type] = variableTypeIndex;

                    return(variableTypeIndex);
                }

                variableTypeIndex = GetTypeIndex(type, needsCompleteIndex);
            }
            return(variableTypeIndex);
        }
예제 #3
0
        private void InsertStaticFieldRegionMember(List <DataFieldDescriptor> fieldDescs, DefType defType, List <DataFieldDescriptor> staticFields, string staticFieldForm, string staticFieldFormTypePrefix, bool staticDataInObject)
        {
            if (staticFields != null && (staticFields.Count > 0))
            {
                // Generate struct symbol for type describing individual fields of the statics region
                ClassFieldsTypeDescriptor fieldsDescriptor = new ClassFieldsTypeDescriptor
                {
                    Size        = (ulong)0,
                    FieldsCount = staticFields.Count
                };

                ClassTypeDescriptor classTypeDescriptor = new ClassTypeDescriptor
                {
                    IsStruct    = !staticDataInObject ? 1 : 0,
                    Name        = staticFieldFormTypePrefix + _objectWriter.GetMangledName(defType),
                    BaseClassId = 0
                };

                if (staticDataInObject)
                {
                    classTypeDescriptor.BaseClassId = GetTypeIndex(defType.Context.GetWellKnownType(WellKnownType.Object), true);
                }

                uint staticFieldRegionTypeIndex       = _objectWriter.GetCompleteClassTypeIndex(classTypeDescriptor, fieldsDescriptor, staticFields.ToArray());
                uint staticFieldRegionSymbolTypeIndex = staticFieldRegionTypeIndex;

                // This means that access to this static region is done via a double indirection
                if (staticDataInObject)
                {
                    PointerTypeDescriptor pointerTypeDescriptor = new PointerTypeDescriptor();
                    pointerTypeDescriptor.Is64Bit     = Is64Bit ? 1 : 0;
                    pointerTypeDescriptor.IsConst     = 0;
                    pointerTypeDescriptor.IsReference = 0;
                    pointerTypeDescriptor.ElementType = staticFieldRegionTypeIndex;

                    uint intermediatePointerDescriptor = _objectWriter.GetPointerTypeIndex(pointerTypeDescriptor);
                    pointerTypeDescriptor.ElementType = intermediatePointerDescriptor;
                    staticFieldRegionSymbolTypeIndex  = _objectWriter.GetPointerTypeIndex(pointerTypeDescriptor);
                }

                DataFieldDescriptor staticRegionField = new DataFieldDescriptor
                {
                    FieldTypeIndex = staticFieldRegionSymbolTypeIndex,
                    Offset         = 0xFFFFFFFF,
                    Name           = staticFieldForm
                };

                fieldDescs.Add(staticRegionField);
            }
        }
예제 #4
0
        // Get Type index for this pointer of specified type
        public uint GetThisTypeIndex(TypeDesc type)
        {
            lock (_lock)
            {
                uint typeIndex;

                if (_thisTypes.TryGetValue(type, out typeIndex))
                {
                    return(typeIndex);
                }

                PointerTypeDescriptor descriptor = new PointerTypeDescriptor();
                // Note the use of GetTypeIndex here instead of GetVariableTypeIndex (We need the type exactly, not a reference to the type (as would happen for arrays/classes), and not a primitive value (as would happen for primitives))
                descriptor.ElementType = GetTypeIndex(type, true);
                descriptor.Is64Bit     = Is64Bit ? 1 : 0;
                descriptor.IsConst     = 1;
                descriptor.IsReference = 0;

                typeIndex = _objectWriter.GetPointerTypeIndex(descriptor);
                _thisTypes.Add(type, typeIndex);
                return(typeIndex);
            }
        }
예제 #5
0
 uint ITypesDebugInfoWriter.GetPointerTypeIndex(PointerTypeDescriptor pointerDescriptor)
 {
     return(_dbgInfoWriter.GetPointerTypeIndex(pointerDescriptor));
 }
예제 #6
0
 uint ITypesDebugInfoWriter.GetPointerTypeIndex(PointerTypeDescriptor pointerDescriptor)
 {
     return(GetPointerTypeIndex(_nativeObjectWriter, pointerDescriptor));
 }
예제 #7
0
 private static extern uint GetPointerTypeIndex(IntPtr objWriter, PointerTypeDescriptor pointerDescriptor);