internal ICorDebugGCHeapSegment(ICorDebugGCHeap heap, ref COR_SEGMENT corSegment) { Debug.Assert(heap.m_process != null); // Only call this on live heaps. m_heap = heap; m_start = corSegment.start; m_end = corSegment.end; m_heapNum = (int)corSegment.heap; }
internal ICorDebugGCHeapType(ICorDebugGCHeap heap, string typeName, string moduleFilePath) { m_heap = heap; m_index = heap.m_types.Count; heap.m_types.Add(this); m_name = typeName; m_moduleFilePath = moduleFilePath; m_typeKind = CorElementType.ELEMENT_TYPE_CLASS; m_isArray = false; }
internal ICorDebugGCHeapRoot(ref COR_GC_REFERENCE root, ICorDebugGCHeap heap, StringBuilder buffer) { Address address; Address objRef = 0; root.Location.GetAddress(out address); m_addressOfRoot = address; string adName = ""; if (root.Domain != null) { uint nameSize; root.Domain.GetName((uint)buffer.Capacity, out nameSize, buffer); adName = buffer.ToString(); } m_appDomain = new ICorDebugAD(adName); var asRef = root.Location as ICorDebugReferenceValue; if (asRef != null) { asRef.GetValue(out objRef); m_heapReference = objRef; } else if (root.Location != null) { root.Location.GetAddress(out objRef); m_heapReference = objRef; } else { Console.WriteLine("ERROR! could not fetch value from root 0x{0:x}", address); } Debug.Assert(Object == 0 || heap.IsInHeap(Object)); m_type = null; if (root.Type == CorGCReferenceType.CorHandleStrong) { m_kind = GCRootKind.Strong; m_name = "Strong Handle"; } else if (root.Type == CorGCReferenceType.CorHandleStrongPinning) { m_kind = GCRootKind.Pinning; m_name = "Pinning Handle"; } else if (root.Type == CorGCReferenceType.CorHandleWeakShort) { m_kind = GCRootKind.Weak; m_name = "Weak Handle"; } else if (root.Type == CorGCReferenceType.CorReferenceStack) { m_kind = GCRootKind.LocalVar; m_name = "Local Variable"; } else if (root.Type == CorGCReferenceType.CorReferenceFinalizer) { m_kind = GCRootKind.Finalizer; m_name = "Finalization"; } else if (root.Type == CorGCReferenceType.CorHandleStrongAsyncPinned) { m_kind = GCRootKind.AsyncPinning; m_name = "Async Pinning"; } else { m_kind = GCRootKind.Strong; // TODO FIX NOW complete the enumeration. m_name = "Other Handle"; } }
private static ICorDebugGCHeapType GetTypeFromNames(Dictionary <string, ICorDebugGCHeapType> types, string className, string moduleFilePath, ICorDebugGCHeap heap) { ICorDebugGCHeapType ret; if (types.TryGetValue(className, out ret)) { return(ret); } ret = new ICorDebugGCHeapType(heap, className, moduleFilePath); types.Add(className, ret); return(ret); }
} // Used for deserialization internal ICorDebugGCHeapType(ICorDebugGCHeap heap, COR_TYPEID typeID) { // Console.WriteLine("Creating type for typeId {0:x} {1:x}", typeID.token1, typeID.token2); m_heap = heap; m_index = heap.m_types.Count; m_name = ""; m_moduleFilePath = ""; heap.m_typeTable[typeID] = this; heap.m_types.Add(this); COR_TYPE_LAYOUT header = new COR_TYPE_LAYOUT(); // Console.WriteLine("Calling GetTypeLayout for typeId {0:x} {1:x}", typeID.token1, typeID.token2); heap.m_process5.GetTypeLayout(typeID, out header); m_typeKind = header.type; m_boxOffset = header.boxOffset; m_size = header.objectSize; // Strings are considered arrays. m_isArray = (header.type == CorElementType.ELEMENT_TYPE_ARRAY || header.type == CorElementType.ELEMENT_TYPE_SZARRAY || header.type == CorElementType.ELEMENT_TYPE_STRING); if (m_isArray) { // Console.WriteLine("Calling GetArrayLayout for typeId {0:x} {1:x}", typeID.token1, typeID.token2); heap.m_process5.GetArrayLayout(typeID, out m_array); m_elementType = heap.GetObjectTypeFromID(m_array.componentID); m_moduleFilePath = ComponentType.Module.FileName; if (m_typeKind == CorElementType.ELEMENT_TYPE_SZARRAY) { m_name = ComponentType.Name + "[]"; } else if (m_typeKind == CorElementType.ELEMENT_TYPE_ARRAY) { if (m_array.numRanks == 1) { m_name = ComponentType.Name + "[*]"; } else { m_name = ComponentType.Name + "[" + new string(',', m_array.numRanks - 1) + "]"; } Debug.Assert(m_array.firstElementOffset > m_array.rankOffset); } else if (m_typeKind == CorElementType.ELEMENT_TYPE_STRING) { m_name = "System.String"; } Debug.Assert(m_array.firstElementOffset > 0); } else { if (header.parentID.token1 != 0 || header.parentID.token2 != 0) // If we have a parent get it. { m_baseType = heap.GetObjectTypeFromID(header.parentID); } SetNameModuleAndFields(m_typeKind, typeID, header.numFields); #if DEBUG if (m_fields != null) { foreach (var field in m_fields) { Debug.Assert(field != null); } } #endif } }