protected EvalDebugCallbackEventArgs(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) : base(pAppDomain) { AppDomain = pAppDomain; Thread = pThread; Eval = pEval; }
// The following function create values only for the purpuse of evalutaion // They actually do not allocate memory on the managed heap // The advantage is that it does not continue the process /// <exception cref="DebuggerException">Can not create string this way</exception> public static Value CreateValue(Process process, object value) { if (value is string) { throw new DebuggerException("Can not create string this way"); } CorElementType corElemType; ICorDebugClass corClass = null; if (value != null) { corElemType = DebugType.TypeNameToCorElementType(value.GetType().FullName); } else { corElemType = CorElementType.CLASS; corClass = DebugType.Create(process, null, typeof(object).FullName).CorType.Class; } ICorDebugEval corEval = CreateCorEval(process); ICorDebugValue corValue = corEval.CreateValue((uint)corElemType, corClass); Value v = new Value(process, new Expressions.PrimitiveExpression(value), corValue); if (value != null) { v.PrimitiveValue = value; } return(v); }
public static Value CreateValue(AppDomain appDomain, object value) { if (value == null) { ICorDebugClass corClass = appDomain.ObjectType.CorType.GetClass(); Thread thread = GetEvaluationThread(appDomain); ICorDebugEval corEval = thread.CorThread.CreateEval(); ICorDebugValue corValue = corEval.CreateValue((uint)CorElementType.CLASS, corClass); return(new Value(appDomain, corValue)); } else if (value is string) { return(Eval.NewString(appDomain, (string)value)); } else { if (!value.GetType().IsPrimitive) { throw new DebuggerException("Value must be primitve type. Seen " + value.GetType()); } Value val = Eval.NewObjectNoConstructor(DebugType.CreateFromType(appDomain.Mscorlib, value.GetType())); val.PrimitiveValue = value; return(val); } }
Eval(Process process, string description, ICorDebugEval corEval) { this.process = process; this.description = description; this.corEval = corEval; this.state = EvalState.Evaluating; }
public static Value CreateValue(Thread evalThread, object value) { if (value == null) { ICorDebugClass corClass = evalThread.AppDomain.ObjectType.ToCorDebug().GetClass(); ICorDebugEval corEval = evalThread.CorThread.CreateEval(); ICorDebugValue corValue = corEval.CreateValue((uint)CorElementType.CLASS, corClass); return(new Value(evalThread.AppDomain, corValue)); } else if (value is string) { return(Eval.NewString(evalThread, (string)value)); } else { if (!value.GetType().IsPrimitive) { throw new DebuggerException("Value must be primitve type. Seen " + value.GetType()); } IType type = evalThread.AppDomain.Compilation.FindType(value.GetType()); Value val = Eval.NewObjectNoConstructor(evalThread, type); val.SetPrimitiveValue(evalThread, value); return(val); } }
/** Creates an evaluation object. */ public Eval CreateEval() { ICorDebugEval e = null; m_th.CreateEval(out e); return(new Eval(e)); }
static void StartMethodInvoke(ICorDebugEval corEval, MethodInfo method, Value thisValue, Value[] args) { List <ICorDebugValue> corArgs = new List <ICorDebugValue>(); args = args ?? new Value[0]; try { if (thisValue != null) { if (!(thisValue.IsObject)) { throw new EvalSetupException("Can not evaluate on a value which is not an object"); } if (!method.DeclaringType.IsInstanceOfType(thisValue)) { throw new EvalSetupException("Can not evaluate because the object is not of proper type"); } corArgs.Add(thisValue.SoftReference); } foreach (Value arg in args) { corArgs.Add(arg.SoftReference); } } catch (CannotGetValueException e) { throw new EvalSetupException(e.Message); } ICorDebugType[] genericArgs = method.DeclaringType.GenericArgumentsAsCorDebugType; corEval.CastTo <ICorDebugEval2>().CallParameterizedFunction( method.CorFunction, (uint)genericArgs.Length, genericArgs, (uint)corArgs.Count, corArgs.ToArray() ); //corEval.CallFunction(method.CorFunction, (uint)corArgs.Count, corArgs.ToArray()); }
/** Creates an evaluation object. */ public CorEval CreateEval() { ICorDebugEval e = null; m_th.CreateEval(out e); return(e == null?null:new CorEval(e)); }
int ICorDebugThread.CreateEval(out ICorDebugEval ppEval) { Debug.Assert(!IsVirtualThread); ppEval = new CorDebugEval(this); return(Utility.COM_HResults.S_OK); }
internal Eval GetEval(ICorDebugEval corEval) { foreach(Eval eval in activeEvals) { if (eval.IsCorEval(corEval)) { return eval; } } throw new DebuggerException("Eval not found for given ICorDebugEval"); }
private void HandleEvalEvent(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { var domain = GetProcessWrapper(pAppDomain).GetAppDomain(pAppDomain); var thread = domain.GetThread(pThread); var eval = Session.ComInstanceCollector.GetWrapper<RuntimeEvaluation>(pEval); var eventArgs = new DebuggerEventArgs(domain, true); eval.DispatchEvaluationCompleted(eventArgs); FinalizeEvent(eventArgs); }
public static Value CreateValue(Process process, object val) { corEval2 = process.SelectedThread.CorThread.CreateEval(); Value res = new Value(process, new IExpirable[] {}, new IMutable[] {}, delegate { return(corEval2.CreateValue((uint)GetElementType(val.GetType()), null)); }); //res.PrimitiveValue = val; return(res); }
/// <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); }
void ICorDebugManagedCallback.EvalException( ICorDebugAppDomain appDomain, ICorDebugThread thread, ICorDebugEval eval) { if (DebugOutput) { Console.WriteLine("info: EvalException"); } appDomain.Continue(0); }
internal Eval GetActiveEval(ICorDebugEval corEval) { foreach (Eval eval in this.activeEvals) { if (eval.CorEval == corEval) { return(eval); } } throw new DebuggerException("Eval not found for given ICorDebugEval"); }
public void EvalException( ICorDebugAppDomain appDomain, ICorDebugThread thread, ICorDebugEval eval) { m_delegate.OnEvalException( new EvalEventArgs( new DebuggedAppDomain(appDomain), new DebuggedThread(thread), new Eval(eval))); }
internal Eval this[ICorDebugEval corEval] { get { foreach (Eval eval in this) { if (eval.IsCorEval(corEval)) { return(eval); } } throw new DebuggerException("Eval not found for given ICorDebugEval"); } }
internal RuntimeEvaluation(RuntimeThread thread, ICorDebugEval comEvaluation) { if (thread.State == ThreadState.Suspended) throw new InvalidOperationException("Thread is suspended."); if (!thread.IsManaged) throw new InvalidOperationException("Thread is at native code."); if (!thread.IsAtGCSafePoint) throw new InvalidOperationException("Thread is at GC unsafe point."); _thread = thread; _comEvaluation = comEvaluation; }
/// <returns>True if setup was successful</returns> internal bool SetupEvaluation(Thread targetThread) { process.AssertPaused(); try { if (targetThread.IsLastFunctionNative) { throw new EvalSetupException("Can not evaluate because native frame is on top of stack"); } if (!targetThread.IsAtSafePoint) { throw new EvalSetupException("Can not evaluate because thread is not at a safe point"); } // TODO: What if this thread is not suitable? corEval = targetThread.CorThread.CreateEval(); try { evaluationInvoker(corEval); } catch (COMException e) { if ((uint)e.ErrorCode == 0x80131C26) { throw new EvalSetupException("Can not evaluate in optimized code"); } else if ((uint)e.ErrorCode == 0x80131C28) { throw new EvalSetupException("Object is in wrong AppDomain"); } else if ((uint)e.ErrorCode == 0x8013130A) { // Happens on getting of Sytem.Threading.Thread.ManagedThreadId; See SD2-1116 throw new EvalSetupException("Function does not have IL code"); } else { throw; } } state = EvalState.Evaluating; return(true); } catch (EvalSetupException e) { state = EvalState.EvaluatedError; errorMsg = e.Message; return(false); } }
internal RuntimeEvaluation(RuntimeThread thread, ICorDebugEval comEvaluation) { if (thread.State == ThreadState.Suspended) { throw new InvalidOperationException("Thread is suspended."); } if (!thread.IsManaged) { throw new InvalidOperationException("Thread is at native code."); } if (!thread.IsAtGCSafePoint) { throw new InvalidOperationException("Thread is at GC unsafe point."); } _thread = thread; _comEvaluation = comEvaluation; }
void ICorDebugManagedCallback.EvalException(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { var ev = new CorEventArgs(new CorAppDomain(pAppDomain, p_options)); GetOwner(ev.Controller).DispatchEvent(ev); FinishEvent(ev); }
void HandleEvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval corEval, bool exception) { // Let the eval know that the CorEval has finished Eval eval = process.GetActiveEval(corEval); eval.NotifyEvaluationComplete(!exception); process.activeEvals.Remove(eval); pauseOnNextExit = true; ExitCallback(); }
internal Eval GetEval(ICorDebugEval corEval) { return activeEvals.Find(delegate (Eval eval) {return eval.IsCorEval(corEval);}); }
internal bool IsCorEval(ICorDebugEval corEval) { return this.corEval == corEval; }
protected EvalDebugCallbackEventArgs(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) : base(pAppDomain) { this.AppDomain = pAppDomain; this.Thread = pThread; this.Eval = pEval; }
public EvalExceptionDebugCallbackEventArgs(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) : base(pAppDomain, pThread, pEval) { }
void HandleEvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval corEval, bool exception) { // Let the eval know that the CorEval has finished Eval eval = process.GetEval(corEval); eval.NotifyEvaluationComplete(!exception); process.NotifyEvaluationComplete(eval); if (process.SetupNextEvaluation()) { ExitCallback_Continue(); } else { ExitCallback_Paused(); } }
public void EvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval corEval) { ManagedCallback managedCallback = GetProcessCallbackInterface("EvalComplete", pAppDomain); if (managedCallback != null) { managedCallback.EvalComplete(pAppDomain, pThread, corEval); } }
int ICorDebugThread.CreateEval(out ICorDebugEval ppEval) { Debug.Assert(!IsVirtualThread); ppEval = new CorDebugEval(this); return Utility.COM_HResults.S_OK; }
public EvalCompleteDebugCallbackEventArgs(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) : base(pAppDomain, pThread, pEval) { }
public void EvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { controller.Continue(0); }
public void EvalException(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { controller.Continue(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); } }
public void EvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval corEval) { EnterCallback(PausedReason.EvalComplete, "EvalComplete", pThread); HandleEvalComplete(pAppDomain, pThread, corEval, false); }
public virtual void EvalException(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { pAppDomain.Continue(0); }
public virtual void EvalException(ICorDebugAppDomain appDomain, ICorDebugThread thread, ICorDebugEval eval) { this.DefaultHandler(appDomain); }
internal Eval GetEval(ICorDebugEval corEval) { return(activeEvals.Find(delegate(Eval eval) { return eval.IsCorEval(corEval); })); }
public void EvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { try { _EnterCallback(); bool eventforce = false; lock (dbgproc) { try { ICorDebugValue presult; pEval.GetResult(out presult); presult = DebugProcess.Dereference(presult); ulong addr; presult.GetAddress(out addr); dbgproc.dout.WriteLine("$result= (0x{0:x}) {1}", addr, DebugProcess.ToString(presult)); } catch { eventforce = true; string emsg; ulong eaddr; dbgproc._GetExceptionInfo(out emsg, out eaddr); dbgproc.dout.WriteLine("Function evaluation completed with an exception."); dbgproc.dout.WriteLine("$result= (0x{0:x}) <System.Exception>", eaddr); dbgproc.dout.WriteLine("_message=(0x{0:x}) {1}", eaddr, emsg); dbgproc.dout.WriteLine(); // Needed. } } _CallbackEvent("EvalComplete", eventforce); } catch (Exception e) { _CallbackException(e); } }
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); }
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); }
public void EvalException(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { var handler = OnEvalFailed; if (handler != null) handler(this, new DebuggerEvalEventArgs(pThread, pEval)); pAppDomain.Continue(0); }
public void EvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval corEval) { EnterCallback("EvalComplete (" + process.GetActiveEval(corEval).Description + ")", pThread); HandleEvalComplete(pAppDomain, pThread, corEval, false); }
internal Eval(ICorDebugEval e) { m_eval = e; }
internal bool IsCorEval(ICorDebugEval corEval) { return(this.corEval == corEval); }
public void EvalException(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { try { _EnterCallback(); _UpdateActiveThread(pThread); lock (dbgproc) { string emsg; ulong eaddr; dbgproc._GetExceptionInfo(out emsg, out eaddr); dbgproc.dout.WriteLine("Function evaluation completed with an exception."); dbgproc.dout.WriteLine("$result= (0x{0:x}) <System.Exception>", eaddr); dbgproc.dout.WriteLine("_message=(0x{0:x}) {1}", eaddr, emsg); dbgproc.dout.WriteLine(); // Needed. } _CallbackEvent("EvalException", true); } catch (Exception e) { _CallbackException(e); } }
public void EvalException(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { Log("Exception occured during evaluation."); HandleEvalEvent(pAppDomain, pThread, pEval); }
internal CorEval(ICorDebugEval e) : base(e) { m_eval = e; }
public void EvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { HandleEvalEvent(pAppDomain, pThread, pEval); }
public DebuggerEvalEventArgs(ICorDebugThread thread, ICorDebugEval eval) : base(thread) { _eval = eval; }
private void HandleEvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval corEval, bool exception) { // Let the eval know that the CorEval has finished Eval eval = process.ActiveEvals[corEval]; eval.NotifyEvaluationComplete(!exception); process.ActiveEvals.Remove(eval); pauseOnNextExit = true; ExitCallback(); }
public void EvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval corEval) { ManagedCallback managedCallback = GetProcessCallbackInterface(pAppDomain); if (managedCallback != null) { managedCallback.EvalComplete(pAppDomain, pThread, corEval); } }
void ICorDebugManagedCallback.EvalException( ICorDebugAppDomain appDomain, ICorDebugThread thread, ICorDebugEval eval) { HandleEvent(ManagedCallbackType.OnEvalException, new CorEvalEventArgs( appDomain == null ? null : new CorAppDomain(appDomain), thread == null ? null : new CorThread(thread), eval == null ? null : new CorEval(eval), ManagedCallbackType.OnEvalException)); }
public virtual void EvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval pEval) { pAppDomain.Continue(0); }