public static int GetCurrentSequencePointForGeneratorFrame(DebugFrame frame) { Debug.Assert(frame != null); Debug.Assert(frame.Generator != null); return(frame.CurrentLocationCookie); }
public static int GetCurrentSequencePointForLeafGeneratorFrame(DebugThread thread) { DebugFrame frame = thread.GetLeafFrame(); Debug.Assert(frame.Generator != null); return(frame.CurrentLocationCookie); }
internal override bool TryGetLeafFrame(ref DebugFrame frame) { if (_frames.Count > 0) { frame = _frames[_frames.Count - 1].Frame; return frame != null; } else { frame = null; return false; } }
public static bool IsCurrentLeafFrameRemappingToGenerator(DebugThread thread) { DebugFrame frame = null; if (thread.TryGetLeafFrame(ref frame)) { return(frame.ForceSwitchToGeneratorLoop); } return(false); }
internal override bool TryGetLeafFrame(ref DebugFrame frame) { if (_frames.Count > 0) { frame = _frames[_frames.Count - 1].Frame; return(frame != null); } frame = null; return(false); }
public bool CanSetNextStatement(string sourceFile, SourceSpan sourceSpan) { VerifyNotClosed(); ContractUtils.RequiresNotNull(sourceFile, "sourceFile"); ContractUtils.Requires(sourceSpan != SourceSpan.Invalid && sourceSpan != SourceSpan.None, ErrorStrings.InvalidSourceSpan); // Find the thread object. We also check if the current thread is in FrameExit traceback. DebugFrame traceFrame = _traceFrame.Value; if (traceFrame == null) { return(false); } return(GetSequencePointIndexForSourceSpan(sourceFile, sourceSpan, traceFrame) != Int32.MaxValue); }
void IDebugCallback.OnDebugEvent(TraceEventKind kind, DebugThread thread, FunctionInfo functionInfo, int sequencePointIndex, int stackDepth, object payload) { ITraceCallback traceCallback = _traceCallback; if (traceCallback != null) { // $TODO: what if the callback throws an exception? should we swallow it? var curThread = _traceFrame.Value; try { if (kind == TraceEventKind.FrameExit || kind == TraceEventKind.ThreadExit) { traceCallback.OnTraceEvent( kind, kind == TraceEventKind.FrameExit ? functionInfo.Name : null, null, SourceSpan.None, null, payload, functionInfo != null ? functionInfo.CustomPayload : null ); } else { DebugFrame leafFrame = thread.GetLeafFrame(); _traceFrame.Value = leafFrame; Debug.Assert(sequencePointIndex >= 0 && sequencePointIndex < functionInfo.SequencePoints.Length); DebugSourceSpan sourceSpan = functionInfo.SequencePoints[sequencePointIndex]; traceCallback.OnTraceEvent( kind, functionInfo.Name, sourceSpan.SourceFile.Name, sourceSpan.ToDlrSpan(), () => { return(leafFrame.GetLocalsScope()); }, payload, functionInfo.CustomPayload ); } } finally { _traceFrame.Value = curThread; } } }
internal override FunctionInfo GetLeafFrameFunctionInfo(out int stackDepth) { int leafIndex = _frames.Count - 1; if (leafIndex >= 0) { stackDepth = leafIndex; DebugFrame leafFrame = _frames[leafIndex].Frame; if (leafFrame != null) { Debug.Assert(leafIndex == leafFrame.StackDepth); return(leafFrame.FunctionInfo); } Debug.Assert(_frames[leafIndex].RuntimeVariables is IDebugRuntimeVariables); return(((IDebugRuntimeVariables)_frames[leafIndex].RuntimeVariables).FunctionInfo); } stackDepth = Int32.MaxValue; return(null); }
public void SetNextStatement(string sourceFile, SourceSpan sourceSpan) { VerifyNotClosed(); ContractUtils.RequiresNotNull(sourceFile, "sourceFile"); ContractUtils.Requires(sourceSpan != SourceSpan.Invalid && sourceSpan != SourceSpan.None, ErrorStrings.InvalidSourceSpan); // Find the thread object DebugFrame traceFrame = _traceFrame.Value; if (traceFrame == null) { throw new InvalidOperationException(ErrorStrings.SetNextStatementOnlyAllowedInsideTraceback); } int sequencePointIndex = GetSequencePointIndexForSourceSpan(sourceFile, sourceSpan, traceFrame); if (sequencePointIndex == Int32.MaxValue) { throw new InvalidOperationException(ErrorStrings.InvalidSourceSpan); } traceFrame.CurrentSequencePointIndex = sequencePointIndex; }
private DebugFrame GetFrame(int index) { DebugFrame frame = null; if (index >= 0) { frame = _frames[index].Frame; if (frame == null) { IDebugRuntimeVariables runtimeVariables = _frames[index].RuntimeVariables as IDebugRuntimeVariables; Debug.Assert(runtimeVariables != null); frame = new DebugFrame(this, runtimeVariables.FunctionInfo, runtimeVariables, index); _frames[index] = new FrameRuntimeVariablesPair(null, frame); } } if (index == _frames.Count - 1) { frame.IsInTraceback = IsInTraceback; frame.ThrownException = ThrownException; } return(frame); }
internal abstract void PushExistingFrame(DebugFrame frame);
public FrameRuntimeVariablesPair(IRuntimeVariables runtimeVariables, DebugFrame frame) { RuntimeVariables = runtimeVariables; Frame = frame; }
private DebugFrame GetFrame(int index) { DebugFrame frame = null; if (index >= 0) { frame = _frames[index].Frame; if (frame == null) { IDebugRuntimeVariables runtimeVariables = _frames[index].RuntimeVariables as IDebugRuntimeVariables; Debug.Assert(runtimeVariables != null); frame = new DebugFrame(this, runtimeVariables.FunctionInfo, runtimeVariables, index); _frames[index] = new FrameRuntimeVariablesPair(null, frame); } } if (index == _frames.Count - 1) { frame.IsInTraceback = IsInTraceback; frame.ThrownException = ThrownException; } return frame; }
internal override void PushExistingFrame(DebugFrame frame) { _frames.Add(new FrameRuntimeVariablesPair(null, frame)); }
public static IEnumerator <T> CreateDebugGenerator <T>(DebugFrame frame) { return(new DebugGenerator <T>(frame)); }
public static void ReplaceLiftedLocals(DebugFrame frame, IRuntimeVariables liftedLocals) { frame.ReplaceLiftedLocals(liftedLocals); }
public static DebugThread GetThread(DebugFrame frame) { return(frame.Thread); }
internal abstract bool TryGetLeafFrame(ref DebugFrame frame);
internal DebugGenerator(DebugFrame frame) { _frame = frame; _frame.RemapToGenerator(frame.FunctionInfo.Version); }
private int GetSequencePointIndexForSourceSpan(string sourceFile, SourceSpan sourceSpan, DebugFrame frame) { DebugSourceFile debugSourceFile = _debugContext.Lookup(sourceFile); if (debugSourceFile == null) { return Int32.MaxValue; } DebugSourceSpan debugSourceSpan = new DebugSourceSpan(debugSourceFile, sourceSpan); FunctionInfo leafFrameFuncInfo = frame.FunctionInfo; FunctionInfo funcInfo = debugSourceFile.LookupFunctionInfo(debugSourceSpan); // Verify that funcInfo matches the current frame if (funcInfo != leafFrameFuncInfo) { return Int32.MaxValue; } // Get the target sequence point return debugSourceSpan.GetSequencePointIndex(funcInfo); }
private int GetSequencePointIndexForSourceSpan(string sourceFile, SourceSpan sourceSpan, DebugFrame frame) { DebugSourceFile debugSourceFile = _debugContext.Lookup(sourceFile); if (debugSourceFile == null) { return(Int32.MaxValue); } DebugSourceSpan debugSourceSpan = new DebugSourceSpan(debugSourceFile, sourceSpan); FunctionInfo leafFrameFuncInfo = frame.FunctionInfo; FunctionInfo funcInfo = debugSourceFile.LookupFunctionInfo(debugSourceSpan); // Verify that funcInfo matches the current frame if (funcInfo != leafFrameFuncInfo) { return(Int32.MaxValue); } // Get the target sequence point return(debugSourceSpan.GetSequencePointIndex(funcInfo)); }