Beispiel #1
0
        public static int GetCurrentSequencePointForGeneratorFrame(DebugFrame frame)
        {
            Debug.Assert(frame != null);
            Debug.Assert(frame.Generator != null);

            return(frame.CurrentLocationCookie);
        }
Beispiel #2
0
        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;
     }
 }
Beispiel #4
0
        public static bool IsCurrentLeafFrameRemappingToGenerator(DebugThread thread)
        {
            DebugFrame frame = null;

            if (thread.TryGetLeafFrame(ref frame))
            {
                return(frame.ForceSwitchToGeneratorLoop);
            }

            return(false);
        }
Beispiel #5
0
        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;
                }
            }
        }
Beispiel #8
0
        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;
        }
Beispiel #10
0
        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);
        }
Beispiel #11
0
 internal abstract void PushExistingFrame(DebugFrame frame);
Beispiel #12
0
 public FrameRuntimeVariablesPair(IRuntimeVariables runtimeVariables, DebugFrame frame)
 {
     RuntimeVariables = runtimeVariables;
     Frame = frame;
 }
Beispiel #13
0
        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;
        }
Beispiel #14
0
 internal override void PushExistingFrame(DebugFrame frame)
 {
     _frames.Add(new FrameRuntimeVariablesPair(null, frame));
 }
Beispiel #15
0
 internal override void PushExistingFrame(DebugFrame frame)
 {
     _frames.Add(new FrameRuntimeVariablesPair(null, frame));
 }
Beispiel #16
0
 public static IEnumerator <T> CreateDebugGenerator <T>(DebugFrame frame)
 {
     return(new DebugGenerator <T>(frame));
 }
Beispiel #17
0
 public static void ReplaceLiftedLocals(DebugFrame frame, IRuntimeVariables liftedLocals)
 {
     frame.ReplaceLiftedLocals(liftedLocals);
 }
Beispiel #18
0
 public static DebugThread GetThread(DebugFrame frame)
 {
     return(frame.Thread);
 }
Beispiel #19
0
 internal abstract bool TryGetLeafFrame(ref DebugFrame frame);
Beispiel #20
0
 internal DebugGenerator(DebugFrame frame)
 {
     _frame = frame;
     _frame.RemapToGenerator(frame.FunctionInfo.Version);
 }
Beispiel #21
0
 internal abstract bool TryGetLeafFrame(ref DebugFrame frame);
Beispiel #22
0
 public FrameRuntimeVariablesPair(IRuntimeVariables runtimeVariables, DebugFrame frame)
 {
     RuntimeVariables = runtimeVariables;
     Frame            = frame;
 }
Beispiel #23
0
 internal abstract void PushExistingFrame(DebugFrame frame);
Beispiel #24
0
        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));
        }