internal override IEnumerable<ICodeHeap> EnumerateJitHeaps() { LegacyJitManagerInfo[] jitManagers = null; uint needed = 0; int res = _sos.GetJitManagerList(0, null, out needed); if (res >= 0) { jitManagers = new LegacyJitManagerInfo[needed]; res = _sos.GetJitManagerList(needed, jitManagers, out needed); } if (res >= 0 && jitManagers != null) { for (int i = 0; i < jitManagers.Length; ++i) { if (jitManagers[i].type != CodeHeapType.Unknown) continue; res = _sos.GetCodeHeapList(jitManagers[i].addr, 0, null, out needed); if (res >= 0 && needed > 0) { LegacyJitCodeHeapInfo[] heapInfo = new LegacyJitCodeHeapInfo[needed]; res = _sos.GetCodeHeapList(jitManagers[i].addr, needed, heapInfo, out needed); if (res >= 0) { for (int j = 0; j < heapInfo.Length; ++j) { yield return (ICodeHeap)heapInfo[i]; } } } } } }
internal override IEnumerable<ICodeHeap> EnumerateJitHeaps() { byte[] output = new byte[sizeof(int)]; if (Request(DacRequests.JITLIST, null, output)) { int JitManagerSize = Marshal.SizeOf(typeof(LegacyJitManagerInfo)); int count = BitConverter.ToInt32(output, 0); int size = JitManagerSize * count; if (size > 0) { output = new byte[size]; if (Request(DacRequests.MANAGER_LIST, null, output)) { LegacyJitCodeHeapInfo heapInfo = new LegacyJitCodeHeapInfo(); int CodeHeapTypeOffset = Marshal.OffsetOf(typeof(LegacyJitCodeHeapInfo), "codeHeapType").ToInt32(); int AddressOffset = Marshal.OffsetOf(typeof(LegacyJitCodeHeapInfo), "address").ToInt32(); int CurrAddrOffset = Marshal.OffsetOf(typeof(LegacyJitCodeHeapInfo), "currentAddr").ToInt32(); int JitCodeHeapInfoSize = Marshal.SizeOf(typeof(LegacyJitCodeHeapInfo)); for (int i = 0; i < count; ++i) { int type = BitConverter.ToInt32(output, i * JitManagerSize + sizeof(ulong)); // Is this code heap IL? if ((type & 3) != 0) continue; ulong address = BitConverter.ToUInt64(output, i * JitManagerSize); byte[] jitManagerBuffer = new byte[sizeof(ulong) * 2]; WriteValueToBuffer(address, jitManagerBuffer, 0); if (Request(DacRequests.JITHEAPLIST, jitManagerBuffer, jitManagerBuffer)) { int heapCount = BitConverter.ToInt32(jitManagerBuffer, sizeof(ulong)); byte[] codeHeapBuffer = new byte[heapCount * JitCodeHeapInfoSize]; if (Request(DacRequests.CODEHEAP_LIST, jitManagerBuffer, codeHeapBuffer)) { for (int j = 0; j < heapCount; ++j) { heapInfo.address = BitConverter.ToUInt64(codeHeapBuffer, j * JitCodeHeapInfoSize + AddressOffset); heapInfo.codeHeapType = BitConverter.ToUInt32(codeHeapBuffer, j * JitCodeHeapInfoSize + CodeHeapTypeOffset); heapInfo.currentAddr = BitConverter.ToUInt64(codeHeapBuffer, j * JitCodeHeapInfoSize + CurrAddrOffset); yield return (ICodeHeap)heapInfo; } } } } } } } }