public CorDebugFunctionBreakpoint (CorDebugFunction function, uint ilCLR) : base(function.AppDomain)
        {
            m_function   = function;
            m_il         = new Pdbx.IL();
            m_il.CLR     = ilCLR;
            m_il.TinyCLR = function.GetILTinyCLRFromILCLR(ilCLR);

            m_breakpointDef.m_IP  = m_il.TinyCLR;            
            m_breakpointDef.m_md  = m_function.MethodDef_Index;            

            this.Active = true;   
        }
Exemplo n.º 2
0
        public CorDebugFunctionBreakpoint(CorDebugFunction function, uint ilCLR) : base(function.AppDomain)
        {
            m_function   = function;
            m_il         = new Pdbx.IL();
            m_il.CLR     = ilCLR;
            m_il.TinyCLR = function.GetILTinyCLRFromILCLR(ilCLR);

            m_breakpointDef.m_IP = m_il.TinyCLR;
            m_breakpointDef.m_md = m_function.MethodDef_Index;

            this.Active = true;
        }
Exemplo n.º 3
0
        public static CorDebugFunction CorDebugFunctionFromMethodIndex(uint methodIndex, CorDebugAppDomain appDomain)
        {
            CorDebugFunction function = null;
            CorDebugAssembly assembly = appDomain.AssemblyFromIdx(TinyCLR_TypeSystem.IdxAssemblyFromIndex(methodIndex));

            if (assembly != null)
            {
                uint tk = TinyCLR_TypeSystem.TinyCLRTokenFromMethodIndex(methodIndex);
                function = assembly.GetFunctionFromTokenTinyCLR(tk);
            }

            return(function);
        }
Exemplo n.º 4
0
        private CorDebugFunction GetFunctionFromToken(uint tk, Hashtable ht)
        {
            CorDebugFunction function = null;

            Pdbx.Method method = ht [tk] as Pdbx.Method;
            if (method != null)
            {
                CorDebugClass c = new CorDebugClass(this, method.Class);
                function = new CorDebugFunction(c, method);
            }

            Debug.Assert(function != null);
            return(function);
        }
Exemplo n.º 5
0
        int ICorDebugEval.NewObject(ICorDebugFunction pConstructor, uint nArgs, ICorDebugValue[] ppArgs)
        {
            Debug.Assert(nArgs == ppArgs.Length);

            CorDebugFunction f = (CorDebugFunction)pConstructor;
            CorDebugClass    c = f.Class;

            this.Process.SetCurrentAppDomain(this.AppDomain);
            Engine.AllocateObject(GetScratchPadLocation(), c.TypeDef_Index);

            ICorDebugValue[] args = new ICorDebugValue[nArgs + 1];

            args[0] = GetResultValue();
            ppArgs.CopyTo(args, 1);
            ((ICorDebugEval)this).CallFunction(pConstructor, (uint)args.Length, args);

            return(Utility.COM_HResults.S_OK);
        }
Exemplo n.º 6
0
		public CorDebugCode (CorDebugFunction function)
		{
			m_function = function;
		}
Exemplo n.º 7
0
 public CorDebugCode(CorDebugFunction function)
 {
     m_function = function;
 }
Exemplo n.º 8
0
        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);
		}
Exemplo n.º 10
0
        private CorDebugFunction GetFunctionFromToken( uint tk, Hashtable ht )
        {
            CorDebugFunction function = null;
            Pdbx.Method method = ht[tk] as Pdbx.Method;
            if(method != null)
            {
                CorDebugClass c = new CorDebugClass( this, method.Class );
                function = new CorDebugFunction( c, method );
            }

            Debug.Assert( function != null );
            return function;
        }
		public CorDebugValue RuntimeInvoke (CorEvaluationContext corEvaluationContext, CorDebugFunction function, CorDebugType[] typeArgs, CorDebugValue thisObj, CorDebugValue[] arguments)
		{
			return null;
		}
		int ICorDebugManagedCallback.EditAndContinueRemap (CorDebugAppDomain pAppDomain, CorDebugThread pThread, CorDebugFunction pFunction, int fAccurate)
		{
			return 0;
		}