public CorFrame[] GetActiveInternalFrames()
        {
            ICorDebugThread3 th3 = (ICorDebugThread3)m_th;

            UInt32 cInternalFrames = 0;

            th3.GetActiveInternalFrames(0, out cInternalFrames, null);

            ICorDebugInternalFrame2[] ppInternalFrames = new ICorDebugInternalFrame2[cInternalFrames];
            th3.GetActiveInternalFrames(cInternalFrames, out cInternalFrames, ppInternalFrames);

            CorFrame[] corFrames = new CorFrame[cInternalFrames];
            for (int i = 0; i < cInternalFrames; i++)
            {
                corFrames[i] = new CorFrame(ppInternalFrames[i] as ICorDebugFrame);
            }
            return(corFrames);
        }
Beispiel #2
0
        internal unsafe void InitLocalData()
        {
            if (_corDebugInit)
            {
                return;
            }

            _corDebugInit = true;

            ICorDebugThread3   thread = (ICorDebugThread3)CorDebugThread;
            ICorDebugStackWalk stackwalk;

            thread.CreateStackWalk(out stackwalk);

            do
            {
                ICorDebugFrame frame;
                stackwalk.GetFrame(out frame);

                ICorDebugILFrame ilFrame = frame as ICorDebugILFrame;
                if (ilFrame == null)
                {
                    continue;
                }

                byte[] context = ContextHelper.Context;

                uint size;

                fixed(byte *ptr = context)
                stackwalk.GetContext(ContextHelper.ContextFlags, ContextHelper.Length, out size, new IntPtr(ptr));

                ulong ip = BitConverter.ToUInt32(context, ContextHelper.InstructionPointerOffset);
                ulong sp = BitConverter.ToUInt32(context, ContextHelper.StackPointerOffset);

                DesktopStackFrame result = _stackTrace.Where(frm => sp == frm.StackPointer && ip == frm.InstructionPointer).Select(p => (DesktopStackFrame)p).SingleOrDefault();
                if (result != null)
                {
                    result.CordbFrame = ilFrame;
                }
            } while (stackwalk.Next() == 0);
        }
        /**
         * If PureV3StackWalk is specified, then this method returns a CorStackWalk, which does not expose
         * ICorDebugInternalFrames.  If ExtendedV3StackWalk is specified, then this method returns a
         * CorStackWalkEx, which derives from CorStackWalk and interleaves ICorDebugInternalFrames.
         */
        public CorStackWalk CreateStackWalk(CorStackWalkType type)
        {
            ICorDebugThread3 th3 = m_th as ICorDebugThread3;

            if (th3 == null)
            {
                return(null);
            }

            ICorDebugStackWalk s = null;

            th3.CreateStackWalk(out s);
            if (type == CorStackWalkType.PureV3StackWalk)
            {
                return(new CorStackWalk(s, this));
            }
            else
            {
                return(new CorStackWalkEx(s, this));
            }
        }