Ejemplo n.º 1
0
        internal TargetClassObject GetCurrentObject(TargetMemoryAccess target,
                                                    TargetLocation location)
        {
            // location.Address resolves to the address of the MonoObject,
            // dereferencing it once gives us the vtable, dereferencing it
            // twice the class.
            TargetAddress address;

            address = target.ReadAddress(location.GetAddress(target));
            address = target.ReadAddress(address);

            TargetType current = File.MonoLanguage.ReadMonoClass(target, address);

            if (current == null)
            {
                return(null);
            }

            if (IsByRef && !current.IsByRef)             // Unbox
            {
                location = location.GetLocationAtOffset(
                    2 * target.TargetMemoryInfo.TargetAddressSize);
            }

            return((TargetClassObject)current.GetObject(target, location));
        }
Ejemplo n.º 2
0
        internal TargetObject GetInstanceField(TargetMemoryAccess target,
                                               TargetStructObject instance,
                                               TargetFieldInfo field)
        {
            GetFields(target);

            int        offset = field_offsets [field.Position];
            TargetType type   = field_types [field.Position];

            if (!Type.IsByRef)
            {
                offset -= 2 * target.TargetMemoryInfo.TargetAddressSize;
            }
            TargetLocation field_loc = instance.Location.GetLocationAtOffset(offset);

            TargetAddress orig_addr = field_loc.GetAddress(target);

            if (type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            TargetAddress addr = field_loc.GetAddress(target);

            if (field_loc.HasAddress && field_loc.GetAddress(target).IsNull)
            {
                return(new TargetNullObject(type));
            }

            return(type.GetObject(target, field_loc));
        }
Ejemplo n.º 3
0
        internal TargetObject GetStaticField(TargetMemoryAccess target, TargetFieldInfo field,
                                             TargetAddress data_address)
        {
            GetFields(target);

            int        offset = field_offsets [field.Position];
            TargetType type   = field_types [field.Position];

            TargetLocation location  = new AbsoluteTargetLocation(data_address);
            TargetLocation field_loc = location.GetLocationAtOffset(offset);

            if (type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            return(type.GetObject(target, field_loc));
        }
Ejemplo n.º 4
0
        internal override TargetObject GetObject(StackFrame frame,
                                                 TargetMemoryAccess target)
        {
            TargetLocation location = GetLocation(frame, target);

            if (location == null)
            {
                throw new LocationInvalidException();
            }

            if (location.HasAddress && location.GetAddress(target).IsNull)
            {
                TargetLocation null_loc = new AbsoluteTargetLocation(TargetAddress.Null);
                return(new TargetNullObject(type));
            }

            return(type.GetObject(target, location));
        }
Ejemplo n.º 5
0
        internal override TargetObject GetDereferencedObject(TargetMemoryAccess target)
        {
            TargetType current_type = GetCurrentType(target);

            if (current_type == null)
            {
                return(null);
            }

            // If this is a reference type, then the `MonoObject *' already
            // points to the boxed object itself.
            // If it's a valuetype, then the boxed contents is immediately
            // after the `MonoObject' header.

            int            offset       = current_type.IsByRef ? 0 : type.Size;
            TargetLocation new_location = Location.GetLocationAtOffset(offset);
            TargetObject   obj          = current_type.GetObject(target, new_location);

            return(obj);
        }
Ejemplo n.º 6
0
        protected override TargetObject DoGetObject(TargetMemoryAccess target,
                                                    TargetLocation location)
        {
            if (target_type == null)
            {
                target_type = language.LookupType(TargetName);
            }

            if (target_type == null)
            {
                return(null);
            }

            TargetObject obj = target_type.GetObject(target, location);

            if (obj == null)
            {
                return(null);
            }

            obj.SetTypeName(Name);
            return(obj);
        }