示例#1
0
        internal StackFrame GetStackFrameAt(uint chainIndex, uint frameIndex)
        {
            process.AssertPaused();

            ICorDebugChainEnum corChainEnum = CorThread.EnumerateChains();

            if (chainIndex >= corChainEnum.Count)
            {
                throw new DebuggerException("The requested chain index is too big");
            }
            corChainEnum.Skip(corChainEnum.Count - chainIndex - 1);
            ICorDebugChain corChain = corChainEnum.Next();

            if (corChain.IsManaged == 0)
            {
                throw new DebuggerException("The requested chain is not managed");
            }

            ICorDebugFrameEnum corFrameEnum = corChain.EnumerateFrames();

            if (frameIndex >= corFrameEnum.Count)
            {
                throw new DebuggerException("The requested frame index is too big");
            }
            corFrameEnum.Skip(corFrameEnum.Count - frameIndex - 1);
            ICorDebugFrame corFrame = corFrameEnum.Next();

            if (!corFrame.Is <ICorDebugILFrame>())
            {
                throw new DebuggerException("The rquested frame is not IL frame");
            }

            StackFrame stackFrame = new StackFrame(this, corFrame.CastTo <ICorDebugILFrame>(), chainIndex, frameIndex);

            return(stackFrame);
        }