Esempio n. 1
0
        private ulong FindWaitHandle(ulong start, ulong stop, HashSet <string> eventTypes)
        {
            ClrHeap heap = m_runtime.GetHeap();

            foreach (ulong obj in EnumerateObjectsOfTypes(start, stop, eventTypes))
            {
                return(obj);
            }

            return(0);
        }
Esempio n. 2
0
 public DesktopMethod(DesktopRuntimeBase runtime, ulong md, IMethodDescData mdData, MethodAttributes attrs)
 {
     m_runtime = runtime;
     m_sig = runtime.GetNameForMD(md);
     m_ip = mdData.NativeCodeAddr;
     m_jit = mdData.JITType;
     m_attrs = attrs;
     m_token = mdData.MDToken;
     var heap = (DesktopGCHeap)runtime.GetHeap();
     m_type = heap.GetGCHeapType(mdData.MethodTable, 0);
 }
Esempio n. 3
0
 public DesktopMethod(DesktopRuntimeBase runtime, ulong md, IMethodDescData mdData, MethodAttributes attrs)
 {
     _runtime = runtime;
     _sig = runtime.GetNameForMD(md);
     _ip = mdData.NativeCodeAddr;
     _jit = mdData.JITType;
     _attrs = attrs;
     _token = mdData.MDToken;
     var heap = runtime.GetHeap();
     _type = (DesktopHeapType)heap.GetTypeByMethodTable(mdData.MethodTable, 0);
 }
Esempio n. 4
0
        public DesktopMethod(DesktopRuntimeBase runtime, ulong md, IMethodDescData mdData, MethodAttributes attrs)
        {
            m_runtime = runtime;
            m_sig     = runtime.GetNameForMD(md);
            m_ip      = mdData.NativeCodeAddr;
            m_jit     = mdData.JITType;
            m_attrs   = attrs;
            m_token   = mdData.MDToken;
            var heap = (DesktopGCHeap)runtime.GetHeap();

            m_type = heap.GetGCHeapType(mdData.MethodTable, 0);
        }
Esempio n. 5
0
        public DesktopMethod(DesktopRuntimeBase runtime, ulong md, IMethodDescData mdData, MethodAttributes attrs)
        {
            _runtime = runtime;
            _sig     = runtime.GetNameForMD(md);
            _ip      = mdData.NativeCodeAddr;
            _jit     = mdData.JITType;
            _attrs   = attrs;
            _token   = mdData.MDToken;
            _gcInfo  = mdData.GCInfo;
            var heap = runtime.GetHeap();

            _type        = (DesktopHeapType)heap.GetTypeByMethodTable(mdData.MethodTable, 0);
            _hotColdInfo = new HotColdRegions()
            {
                HotStart = _ip, HotSize = mdData.HotSize, ColdStart = mdData.ColdStart, ColdSize = mdData.ColdSize
            };
        }
Esempio n. 6
0
        public override IEnumerable <ClrType> EnumerateTypes()
        {
            var heap   = (DesktopGCHeap)_runtime.GetHeap();
            var mtList = _runtime.GetMethodTableList(_address);

            if (_typesLoaded)
            {
                foreach (var type in heap.EnumerateTypes())
                {
                    if (type.Module == this)
                    {
                        yield return(type);
                    }
                }
            }
            else
            {
                if (mtList != null)
                {
                    foreach (ulong mt in mtList)
                    {
                        if (mt != _runtime.ArrayMethodTable)
                        {
                            // prefetch element type, as this also can load types
                            var type = heap.GetGCHeapType(mt, 0, 0);
                            if (type != null)
                            {
                                yield return(type);
                            }
                        }
                    }
                }

                _typesLoaded = true;
            }
        }
Esempio n. 7
0
 public HandleTableWalker(DesktopRuntimeBase dac)
 {
     _runtime = dac;
     _heap    = dac.GetHeap();
     Handles  = new List <ClrHandle>();
 }
Esempio n. 8
0
        private IEnumerable <ulong> EnumerateManagedThreadpoolObjects()
        {
            _heap = _runtime.GetHeap();

            ClrModule mscorlib = GetMscorlib();

            if (mscorlib != null)
            {
                ClrType queueType = mscorlib.GetTypeByName("System.Threading.ThreadPoolGlobals");
                if (queueType != null)
                {
                    ClrStaticField workQueueField = queueType.GetStaticFieldByName("workQueue");
                    if (workQueueField != null)
                    {
                        foreach (var appDomain in _runtime.AppDomains)
                        {
                            object  workQueueValue = workQueueField.GetValue(appDomain);
                            ulong   workQueue      = workQueueValue == null ? 0L : (ulong)workQueueValue;
                            ClrType workQueueType  = _heap.GetObjectType(workQueue);

                            if (workQueue == 0 || workQueueType == null)
                            {
                                continue;
                            }

                            ulong   queueHead;
                            ClrType queueHeadType;
                            do
                            {
                                if (!GetFieldObject(workQueueType, workQueue, "queueHead", out queueHeadType, out queueHead))
                                {
                                    break;
                                }

                                ulong   nodes;
                                ClrType nodesType;
                                if (GetFieldObject(queueHeadType, queueHead, "nodes", out nodesType, out nodes) && nodesType.IsArray)
                                {
                                    int len = nodesType.GetArrayLength(nodes);
                                    for (int i = 0; i < len; ++i)
                                    {
                                        ulong addr = (ulong)nodesType.GetArrayElementValue(nodes, i);
                                        if (addr != 0)
                                        {
                                            yield return(addr);
                                        }
                                    }
                                }

                                if (!GetFieldObject(queueHeadType, queueHead, "Next", out queueHeadType, out queueHead))
                                {
                                    break;
                                }
                            } while (queueHead != 0);
                        }
                    }
                }


                queueType = mscorlib.GetTypeByName("System.Threading.ThreadPoolWorkQueue");
                if (queueType != null)
                {
                    ClrStaticField threadQueuesField = queueType.GetStaticFieldByName("allThreadQueues");
                    if (threadQueuesField != null)
                    {
                        foreach (ClrAppDomain domain in _runtime.AppDomains)
                        {
                            ulong?threadQueue = (ulong?)threadQueuesField.GetValue(domain);
                            if (!threadQueue.HasValue || threadQueue.Value == 0)
                            {
                                continue;
                            }

                            ClrType threadQueueType = _heap.GetObjectType(threadQueue.Value);
                            if (threadQueueType == null)
                            {
                                continue;
                            }

                            ulong   outerArray     = 0;
                            ClrType outerArrayType = null;
                            if (!GetFieldObject(threadQueueType, threadQueue.Value, "m_array", out outerArrayType, out outerArray) || !outerArrayType.IsArray)
                            {
                                continue;
                            }

                            int outerLen = outerArrayType.GetArrayLength(outerArray);
                            for (int i = 0; i < outerLen; ++i)
                            {
                                ulong entry = (ulong)outerArrayType.GetArrayElementValue(outerArray, i);
                                if (entry == 0)
                                {
                                    continue;
                                }

                                ClrType entryType = _heap.GetObjectType(entry);
                                if (entryType == null)
                                {
                                    continue;
                                }

                                ulong   array;
                                ClrType arrayType;
                                if (!GetFieldObject(entryType, entry, "m_array", out arrayType, out array) || !arrayType.IsArray)
                                {
                                    continue;
                                }

                                int len = arrayType.GetArrayLength(array);
                                for (int j = 0; j < len; ++j)
                                {
                                    ulong addr = (ulong)arrayType.GetArrayElementValue(array, i);
                                    if (addr != 0)
                                    {
                                        yield return(addr);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 9
0
 public HandleTableWalker(DesktopRuntimeBase dac)
 {
     m_runtime = dac;
     m_heap = dac.GetHeap();
     Handles = new List<ClrHandle>();
 }