void DoBreak(ILIntepreter intp, int bpHash, bool isStep) { KeyValuePair <int, StackFrameInfo[]>[] frames = new KeyValuePair <int, StackFrameInfo[]> [AppDomain.Intepreters.Count]; frames[0] = new KeyValuePair <int, StackFrameInfo[]>(intp.GetHashCode(), GetStackFrameInfo(intp)); int idx = 1; foreach (var j in AppDomain.Intepreters) { if (j.Value != intp) { j.Value.ShouldBreak = true; frames[idx++] = new KeyValuePair <int, Debugger.StackFrameInfo[]>(j.Value.GetHashCode(), GetStackFrameInfo(j.Value)); } } if (!isStep) { server.SendSCBreakpointHit(intp.GetHashCode(), bpHash, frames); } else { server.SendSCStepComplete(intp.GetHashCode(), frames); } //Breakpoint hit intp.Break(); }
internal void ThreadEnded(ILIntepreter intp) { if (server != null && server.IsAttached) { server.SendSCThreadEnded(intp.GetHashCode()); } }
/// <summary> /// Invokes a specific method /// </summary> /// <param name="m">Method</param> /// <param name="instance">object instance</param> /// <param name="p">Parameters</param> /// <returns></returns> public object Invoke(IMethod m, object instance, params object[] p) { object res = null; if (m is ILMethod) { ILIntepreter inteptreter = null; lock (freeIntepreters) { if (freeIntepreters.Count > 0) { inteptreter = freeIntepreters.Dequeue(); //Clear debug state, because it may be in ShouldBreak State inteptreter.ClearDebugState(); } else { inteptreter = new ILIntepreter(this); #if DEBUG intepreters[inteptreter.GetHashCode()] = inteptreter; debugService.ThreadStarted(inteptreter); #endif } } try { res = inteptreter.Run((ILMethod)m, instance, p); } finally { lock (freeIntepreters) { #if DEBUG if (inteptreter.CurrentStepType != StepTypes.None) { //We should resume all other threads if we are currently doing stepping operation foreach (var i in intepreters) { if (i.Value != inteptreter) { i.Value.ClearDebugState(); i.Value.Resume(); } } inteptreter.ClearDebugState(); } #endif inteptreter.Stack.ManagedStack.Clear(); inteptreter.Stack.Frames.Clear(); freeIntepreters.Enqueue(inteptreter); #if DEBUG //debugService.ThreadEnded(inteptreter); #endif } } } return(res); }