private CorDebugValue GetResultValue ()
        {
            if (m_resultValue == null)
            {
                m_resultValue = Process.ScratchPad.GetValue (m_iScratchPad, m_appDomain);
            }

            return m_resultValue;
        }
		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;
		}
        private CorDebugValue GetResultValue()
        {
            if (m_resultValue == null)
            {
                m_resultValue = Process.ScratchPad.GetValue(m_iScratchPad, m_appDomain);
            }

            return(m_resultValue);
        }
Beispiel #4
0
        private CorDebugValue[] EnsureValues(ref CorDebugValue[] values, uint cInfo, Engine.StackValueKind kind)
        {
            if (values == null)
            {
                values = CorDebugValue.CreateValues(this.Engine.GetStackFrameValueAll(m_chain.Thread.ID, this.DepthTinyCLR, cInfo, kind), this.Process);
            }

            return(values);
        }
Beispiel #5
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;
     }
 }
Beispiel #6
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);
        }
Beispiel #7
0
		public void Reload ()
		{
			if (loader != null) {
				// Obsolete value, get a new one
				CorDebugValue v = loader ();
				version = MicroFrameworkDebuggerSession.EvaluationTimestamp;
				if (v != null)
					val = v;
			}
		}
        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);
        }
Beispiel #9
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);
        }
 public void ResumingExecution()
 {
     if (IsSuspended)
     {
         RefreshChain();
     }
     else
     {
         m_chain            = null;
         m_currentException = null;
     }
 }
        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);
        }
 public void StoppedOnException()
 {
     m_currentException = CorDebugValue.CreateValue(Engine.GetThreadException(m_id), this.AppDomain);
 }
 int ICorDebugType.GetClass(out ICorDebugClass ppClass)
 {
     ppClass = CorDebugValue.ClassFromRuntimeValue(m_ValueArray.RuntimeValue, m_ValueArray.AppDomain);
     return(Utility.COM_HResults.S_OK);
 }
		public CorDebugValue RuntimeInvoke (CorEvaluationContext corEvaluationContext, CorDebugFunction function, CorDebugType[] typeArgs, CorDebugValue thisObj, CorDebugValue[] arguments)
		{
			return null;
		}
		public void StoppedOnException ()
		{
			m_currentException = CorDebugValue.CreateValue (Engine.GetThreadException (m_id), this.AppDomain);
		}
 private void ResetScratchPadLocation()
 {
     m_iScratchPad = SCRATCH_PAD_INDEX_NOT_INITIALIZED;
     m_resultValue = null;
 }
 private void ResetScratchPadLocation()
 {
     m_iScratchPad = SCRATCH_PAD_INDEX_NOT_INITIALIZED;
     m_resultValue = null;            
 }
Beispiel #18
0
		public CorValRef (CorDebugValue val)
		{
			this.val = val;
			this.version = MicroFrameworkDebuggerSession.EvaluationTimestamp;
		}
Beispiel #19
0
 public CorDebugValueReferenceByRef(CorDebugValue val, RuntimeValue rtv, CorDebugAppDomain appDomain) : base(val, rtv, appDomain)
 {
 }
Beispiel #20
0
 public CorDebugValueReference(CorDebugValue val, RuntimeValue rtv, CorDebugAppDomain appDomain)
     : base(rtv, appDomain)
 {
     m_value = val;
 }
Beispiel #21
0
 protected CorDebugValue CreateValue(RuntimeValue rtv)
 {
     return(CorDebugValue.CreateValue(rtv, m_appDomain));
 }
        int ICorDebugEval.CallFunction(ICorDebugFunction pFunction, uint nArgs, ICorDebugValue[] ppArgs)
        {
            try
            {
                //CreateThread will cause a thread create event to occur.  This is a virtual thread, so
                //we need to suspend processing of tinyclr commands until we have created the thread ourselves
                //and the processing of a new virtual thread will be ignored.
                Process.SuspendCommands(true);

                //need to flush the breakpoints in case new breakpoints were waiting until process was resumed.
                Process.UpdateBreakpoints();

                Debug.Assert(nArgs == ppArgs.Length);
                Debug.Assert(Process.IsExecutionPaused);

                CorDebugFunction function = (CorDebugFunction)pFunction;

                uint md = function.MethodDef_Index;
                if (function.IsVirtual && function.IsInstance)
                {
                    Debug.Assert(nArgs > 0);
                    md = this.Engine.GetVirtualMethod(function.MethodDef_Index, ((CorDebugValue)ppArgs[0]).RuntimeValue);
                }

                this.Process.SetCurrentAppDomain(this.AppDomain);
                //Send the selected thread ID to the device so calls that use Thread.CurrentThread work as the user expects.
                uint pid = this.Engine.CreateThread(md, GetScratchPadLocation(), m_threadReal.ID);

                if (pid == uint.MaxValue)
                {
                    throw new ArgumentException("TinyCLR cannot call this function.  Possible reasons include: ByRef arguments not supported");
                }

                //If anything below fails, we need to clean up by killing the thread
                if (nArgs > 0)
                {
                    RuntimeValue[] args = this.Engine.GetStackFrameValueAll(pid, 0, function.NumArg, Engine.StackValueKind.Argument);

                    for (int iArg = 0; iArg < nArgs; iArg++)
                    {
                        CorDebugValue valSrc = (CorDebugValue)ppArgs[iArg];
                        CorDebugValue valDst = CorDebugValue.CreateValue(args[iArg], m_appDomain);

                        if (valDst.RuntimeValue.Assign(valSrc.RuntimeValue) == null)
                        {
                            throw new ArgumentException("TinyCLR cannot set argument " + iArg);
                        }
                    }
                }

                m_threadVirtual = new CorDebugThread(this.Process, pid, this);
                m_threadReal.AttachVirtualThread(m_threadVirtual);
                Debug.Assert(!m_fActive);
                m_fActive = true;

                //It is possible that a hard breakpoint is hit, the first line of the function
                //to evaluate.  If that is the case, than breakpoints need to be drained so the
                //breakpoint event is fired, to avoid a race condition, where cpde resumes
                //execution to start the function eval before it gets the breakpoint event
                //This is primarily due to the difference in behavior of the TinyCLR and the desktop.
                //In the desktop, the hard breakpoint will not get hit until execution is resumed.
                //The TinyCLR can hit the breakpoint during the Thread_Create call.

                Process.DrainBreakpoints();
            }
            finally
            {
                Process.SuspendCommands(false);
            }

            return(Utility.COM_HResults.S_OK);
        }
		public CorDebugValue RuntimeInvoke (CorDebugFunction function, CorDebugType[] typeArgs, CorDebugValue thisObj, CorDebugValue[] arguments)
		{
			return Session.RuntimeInvoke (this, function, typeArgs, thisObj, arguments);
		}
Beispiel #24
0
		public CorValRef (ValueLoader loader)
		{
			this.val = loader ();
			this.loader = loader;
			this.version = MicroFrameworkDebuggerSession.EvaluationTimestamp;
		}
		public CorDebugValueReference (CorDebugValue val, RuntimeValue rtv, CorDebugAppDomain appDomain)
            : base (rtv, appDomain)
		{
			m_value = val;
		}
        private CorDebugValue[] EnsureValues(ref CorDebugValue[] values, uint cInfo, Engine.StackValueKind kind)
        {
            if (values == null)
            {
                values = CorDebugValue.CreateValues(this.Engine.GetStackFrameValueAll(m_chain.Thread.ID, this.DepthTinyCLR, cInfo, kind), this.Process);
            }

            return values;
        }
		public CorDebugValueReferenceByRef (CorDebugValue val, RuntimeValue rtv, CorDebugAppDomain appDomain) : base (val, rtv, appDomain)
		{                    
		}
		public void ResumingExecution ()
		{
			if (IsSuspended) {
				RefreshChain ();
			} else {
				m_chain = null;
				m_currentException = null;
			}
		}
Beispiel #29
0
 private CorDebugValue GetStackFrameValue(uint dwIndex, Engine.StackValueKind kind)
 {
     return(CorDebugValue.CreateValue(this.Engine.GetStackFrameValue(m_chain.Thread.ID, m_depthTinyCLR, kind, dwIndex), this.AppDomain));
 }