Exemplo n.º 1
0
        public void NewParameterizedObject(CorFunction managedFunction, CorType[] argumentTypes, CorValue[] arguments)
        {
            ICorDebugType[] types       = null;
            int             typesLength = 0;

            ICorDebugValue[] values     = null;
            int            valuesLength = 0;
            ICorDebugEval2 eval2        = (ICorDebugEval2)m_eval;

            if (argumentTypes != null)
            {
                types = new ICorDebugType[argumentTypes.Length];
                for (int i = 0; i < argumentTypes.Length; i++)
                {
                    types[i] = argumentTypes[i].m_type;
                }
                typesLength = types.Length;
            }
            if (arguments != null)
            {
                values = new ICorDebugValue[arguments.Length];
                for (int i = 0; i < arguments.Length; i++)
                {
                    values[i] = arguments[i].m_val;
                }
                valuesLength = values.Length;
            }
            eval2.NewParameterizedObject(managedFunction.m_function, (uint)typesLength, types, (uint)valuesLength, values);
        }
Exemplo n.º 2
0
Arquivo: Eval.cs Projeto: Orvid/Cosmos
        public void NewParameterizedObject(CorFunction managedFunction, CorType[] argumentTypes, CorValue[] arguments)
        {
    
            ICorDebugType[] types = null;
            int typesLength = 0;
            ICorDebugValue[] values = null;
            int valuesLength = 0;
            ICorDebugEval2 eval2 = (ICorDebugEval2) m_eval;

            if (argumentTypes != null)
            {
                types = new ICorDebugType[argumentTypes.Length];
                for (int i = 0; i < argumentTypes.Length; i++)
                    types[i] = argumentTypes[i].m_type;
                typesLength = types.Length;
            }
            if (arguments != null)
            {
                values = new ICorDebugValue[arguments.Length];
                for (int i = 0; i < arguments.Length; i++)
                    values[i] = arguments[i].m_val;
                valuesLength = values.Length;
            }
            eval2.NewParameterizedObject(managedFunction.m_function, (uint)typesLength, types, (uint)valuesLength, values);
        }
Exemplo n.º 3
0
        internal MDbgFunction(MDbgModule managedModule, CorFunction managedFunction)
        {
            Debug.Assert(managedModule != null);
            Debug.Assert(managedFunction != null);
            Debug.Assert(managedFunction.Version >= 0 && managedFunction.Version - 1 <= managedModule.EditsCounter); // version numbers starts with 1

            m_module = managedModule;
            m_function = managedFunction;
            EnsureIsUpToDate();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Looks up a CorFunction.
 /// </summary>
 /// <param name="managedFunction">Which CorFunction to lookup.</param>
 /// <returns>The coresponding MDbgFunction.</returns>
 public MDbgFunction LookupFunction(CorFunction managedFunction)
 {
     if (managedFunction != null)
     {
         return this.Lookup(managedFunction.Module).GetFunction(managedFunction);
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 5
0
 public void CallFunction(CorFunction managedFunction, CorValue[] arguments)
 {
     ICorDebugValue[] values = null;
     if(arguments!=null)
     {
         values = new ICorDebugValue[arguments.Length];
         for(int i=0;i<arguments.Length;i++)
             values[i] = arguments[i].m_val;
     }
     m_eval.CallFunction(managedFunction.m_function,
                         (uint) (arguments==null?0:arguments.Length),
                         values);
 }
Exemplo n.º 6
0
        public MDbgFunction Get(CorFunction managedFunction)
        {
            int funcVersion;
            funcVersion = managedFunction.Version;

            // now get version from our cache.
            MDbgFunction mdbgFunction = RetrieveFromCache(managedFunction.Token, funcVersion);
            if (mdbgFunction == null)
            {
                mdbgFunction = new MDbgFunction(m_module, managedFunction);
                AddToCache(managedFunction.Token, funcVersion, mdbgFunction);
            }
            return mdbgFunction;
        }
Exemplo n.º 7
0
 public void CallFunction(CorFunction managedFunction, CorValue[] arguments)
 {
     ICorDebugValue[] values = null;
     if (arguments != null)
     {
         values = new ICorDebugValue[arguments.Length];
         for (int i = 0; i < arguments.Length; i++)
         {
             values[i] = arguments[i].m_val;
         }
     }
     m_eval.CallFunction(managedFunction.m_function,
                         (uint)(arguments == null ? 0 : arguments.Length),
                         values);
 }
Exemplo n.º 8
0
 private bool attemptToSetBreakpointThroughSequencePoints(ISymbolDocument doc, int line, ISymbolMethod method, CorFunction function)
 {
     bool found = false;
     foreach (var sp in getSequencePoints(method))
     {
         if (sp.Document.URL.Equals(doc.URL) && sp.LineStart.Equals(line))
         {
             var bp = function.ILCode.CreateBreakpoint(sp.Offset);
             bp.Activate(true);
             found = true;
             break;
         }
     }
     return found;
 }
Exemplo n.º 9
0
        public CorType GetVirtualMethodAndType(int memberToken, out CorFunction managedFunction)
        {
            ICorDebugType     dt    = null;
            ICorDebugFunction pfunc = null;

            (m_objVal as ICorDebugObjectValue2).GetVirtualMethodAndType((uint)memberToken, out pfunc, out dt);
            if (pfunc == null)
            {
                managedFunction = null;
            }
            else
            {
                managedFunction = new CorFunction(pfunc);
            }
            return(dt == null ? null : new CorType(dt));
        }
Exemplo n.º 10
0
 /// <summary>
 /// Create a new instance of the FunctionRemapCompleteStopReason class.
 /// </summary>
 /// <param name="appDomain">The appDomain where remapping is occuring.</param>
 /// <param name="thread">The thread on which the remapping is occuring.</param>
 /// <param name="managedFunction">The version of function the debugger remapped to.</param>
 public FunctionRemapCompleteStopReason(CorAppDomain appDomain,
                                          CorThread thread,
                                          CorFunction managedFunction)
 {
     Debug.Assert(appDomain != null);
     Debug.Assert(thread != null);
     Debug.Assert(managedFunction != null);
     m_appDomain = appDomain;
     m_thread = thread;
     m_function = managedFunction;
 }
Exemplo n.º 11
0
 private void setBreakpointThroughFunction(CorFunction function)
 {
     var bp = function.CreateBreakpoint();
     bp.Activate(true);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Releases all resources used by the MDbgFunction.
        /// </summary>
        public void Dispose()
        {
            // Release unmanaged resources, especially symbol readers
            m_function = null;

            m_symMethod = null;
            m_SPoffsets = null;
            m_SPdocuments = null;
            m_SPstartLines = null;
            m_SPendLines = null;
            m_SPstartColumns = null;
            m_SPendColumns = null;
            m_SPcount = 0;
        }
Exemplo n.º 13
0
 public CorFunctionRemapCompleteEventArgs(CorAppDomain appDomain,
                                    CorThread thread,
                                    CorFunction managedFunction
                                    )
     : base(appDomain, thread)
 {
     m_managedFunction = managedFunction;
 }
Exemplo n.º 14
0
 public CorFunctionRemapOpportunityEventArgs(CorAppDomain appDomain,
                                    CorThread thread,
                                    CorFunction oldFunction,
                                    CorFunction newFunction,
                                    int oldILoffset
                                    )
     : base(appDomain, thread)
 {
     m_oldFunction = oldFunction;
     m_newFunction = newFunction;
     m_oldILoffset = oldILoffset;
 }
Exemplo n.º 15
0
 internal CorActiveFunction(int ilOffset, CorFunction managedFunction, CorModule managedModule)
 {
     m_ilOffset = ilOffset;
     m_function = managedFunction;
     m_module   = managedModule;
 }
Exemplo n.º 16
0
        private SequencePoint get_location(CorFunction function, uint offset)
        {
            var reader = _symbolReaders.Find(r => r.Key.Equals(function.Module.Name)).Value;
            var symmethod = reader.GetMethod(new SymbolToken(function.Token));

            if (symmethod == null)
                return null;

            SequencePoint prev_sp = null;
            foreach (var sp in new SequencePointFactory().Generate(symmethod))
            {
                if (sp.Offset > offset)
                    break;
                prev_sp = sp;
            }
            return prev_sp;
        }
Exemplo n.º 17
0
 public RemapOpportunityReachedStopReason(CorAppDomain appDomain,
                                          CorThread thread,
                                          CorFunction oldFunction,
                                          CorFunction newFunction,
                                          int oldILOffset)
 {
     Debug.Assert(appDomain != null);
     Debug.Assert(thread != null);
     Debug.Assert(oldFunction != null);
     Debug.Assert(newFunction != null);
     m_appDomain = appDomain;
     m_thread = thread;
     m_oldFunction = oldFunction;
     m_newFunction = newFunction;
     m_oldILOffset = oldILOffset;
 }
Exemplo n.º 18
0
		public CorValue RuntimeInvoke (CorFunction function, CorType[] typeArgs, CorValue thisObj, CorValue[] arguments)
		{
			return Session.RuntimeInvoke (this, function, typeArgs, thisObj, arguments);
		}
Exemplo n.º 19
0
		public CorValue RuntimeInvoke (CorEvaluationContext ctx, CorFunction function, CorType[] typeArgs, CorValue thisObj, CorValue[] arguments)
		{
			if (!ctx.Thread.ActiveChain.IsManaged)
				throw new EvaluatorException ("Cannot evaluate expression because the thread is stopped in native code.");

			CorValue[] args;
			if (thisObj == null)
				args = arguments;
			else {
				args = new CorValue[arguments.Length + 1];
				args[0] = thisObj;
				arguments.CopyTo (args, 1);
			}

			CorMethodCall mc = new CorMethodCall ();
			CorValue exception = null;
			CorEval eval = ctx.Eval;

			EvalEventHandler completeHandler = delegate (object o, CorEvalEventArgs eargs) {
				OnEndEvaluating ();
				mc.DoneEvent.Set ();
				eargs.Continue = false;
			};

			EvalEventHandler exceptionHandler = delegate (object o, CorEvalEventArgs eargs) {
				OnEndEvaluating ();
				exception = eargs.Eval.Result;
				mc.DoneEvent.Set ();
				eargs.Continue = false;
			};

			process.OnEvalComplete += completeHandler;
			process.OnEvalException += exceptionHandler;

			mc.OnInvoke = delegate {
				if (function.GetMethodInfo (this).Name == ".ctor")
					eval.NewParameterizedObject (function, typeArgs, args);
				else
					eval.CallParameterizedFunction (function, typeArgs, args);
				process.SetAllThreadsDebugState (CorDebugThreadState.THREAD_SUSPEND, ctx.Thread);
				ClearEvalStatus ();
				OnStartEvaluating ();
				process.Continue (false);
			};
			mc.OnAbort = delegate {
				eval.Abort ();
			};
			mc.OnGetDescription = delegate {
				System.Reflection.MethodInfo met = function.GetMethodInfo (ctx.Session);
				if (met != null)
					return met.Name;
				else
					return "<Unknown>";
			};

			try {
				ObjectAdapter.AsyncExecute (mc, ctx.Options.EvaluationTimeout);
			}
			finally {
				process.OnEvalComplete -= completeHandler;
				process.OnEvalException -= exceptionHandler;
			}

			if (exception != null) {
/*				ValueReference<CorValue, CorType> msg = ctx.Adapter.GetMember (ctx, val, "Message");
				if (msg != null) {
					string s = msg.ObjectValue as string;
					mc.ExceptionMessage = s;
				}
				else
					mc.ExceptionMessage = "Evaluation failed.";*/
				CorValRef vref = new CorValRef (exception);
				throw new EvaluatorException ("Evaluation failed: " + ObjectAdapter.GetValueTypeName (ctx, vref));
			}

			return eval.Result;
		}
Exemplo n.º 20
0
 public CorType GetVirtualMethodAndType(int memberToken, out CorFunction managedFunction)
 {
     ICorDebugType dt = null;
     ICorDebugFunction pfunc = null;
     (m_objVal as ICorDebugObjectValue2).GetVirtualMethodAndType((uint)memberToken, out pfunc, out dt);
     if (pfunc == null)
         managedFunction = null;
     else
         managedFunction = new CorFunction (pfunc);
     return dt==null?null:new CorType (dt);
 }
Exemplo n.º 21
0
 public CorEditAndContinueRemapEventArgs(CorAppDomain appDomain,
                                 CorThread thread,
                                 CorFunction managedFunction,
                                 int accurate,
                                 ManagedCallbackType callbackType)
     : base(appDomain, thread, callbackType)
 {
     m_managedFunction = managedFunction;
     m_accurate = accurate;
 }
Exemplo n.º 22
0
 internal CorActiveFunction(int ilOffset, CorFunction managedFunction, CorModule managedModule)
 {
     m_ilOffset = ilOffset;
     m_function = managedFunction;
     m_module = managedModule;
 }
Exemplo n.º 23
0
 public CorFunctionRemapOpportunityEventArgs(CorAppDomain appDomain,
                                    CorThread thread,
                                    CorFunction oldFunction,
                                    CorFunction newFunction,
                                    int oldILoffset,
                                    ManagedCallbackType callbackType
                                    )
     : base(appDomain, thread, callbackType)
 {
     m_oldFunction = oldFunction;
     m_newFunction = newFunction;
     m_oldILoffset = oldILoffset;
 }
Exemplo n.º 24
0
 /// <summary>
 /// Gets the MDbgFunction for a given CorFunction.
 /// </summary>
 /// <param name="managedFunction">The CorFunction to lookup.</param>
 /// <returns>The coresponding MDbgFunction.</returns>
 public MDbgFunction GetFunction(CorFunction managedFunction)
 {
     return m_functions.Get(managedFunction);
 }
Exemplo n.º 25
0
 public CorFunctionRemapCompleteEventArgs(CorAppDomain appDomain,
                                    CorThread thread,
                                    CorFunction managedFunction,
                                    ManagedCallbackType callbackType
                                    )
     : base(appDomain, thread, callbackType)
 {
     m_managedFunction = managedFunction;
 }
Exemplo n.º 26
0
 /// <summary>
 /// Looks up a CorFunction.
 /// </summary>
 /// <param name="managedFunction">Which CorFunction to lookup.</param>
 /// <returns>The coresponding MDbgFunction.</returns>
 public MDbgFunction LookupFunction(CorFunction managedFunction)
 {
     return this.Lookup(managedFunction.Module).GetFunction(managedFunction);
 }