예제 #1
0
        public static CorDebugClass ClassFromRuntimeValue(RuntimeValue rtv, CorDebugAppDomain appDomain)
        {
            RuntimeValue_Reflection rtvf = rtv as RuntimeValue_Reflection;
            CorDebugClass           cls  = null;
            object objBuiltInKey         = null;

            Debug.Assert(!rtv.IsNull);

            if (rtvf != null)
            {
                objBuiltInKey = rtvf.ReflectionType;
            }
            else if (rtv.DataType == RuntimeDataType.DATATYPE_TRANSPARENT_PROXY)
            {
                objBuiltInKey = RuntimeDataType.DATATYPE_TRANSPARENT_PROXY;
            }
            else
            {
                cls = TinyCLR_TypeSystem.CorDebugClassFromTypeIndex(rtv.Type, appDomain);
            }

            if (objBuiltInKey != null)
            {
                CorDebugProcess.BuiltinType builtInType = appDomain.Process.ResolveBuiltInType(objBuiltInKey);

                cls = builtInType.GetClass(appDomain);

                if (cls == null)
                {
                    cls = new CorDebugClass(builtInType.GetAssembly(appDomain), builtInType.TokenCLR);
                }
            }

            return(cls);
        }
예제 #2
0
 protected internal RuntimeValue_Indirect(Engine eng, WireProtocol.Commands.Debugging_Value[] array, int pos) : base(eng, array[pos])
 {
     if (++pos < array.Length)
     {
         m_value = Convert(eng, array, pos);
     }
 }
예제 #3
0
		public static CorDebugClass ClassFromRuntimeValue (RuntimeValue rtv, CorDebugAppDomain appDomain)
		{
			RuntimeValue_Reflection rtvf = rtv as RuntimeValue_Reflection;
			CorDebugClass cls = null;
			object objBuiltInKey = null;
			Debug.Assert (!rtv.IsNull);

			if (rtvf != null) {
				objBuiltInKey = rtvf.ReflectionType;
			} else if (rtv.DataType == RuntimeDataType.DATATYPE_TRANSPARENT_PROXY) {
				objBuiltInKey = RuntimeDataType.DATATYPE_TRANSPARENT_PROXY;
			} else {
				cls = TinyCLR_TypeSystem.CorDebugClassFromTypeIndex (rtv.Type, appDomain);
			}

			if (objBuiltInKey != null) {                
				CorDebugProcess.BuiltinType builtInType = appDomain.Process.ResolveBuiltInType (objBuiltInKey);             
                
				cls = builtInType.GetClass (appDomain);

				if (cls == null) {
					cls = new CorDebugClass (builtInType.GetAssembly (appDomain), builtInType.TokenCLR);
				}                
			}

			return cls;
		}
 protected internal RuntimeValue_Indirect( Engine eng, WireProtocol.Commands.Debugging_Value[] array, int pos ) : base( eng, array[pos] )
 {
     if(++pos < array.Length)
     {
         m_value = Convert( eng, array, pos );
     }
 }
예제 #5
0
        private bool IsValuePrimitive()
        {
            if (m_fIsBoxed || m_fIsEnum)
            {
                if (m_valuePrimitive == null)
                {
                    if (m_rtv.IsBoxed)
                    {
                        RuntimeValue rtv = m_rtv.GetField(1, 0);

                        Debug.Assert(rtv.IsPrimitive);

                        //Assert that m_class really points to a primitive
                        m_valuePrimitive = (CorDebugValuePrimitive)CreateValue(rtv);
                    }
                    else
                    {
                        Debug.Assert(m_fIsEnum);
                        m_valuePrimitive = new CorDebugValuePrimitive(m_rtv, m_appDomain);
                        Debug.Assert(m_rtv.IsPrimitive);
                    }
                }
            }

            return(m_valuePrimitive != null);
        }
예제 #6
0
 //Object or CLASS, or VALUETYPE
 public CorDebugValueObject(RuntimeValue rtv, CorDebugAppDomain appDomain) : base(rtv, appDomain)
 {
     if (!rtv.IsNull)
     {
         m_class    = CorDebugValue.ClassFromRuntimeValue(rtv, appDomain);
         m_fIsEnum  = m_class.IsEnum;
         m_fIsBoxed = rtv.IsBoxed;
     }
 }
예제 #7
0
		public static CorDebugValue[] CreateValues (RuntimeValue[] rtv, CorDebugAppDomain appDomain)
		{
			CorDebugValue[] values = new CorDebugValue[rtv.Length];
			for (int i = 0; i < rtv.Length; i++) {
				values [i] = CorDebugValue.CreateValue (rtv [i], appDomain);
			}

			return values;
		}
        int ICorDebugObjectValue.GetFieldValue(ICorDebugClass pClass, uint fieldDef, out ICorDebugValue ppValue)
        {
            //cache fields?
            RuntimeValue rtv = m_rtv.GetField(0, TinyCLR_TypeSystem.ClassMemberIndexFromCLRToken(fieldDef, ((CorDebugClass)pClass).Assembly));

            ppValue = CreateValue(rtv);

            return(Utility.COM_HResults.S_OK);
        }
        int ICorDebugReferenceValue.SetValue(ulong value)
        {
            Debug.Assert(value <= uint.MaxValue);
            RuntimeValue rtvNew = m_rtv.Assign((uint)value);

            this.RuntimeValue = rtvNew;

            return(Utility.COM_HResults.S_OK);
        }
예제 #10
0
        public static CorDebugValue CreateValue(RuntimeValue rtv, CorDebugAppDomain appDomain)
        {
            CorDebugValue val = null;
            bool fIsReference;
            
            if (rtv.IsBoxed)
            {
                val = new CorDebugValueBoxedObject (rtv, appDomain);
                fIsReference = true;
            }
            else if (rtv.IsPrimitive)
            {
                CorDebugClass c = ClassFromRuntimeValue (rtv, appDomain);
    
                if (c.IsEnum)
                {
                    val = new CorDebugValueObject (rtv, appDomain);
                    fIsReference = false;
                }
                else
                {
                    val = new CorDebugValuePrimitive (rtv, appDomain);
                    fIsReference = false;
                }
            }
            else if (rtv.IsArray)
            {
                val = new CorDebugValueArray (rtv, appDomain);
                fIsReference = true;
            }
            else if (rtv.CorElementType == CorElementType.ELEMENT_TYPE_STRING)
            {
                val = new CorDebugValueString (rtv, appDomain);
                fIsReference = true;
            }
            else
            {
                val = new CorDebugValueObject (rtv, appDomain);
                fIsReference = !rtv.IsValueType;
            }
            
            if (fIsReference)
            {
                val = new CorDebugValueReference(val, val.m_rtv, val.m_appDomain);
            }

            if (rtv.IsReference)    //CorElementType.ELEMENT_TYPE_BYREF
            {
                val = new CorDebugValueReferenceByRef(val, val.m_rtv, val.m_appDomain);
            }

            return val;        
        }
예제 #11
0
        public static CorDebugValue CreateValue(RuntimeValue rtv, CorDebugAppDomain appDomain)
        {
            CorDebugValue val = null;
            bool          fIsReference;

            if (rtv.IsBoxed)
            {
                val          = new CorDebugValueBoxedObject(rtv, appDomain);
                fIsReference = true;
            }
            else if (rtv.IsPrimitive)
            {
                CorDebugClass c = ClassFromRuntimeValue(rtv, appDomain);

                if (c.IsEnum)
                {
                    val          = new CorDebugValueObject(rtv, appDomain);
                    fIsReference = false;
                }
                else
                {
                    val          = new CorDebugValuePrimitive(rtv, appDomain);
                    fIsReference = false;
                }
            }
            else if (rtv.IsArray)
            {
                val          = new CorDebugValueArray(rtv, appDomain);
                fIsReference = true;
            }
            else if (rtv.CorElementType == CorElementType.ELEMENT_TYPE_STRING)
            {
                val          = new CorDebugValueString(rtv, appDomain);
                fIsReference = true;
            }
            else
            {
                val          = new CorDebugValueObject(rtv, appDomain);
                fIsReference = !rtv.IsValueType;
            }

            if (fIsReference)
            {
                val = new CorDebugValueReference(val, val.m_rtv, val.m_appDomain);
            }

            if (rtv.IsReference)                  //CorElementType.ELEMENT_TYPE_BYREF
            {
                val = new CorDebugValueReferenceByRef(val, val.m_rtv, val.m_appDomain);
            }

            return(val);
        }
예제 #12
0
        int ICorDebugClass.GetStaticFieldValue(uint fieldDef, ICorDebugFrame pFrame, out ICorDebugValue ppValue)
        {
            //Cache, and invalidate when necessary???
            uint fd = TinyCLR_TypeSystem.ClassMemberIndexFromCLRToken(fieldDef, this.Assembly);

            this.Process.SetCurrentAppDomain(this.AppDomain);
            RuntimeValue rtv = this.Engine.GetStaticFieldValue(fd);

            ppValue = CorDebugValue.CreateValue(rtv, this.AppDomain);

            return(Utility.COM_HResults.S_OK);
        }
예제 #13
0
        int ICorDebugThread.GetObject(out ICorDebugValue ppObject)
        {
            Debug.Assert(!IsVirtualThread);

            RuntimeValue rv = Engine.GetThread(m_id);

            if (rv != null)
            {
                ppObject = CorDebugValue.CreateValue(rv, this.AppDomain);
            }
            else
            {
                ppObject = null;
            }

            return(Utility.COM_HResults.S_OK);
        }
예제 #14
0
        public RuntimeValue Assign(RuntimeValue val)
        {
            RuntimeValue retval = null;

            if (this.IsReflection || (val != null && val.IsReflection))
            {
                byte[] data = new byte[8];
                uint   dt   = (uint)RuntimeDataType.DATATYPE_OBJECT;

                if (val != null)
                {
                    dt = val.m_handle.m_dt;
                    Array.Copy(val.m_handle.m_builtinValue, data, data.Length);
                }

                if (SetBlock(dt, data))
                {
                    retval = this;
                }
            }
            else if (this.IsPrimitive)
            {
                if (val == null || val.IsPrimitive == false)
                {
                    throw new InvalidCastException("The two runtime values are incompatible");
                }

                this.Value = val.Value;

                retval = this;
            }
            else
            {
                if (val != null && val.IsPrimitive == true)
                {
                    throw new InvalidCastException("The two runtime values are incompatible");
                }

                retval = Assign(val != null ? val.ReferenceIdDirect : 0);
            }

            return(retval);
        }
예제 #15
0
 public CorDebugValueReference(CorDebugValue val, RuntimeValue rtv, CorDebugAppDomain appDomain)
     : base(rtv, appDomain)
 {
     m_value = val;
 }
예제 #16
0
 public CorDebugValueBoxedObject(RuntimeValue rtv, CorDebugAppDomain appDomain) : base(rtv, appDomain)
 {
     m_value = new CorDebugValueObject(rtv, appDomain);
 }
예제 #17
0
 public CorDebugValueArray(RuntimeValue rtv, CorDebugAppDomain appDomain) : base(rtv, appDomain)
 {
 }
예제 #18
0
		public CorDebugValueString (RuntimeValue rtv, CorDebugAppDomain appDomain)
            : base (rtv, appDomain)
		{
		}
예제 #19
0
        public RuntimeValue Assign( RuntimeValue val )
        {
            RuntimeValue retval = null;

            if(this.IsReflection || (val != null && val.IsReflection))
            {
                byte[] data = new byte[8];
                uint dt = (uint)RuntimeDataType.DATATYPE_OBJECT;

                if(val != null)
                {
                    dt = val.m_handle.m_dt;
                    Array.Copy( val.m_handle.m_builtinValue, data, data.Length );
                }

                if(SetBlock( dt, data ))
                {
                    retval = this;
                }             
            }
            else if(this.IsPrimitive)
            {
                if(val == null || val.IsPrimitive == false)
                {
                    throw new InvalidCastException( "The two runtime values are incompatible" );
                }

                this.Value = val.Value;

                retval = this;
            }
            else
            {
                if(val != null && val.IsPrimitive == true)
                {
                    throw new InvalidCastException( "The two runtime values are incompatible" );
                }

                retval = Assign( val != null ? val .ReferenceIdDirect : 0 );
            }

            return retval;
        }
        public RuntimeValue[] GetStackFrameValueAll(uint pid, uint depth, uint cValues, StackValueKind kind)
        {
            WireProtocol.OutgoingMessage[] cmds = new WireProtocol.OutgoingMessage[cValues];
            RuntimeValue[] vals = null;
            uint i;

            for (i = 0; i < cValues; i++)
            {
                cmds[i] = CreateMessage_GetValue_Stack(pid, depth, kind, i);
            }

            WireProtocol.IncomingMessage[] replies = SyncMessages(cmds);
            if (replies != null)
            {
                vals = new RuntimeValue[cValues];

                for (i = 0; i < cValues; i++)
                {
                    WireProtocol.Commands.Debugging_Value_Reply reply = replies[i].Payload as WireProtocol.Commands.Debugging_Value_Reply;
                    if (reply != null)
                    {
                        vals[i] = RuntimeValue.Convert(this, reply.m_values);
                    }
                }
            }

            return vals;
        }
예제 #21
0
		public CorDebugValueBoxedObject (RuntimeValue rtv, CorDebugAppDomain appDomain) : base (rtv, appDomain)
		{
			m_value = new CorDebugValueObject (rtv, appDomain);  
		}
예제 #22
0
 protected CorDebugValue CreateValue(RuntimeValue rtv)
 {
     return(CorDebugValue.CreateValue(rtv, m_appDomain));
 }
예제 #23
0
		protected CorDebugValue CreateValue (RuntimeValue rtv)
		{
			return CorDebugValue.CreateValue (rtv, m_appDomain);
		}
예제 #24
0
		public CorDebugValuePrimitive (RuntimeValue rtv, CorDebugAppDomain appDomain) : base (rtv, appDomain)
		{
		}
예제 #25
0
 public CorDebugGenericType(CorElementType elemType, RuntimeValue rtv, CorDebugAppDomain appDomain)
 {
     m_elemType  = elemType;
     m_rtv       = rtv;
     m_appDomain = appDomain;
 }
예제 #26
0
 public CorDebugValueReferenceByRef(CorDebugValue val, RuntimeValue rtv, CorDebugAppDomain appDomain) : base(val, rtv, appDomain)
 {
 }
예제 #27
0
 public CorDebugGenericType(CorElementType elemType, RuntimeValue rtv, CorDebugAppDomain appDomain)
 { 
     m_elemType = elemType;
     m_rtv = rtv;
     m_appDomain = appDomain; 
 }
예제 #28
0
		public CorDebugValue (RuntimeValue rtv, CorDebugAppDomain appDomain)
		{
			m_rtv = rtv;                                  
			m_appDomain = appDomain;
		}
예제 #29
0
		public CorDebugValueReference (CorDebugValue val, RuntimeValue rtv, CorDebugAppDomain appDomain)
            : base (rtv, appDomain)
		{
			m_value = val;
		}
예제 #30
0
 public CorDebugValuePrimitive(RuntimeValue rtv, CorDebugAppDomain appDomain) : base(rtv, appDomain)
 {
 }
예제 #31
0
		public CorDebugValueReferenceByRef (CorDebugValue val, RuntimeValue rtv, CorDebugAppDomain appDomain) : base (val, rtv, appDomain)
		{                    
		}
예제 #32
0
 public CorDebugValue(RuntimeValue rtv, CorDebugAppDomain appDomain)
 {
     m_rtv       = rtv;
     m_appDomain = appDomain;
 }
예제 #33
0
		public CorDebugValueArray (RuntimeValue rtv, CorDebugAppDomain appDomain) : base (rtv, appDomain)
		{
		}
        internal RuntimeValue GetFieldValue(RuntimeValue val, uint offset, uint fd)
        {
            WireProtocol.Commands.Debugging_Value_GetField cmd = new WireProtocol.Commands.Debugging_Value_GetField();

            cmd.m_heapblock = (val == null ? 0 : val.m_handle.m_referenceID);
            cmd.m_offset = offset;
            cmd.m_fd = fd;

            return GetRuntimeValue(WireProtocol.Commands.c_Debugging_Value_GetField, cmd);
        }
예제 #35
0
		//Object or CLASS, or VALUETYPE
		public CorDebugValueObject (RuntimeValue rtv, CorDebugAppDomain appDomain) : base (rtv, appDomain)
		{
			if (!rtv.IsNull) {
				m_class = CorDebugValue.ClassFromRuntimeValue (rtv, appDomain);
				m_fIsEnum = m_class.IsEnum;
				m_fIsBoxed = rtv.IsBoxed;                
			}
		}
        public uint GetVirtualMethod(uint md, RuntimeValue obj)
        {
            WireProtocol.Commands.Debugging_Resolve_VirtualMethod cmd = new WireProtocol.Commands.Debugging_Resolve_VirtualMethod();

            cmd.m_md = md;
            cmd.m_obj = obj.ReferenceId;

            WireProtocol.IncomingMessage reply = SyncMessage(WireProtocol.Commands.c_Debugging_Resolve_VirtualMethod, 0, cmd);
            if (reply != null)
            {
                WireProtocol.Commands.Debugging_Resolve_VirtualMethod.Reply cmdReply = reply.Payload as WireProtocol.Commands.Debugging_Resolve_VirtualMethod.Reply;

                if (cmdReply != null)
                {
                    return cmdReply.m_md;
                }
            }

            return 0;
        }
예제 #37
0
 public CorDebugValueString(RuntimeValue rtv, CorDebugAppDomain appDomain)
     : base(rtv, appDomain)
 {
 }