コード例 #1
0
        internal ICorDebugFrame GetFrameAt(FrameID frameID)
        {
            process.AssertPaused();

            ICorDebugChainEnum corChainEnum = CorThread.EnumerateChains();

            if (frameID.ChainIndex >= corChainEnum.Count)
            {
                throw new ArgumentException("Chain index too big", "chainIndex");
            }
            corChainEnum.Skip(corChainEnum.Count - frameID.ChainIndex - 1);

            ICorDebugChain corChain = corChainEnum.Next();

            if (corChain.IsManaged == 0)
            {
                throw new ArgumentException("Chain is not managed", "chainIndex");
            }

            ICorDebugFrameEnum corFrameEnum = corChain.EnumerateFrames();

            if (frameID.FrameIndex >= corFrameEnum.Count)
            {
                throw new ArgumentException("Frame index too big", "frameIndex");
            }
            corFrameEnum.Skip(corFrameEnum.Count - frameID.FrameIndex - 1);

            return(corFrameEnum.Next());
        }
コード例 #2
0
        public static ICorDebugChain Next(this ICorDebugChainEnum corChainEnum)
        {
            ICorDebugChain[] corChains     = new ICorDebugChain[] { null };
            uint             chainsFetched = corChainEnum.Next(1, corChains);

            return(corChains[0]);
        }
コード例 #3
0
 public static IEnumerable <ICorDebugChain> GetEnumerator(this ICorDebugChainEnum corEnum)
 {
     corEnum.Reset();
     while (true)
     {
         ICorDebugChain[] corChains = new ICorDebugChain[EnumerateBufferSize];
         uint             fetched   = corEnum.Next(EnumerateBufferSize, corChains);
         if (fetched == 0)
         {
             yield break;
         }
         for (int i = 0; i < fetched; i++)
         {
             yield return(corChains[i]);
         }
     }
 }
コード例 #4
0
        int ICorDebugThread.EnumerateChains(out ICorDebugChainEnum ppChains)
        {
            Debug.Assert(!IsVirtualThread);

            ArrayList chains = new ArrayList();

            for (CorDebugThread thread = this.GetLastCorDebugThread(); thread != null; thread = thread.m_threadPrevious)
            {
                CorDebugChain chain = thread.Chain;

                if (chain != null)
                {
                    chains.Add(chain);
                }
            }

            ppChains = new CorDebugEnum(chains, typeof(ICorDebugChain), typeof(ICorDebugChainEnum));

            return(Utility.COM_HResults.S_OK);
        }
コード例 #5
0
ファイル: Thread.cs プロジェクト: wmade/SoftwareZator-2012
        internal StackFrame GetStackFrameAt(uint chainIndex, uint frameIndex)
        {
            process.AssertPaused();

            ICorDebugChainEnum corChainEnum = CorThread.EnumerateChains();

            if (chainIndex >= corChainEnum.GetCount())
            {
                throw new DebuggerException("The requested chain index is too big");
            }
            corChainEnum.Skip(corChainEnum.GetCount() - 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.GetCount())
            {
                throw new DebuggerException("The requested frame index is too big");
            }
            corFrameEnum.Skip(corFrameEnum.GetCount() - 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, (ICorDebugILFrame)corFrame, chainIndex, frameIndex);

            return(stackFrame);
        }
コード例 #6
0
 internal CorChainEnumerator(ICorDebugChainEnum chainEnumerator)
 {
     m_enum = chainEnumerator;
 }
コード例 #7
0
        // See docs\Stepping.txt
        public void CheckExpiration()
        {
            try {
                ICorDebugChainEnum chainEnum = CorThread.EnumerateChains();
            } catch (COMException e) {
                // 0x8013132D: The state of the thread is invalid.
                // 0x8013134F: Object is in a zombie state
                // 0x80131301: Process was terminated.
                if ((uint)e.ErrorCode == 0x8013132D ||
                    (uint)e.ErrorCode == 0x8013134F ||
                    (uint)e.ErrorCode == 0x80131301)
                {
                    this.Expire();
                    return;
                }
                else
                {
                    throw;
                }
            }

            if (process.Evaluating)
            {
                return;
            }

            ICorDebugChainEnum corChainEnum = CorThread.EnumerateChains();
            int maxChainIndex = (int)corChainEnum.Count - 1;

            ICorDebugFrameEnum corFrameEnum = corChainEnum.Next().EnumerateFrames();
            // corFrameEnum.Count can return 0 in ExitThread callback
            int maxFrameIndex = (int)corFrameEnum.Count - 1;

            ICorDebugFrame lastFrame = corFrameEnum.Next();

            // Check the token of the current function - function can change if there are multiple handlers for an event
            Function function;

            if (lastFrame != null &&
                functionCache.TryGetValue(new FrameID((uint)maxChainIndex, (uint)maxFrameIndex), out function) &&
                function.Token != lastFrame.FunctionToken)
            {
                functionCache.Remove(new FrameID((uint)maxChainIndex, (uint)maxFrameIndex));
                function.OnExpired(EventArgs.Empty);
            }

            // Expire all functions behind the current maximum
            // Multiple functions can expire at once (test case: Step out of Button1Click in simple winforms application)
            List <KeyValuePair <FrameID, Function> > toBeRemoved = new List <KeyValuePair <FrameID, Function> >();

            foreach (KeyValuePair <FrameID, Function> kvp in functionCache)
            {
                if ((kvp.Key.ChainIndex > maxChainIndex) ||
                    (kvp.Key.ChainIndex == maxChainIndex && kvp.Key.FrameIndex > maxFrameIndex))
                {
                    toBeRemoved.Add(kvp);
                }
            }
            foreach (KeyValuePair <FrameID, Function> kvp in toBeRemoved)
            {
                functionCache.Remove(kvp.Key);
                kvp.Value.OnExpired(EventArgs.Empty);
            }
        }
コード例 #8
0
 internal ChainEnumerator(ICorDebugChainEnum e)
 {
     m_enum = e;
 }
コード例 #9
0
 internal CorChainEnumerator(ICorDebugChainEnum chainEnumerator)
 {
     m_enum = chainEnumerator;
 }
コード例 #10
0
        int ICorDebugThread.EnumerateChains(out ICorDebugChainEnum ppChains)
        {
            Debug.Assert(!IsVirtualThread);

            ArrayList chains = new ArrayList();

            for (CorDebugThread thread = this.GetLastCorDebugThread(); thread != null; thread = thread.m_threadPrevious)
            {
                CorDebugChain chain = thread.Chain;

                if (chain != null)
                {
                    chains.Add(chain);
                }
            }

            ppChains = new CorDebugEnum(chains, typeof(ICorDebugChain), typeof(ICorDebugChainEnum));

            return Utility.COM_HResults.S_OK;
        }