예제 #1
0
파일: Eval.cs 프로젝트: Paccc/SharpDevelop
		Eval(Thread evalThread, string description, EvalStarter evalStarter)
		{
			if (evalThread == null)
				throw new DebuggerException("No evaluation thread was provided");
			
			this.appDomain = evalThread.AppDomain;
			this.process = appDomain.Process;
			this.description = description;
			this.state = EvalState.Evaluating;
			this.thread = evalThread;
			
			if (evalThread.Suspended)
				throw new GetValueException("Can not evaluate because thread is suspended");
			if (evalThread.IsInNativeCode)
				throw new GetValueException("Can not evaluate because thread is in native code");
			if (!evalThread.IsAtSafePoint)
				throw new GetValueException("Can not evaluate because thread is not at safe point");
			
			this.corEval = evalThread.CorThread.CreateEval();
			
			try {
				evalStarter(this);
			} catch (COMException e) {
				if ((uint)e.ErrorCode == 0x80131C26) {
					throw new GetValueException("Can not evaluate in optimized code");
				} else if ((uint)e.ErrorCode == 0x80131C28) {
					throw new GetValueException("Object is in wrong AppDomain");
				} else if ((uint)e.ErrorCode == 0x8013130A) {
					// Happens on getting of Sytem.Threading.Thread.ManagedThreadId; See SD2-1116
					throw new GetValueException("Function does not have IL code");
				} else if ((uint)e.ErrorCode == 0x80131C23) {
					// The operation failed because it is a GC unsafe point. (Exception from HRESULT: 0x80131C23)
					// This can probably happen when we break and the thread is in native code
					throw new GetValueException("Thread is in GC unsafe point");
				} else if ((uint)e.ErrorCode == 0x80131C22) {
					// The operation is illegal because of a stack overflow.
					throw new GetValueException("Can not evaluate after stack overflow");
				} else if ((uint)e.ErrorCode == 0x80131313) {
					// Func eval cannot work. Bad starting point.
					// Reproduction circumstancess are unknown
					throw new GetValueException("Func eval cannot work. Bad starting point.");
				} else {
					#if DEBUG
					throw; // Expose for more diagnostics
					#else
					throw new GetValueException(e.Message);
					#endif
				}
			}
			
			appDomain.Process.activeEvals.Add(this);
			
			appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, evalThread);
		}
예제 #2
0
        /// <exception cref="GetValueException">Can not evaluate in optimized code</exception>
        static Eval CreateEval(Process process, string description, EvalStarter evalStarter)
        {
            ICorDebugEval corEval = CreateCorEval(process);

            Eval newEval = new Eval(process, description, corEval);

            try {
                evalStarter(newEval);
            } catch (COMException e) {
                if ((uint)e.ErrorCode == 0x80131C26)
                {
                    throw new GetValueException("Can not evaluate in optimized code");
                }
                else if ((uint)e.ErrorCode == 0x80131C28)
                {
                    throw new GetValueException("Object is in wrong AppDomain");
                }
                else if ((uint)e.ErrorCode == 0x8013130A)
                {
                    // Happens on getting of Sytem.Threading.Thread.ManagedThreadId; See SD2-1116
                    throw new GetValueException("Function does not have IL code");
                }
                else if ((uint)e.ErrorCode == 0x80131C23)
                {
                    // The operation failed because it is a GC unsafe point. (Exception from HRESULT: 0x80131C23)
                    // This can probably happen when we break and the thread is in native code
                    throw new GetValueException("Thread is in GC unsafe point");
                }
                else if ((uint)e.ErrorCode == 0x80131C22)
                {
                    // The operation is illegal because of a stack overflow.
                    throw new GetValueException("Can not evaluate after stack overflow");
                }
                else if ((uint)e.ErrorCode == 0x80131313)
                {
                    // Func eval cannot work. Bad starting point.
                    // Reproduction circumstancess are unknown
                    throw new GetValueException("Func eval cannot work. Bad starting point.");
                }
                else
                {
                                        #if DEBUG
                    throw;                             // Expose for more diagnostics
                                        #else
                    throw new GetValueException(e.Message);
                                        #endif
                }
            }

            process.NotifyEvaluationStarted(newEval);
            process.AsyncContinue(DebuggeeStateAction.Keep);

            return(newEval);
        }
예제 #3
0
파일: Eval.cs 프로젝트: KAW0/Alter-Native
		Eval(AppDomain appDomain, string description, EvalStarter evalStarter)
		{
			this.appDomain = appDomain;
			this.process = appDomain.Process;
			this.description = description;
			this.state = EvalState.Evaluating;
			this.thread = GetEvaluationThread(appDomain);
			this.corEval = thread.CorThread.CreateEval();
			
			try {
				evalStarter(this);
			} catch (COMException e) {
				if ((uint)e.ErrorCode == 0x80131C26) {
					throw new GetValueException("Can not evaluate in optimized code");
				} else if ((uint)e.ErrorCode == 0x80131C28) {
					throw new GetValueException("Object is in wrong AppDomain");
				} else if ((uint)e.ErrorCode == 0x8013130A) {
					// Happens on getting of Sytem.Threading.Thread.ManagedThreadId; See SD2-1116
					throw new GetValueException("Function does not have IL code");
				} else if ((uint)e.ErrorCode == 0x80131C23) {
					// The operation failed because it is a GC unsafe point. (Exception from HRESULT: 0x80131C23)
					// This can probably happen when we break and the thread is in native code
					throw new GetValueException("Thread is in GC unsafe point");
				} else if ((uint)e.ErrorCode == 0x80131C22) {
					// The operation is illegal because of a stack overflow.
					throw new GetValueException("Can not evaluate after stack overflow");
				} else if ((uint)e.ErrorCode == 0x80131313) {
					// Func eval cannot work. Bad starting point.
					// Reproduction circumstancess are unknown
					throw new GetValueException("Func eval cannot work. Bad starting point.");
				} else {
					#if DEBUG
						throw; // Expose for more diagnostics
					#else
						throw new GetValueException(e.Message);
					#endif
				}
			}
			
			appDomain.Process.ActiveEvals.Add(this);
			
			if (appDomain.Process.Options.SuspendOtherThreads) {
				appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, new Thread[] { thread }, CorDebugThreadState.THREAD_SUSPEND);
			} else {
				appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, this.Process.UnsuspendedThreads, CorDebugThreadState.THREAD_RUN);
			}
		}
예제 #4
0
        Eval(Thread evalThread, string description, EvalStarter evalStarter)
        {
            if (evalThread == null)
            {
                throw new DebuggerException("No evaluation thread was provided");
            }

            this.appDomain   = evalThread.AppDomain;
            this.process     = appDomain.Process;
            this.description = description;
            this.state       = EvalState.Evaluating;
            this.thread      = evalThread;

            if (evalThread.Suspended)
            {
                throw new GetValueException("Can not evaluate because thread is suspended");
            }
            if (evalThread.IsInNativeCode)
            {
                throw new GetValueException("Can not evaluate because thread is in native code");
            }
            if (!evalThread.IsAtSafePoint)
            {
                throw new GetValueException("Can not evaluate because thread is not at safe point");
            }

            this.corEval = evalThread.CorThread.CreateEval();

            try {
                evalStarter(this);
            } catch (COMException e) {
                if ((uint)e.ErrorCode == 0x80131C26)
                {
                    throw new GetValueException("Can not evaluate in optimized code");
                }
                else if ((uint)e.ErrorCode == 0x80131C28)
                {
                    throw new GetValueException("Object is in wrong AppDomain");
                }
                else if ((uint)e.ErrorCode == 0x8013130A)
                {
                    // Happens on getting of Sytem.Threading.Thread.ManagedThreadId; See SD2-1116
                    throw new GetValueException("Function does not have IL code");
                }
                else if ((uint)e.ErrorCode == 0x80131C23)
                {
                    // The operation failed because it is a GC unsafe point. (Exception from HRESULT: 0x80131C23)
                    // This can probably happen when we break and the thread is in native code
                    throw new GetValueException("Thread is in GC unsafe point");
                }
                else if ((uint)e.ErrorCode == 0x80131C22)
                {
                    // The operation is illegal because of a stack overflow.
                    throw new GetValueException("Can not evaluate after stack overflow");
                }
                else if ((uint)e.ErrorCode == 0x80131313)
                {
                    // Func eval cannot work. Bad starting point.
                    // Reproduction circumstancess are unknown
                    throw new GetValueException("Func eval cannot work. Bad starting point.");
                }
                else
                {
                                        #if DEBUG
                    throw;                     // Expose for more diagnostics
                                        #else
                    throw new GetValueException(e.Message);
                                        #endif
                }
            }

            appDomain.Process.activeEvals.Add(this);

            appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, evalThread);
        }
예제 #5
0
	    /// <exception cref="GetValueException">Can not evaluate in optimized code</exception>
	    static Eval CreateEval(Process process, string description, EvalStarter evalStarter)
		{
			ICorDebugEval corEval = CreateCorEval(process);
			
			Eval newEval = new Eval(process, description, corEval);
			
			try {
				evalStarter(newEval);
			} catch (COMException e) {
				if ((uint)e.ErrorCode == 0x80131C26) {
					throw new GetValueException("Can not evaluate in optimized code");
				} else if ((uint)e.ErrorCode == 0x80131C28) {
					throw new GetValueException("Object is in wrong AppDomain");
				} else if ((uint)e.ErrorCode == 0x8013130A) {
					// Happens on getting of Sytem.Threading.Thread.ManagedThreadId; See SD2-1116
					throw new GetValueException("Function does not have IL code");
				} else if ((uint)e.ErrorCode == 0x80131C23) {
					// The operation failed because it is a GC unsafe point. (Exception from HRESULT: 0x80131C23)
					// This can probably happen when we break and the thread is in native code
					throw new GetValueException("Thread is in GC unsafe point");
				} else if ((uint)e.ErrorCode == 0x80131C22) {
					// The operation is illegal because of a stack overflow.
					throw new GetValueException("Can not evaluate after stack overflow");
				} else if ((uint)e.ErrorCode == 0x80131313) {
					// Func eval cannot work. Bad starting point.
					// Reproduction circumstancess are unknown
					throw new GetValueException("Func eval cannot work. Bad starting point.");
				} else {
					#if DEBUG
						throw; // Expose for more diagnostics
					#else
						throw new GetValueException(e.Message);
					#endif
				}
			}
			
			process.NotifyEvaluationStarted(newEval);
			process.AsyncContinue(DebuggeeStateAction.Keep);
			
			return newEval;
		}
예제 #6
0
        Eval(AppDomain appDomain, string description, EvalStarter evalStarter)
        {
            this.appDomain   = appDomain;
            this.process     = appDomain.Process;
            this.description = description;
            this.state       = EvalState.Evaluating;
            this.thread      = GetEvaluationThread(appDomain);
            this.corEval     = thread.CorThread.CreateEval();

            try {
                evalStarter(this);
            } catch (COMException e) {
                if ((uint)e.ErrorCode == 0x80131C26)
                {
                    throw new GetValueException("Can not evaluate in optimized code");
                }
                else if ((uint)e.ErrorCode == 0x80131C28)
                {
                    throw new GetValueException("Object is in wrong AppDomain");
                }
                else if ((uint)e.ErrorCode == 0x8013130A)
                {
                    // Happens on getting of Sytem.Threading.Thread.ManagedThreadId; See SD2-1116
                    throw new GetValueException("Function does not have IL code");
                }
                else if ((uint)e.ErrorCode == 0x80131C23)
                {
                    // The operation failed because it is a GC unsafe point. (Exception from HRESULT: 0x80131C23)
                    // This can probably happen when we break and the thread is in native code
                    throw new GetValueException("Thread is in GC unsafe point");
                }
                else if ((uint)e.ErrorCode == 0x80131C22)
                {
                    // The operation is illegal because of a stack overflow.
                    throw new GetValueException("Can not evaluate after stack overflow");
                }
                else if ((uint)e.ErrorCode == 0x80131313)
                {
                    // Func eval cannot work. Bad starting point.
                    // Reproduction circumstancess are unknown
                    throw new GetValueException("Func eval cannot work. Bad starting point.");
                }
                else
                {
                                        #if DEBUG
                    throw;                             // Expose for more diagnostics
                                        #else
                    throw new GetValueException(e.Message);
                                        #endif
                }
            }

            appDomain.Process.ActiveEvals.Add(this);

            if (appDomain.Process.Options.SuspendOtherThreads)
            {
                appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, new Thread[] { thread }, CorDebugThreadState.THREAD_SUSPEND);
            }
            else
            {
                appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, this.Process.UnsuspendedThreads, CorDebugThreadState.THREAD_RUN);
            }
        }