Пример #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());
        }
 public Wrappers.CorDebug.ICorDebugChainEnum EnumerateChains()
 {
     Wrappers.CorDebug.ICorDebugChainEnum ppChains;
     Interop.CorDebug.ICorDebugChainEnum  out_ppChains;
     this.WrappedObject.EnumerateChains(out out_ppChains);
     ppChains = ICorDebugChainEnum.Wrap(out_ppChains);
     return(ppChains);
 }
Пример #3
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);
            }
        }