Esempio n. 1
0
        internal unsafe IList <ClrRoot> EnumerateStackRoots(ClrThread thread)
        {
            int contextSize;

            var plat = m_dataReader.GetArchitecture();

            if (plat == Architecture.Amd64)
            {
                contextSize = 0x4d0;
            }
            else if (plat == Architecture.X86)
            {
                contextSize = 0x2d0;
            }
            else if (plat == Architecture.Arm)
            {
                contextSize = 0x1a0;
            }
            else
            {
                throw new InvalidOperationException("Unexpected architecture.");
            }

            byte[] context = new byte[contextSize];
            m_dataReader.GetThreadContext(thread.OSThreadId, 0, (uint)contextSize, context);

            var walker                  = new RhStackRootWalker(GetHeap(), GetRhAppDomain(), thread);
            THREADROOTCALLBACK del      = new THREADROOTCALLBACK(walker.Callback);
            IntPtr             callback = Marshal.GetFunctionPointerForDelegate(del);

            fixed(byte *b = &context[0])
            {
                IntPtr ctx = new IntPtr(b);

                m_sos.TraverseStackRoots(thread.Address, ctx, contextSize, callback, IntPtr.Zero);
            }

            GC.KeepAlive(del);

            return(walker.Roots);
        }
Esempio n. 2
0
        internal unsafe IList<ClrRoot> EnumerateStackRoots(ClrThread thread)
        {
            int contextSize;

            var plat = m_dataReader.GetArchitecture();
            if (plat == Architecture.Amd64)
                contextSize = 0x4d0;
            else if (plat == Architecture.X86)
                contextSize = 0x2d0;
            else if (plat == Architecture.Arm)
                contextSize = 0x1a0;
            else
                throw new InvalidOperationException("Unexpected architecture.");
            
            byte[] context = new byte[contextSize];
            m_dataReader.GetThreadContext(thread.OSThreadId, 0, (uint)contextSize, context);

            var walker = new RhStackRootWalker(GetHeap(), GetRhAppDomain(), thread);
            THREADROOTCALLBACK del = new THREADROOTCALLBACK(walker.Callback);
            IntPtr callback = Marshal.GetFunctionPointerForDelegate(del);

            fixed (byte* b = &context[0])
            {
                IntPtr ctx = new IntPtr(b);
                m_sos.TraverseStackRoots(thread.Address, ctx, contextSize, callback, IntPtr.Zero);
            }
            GC.KeepAlive(del);

            return walker.Roots;
        }