public void Print(ClrObject clrObject) { if (clrObject.Type == null) { return; } var items = clrObject.GetObjectField("_items"); if (items.Type == null) { return; } var len = items.Type.GetArrayLength(items); for (var i = 0; i < len; ++i) { var elementAddress = items.Type.GetArrayElementAddress(items, i); items.Type.Heap.ReadPointer(elementAddress, out var objectAddress); var obj = new ClrObject( objectAddress, items.Type.Heap.GetObjectType(objectAddress)); if (obj.Type == null) { return; } var strKey = ClrMdHelper.ToString(obj); Console.WriteLine(strKey); } }
public void Print(ClrObject clrObject) { var entries = clrObject.GetObjectField("_entries"); if (entries.IsNull) { return; } var count = clrObject.GetField <int>("_count"); var arrayType = entries.Type; var elementType = arrayType.ComponentType; var entriesLength = count; for (var i = 0; i < entriesLength; i++) { var entryAddr = arrayType.GetArrayElementAddress(entries.Address, i); var dictEntry = ClrValueClassFactory.Create(entryAddr, elementType); var hash = dictEntry.GetField <int>("hashCode"); if (hash < 0) { continue; } var key = ClrMdHelper.ToString(dictEntry.GetObjectField("key")); var value = ClrMdHelper.ToString(dictEntry.GetObjectField("value")); Console.WriteLine(key + ": " + value); } }
private static void PrintImmutableListNode(ClrObject clrObject) { while (true) { if (clrObject.Type == null) { return; } var key = clrObject.GetObjectField("_key"); if (key.Type == null) { return; } PrintImmutableListNode(clrObject.GetObjectField("_left")); var strKey = ClrMdHelper.ToString(key); Console.WriteLine(strKey); clrObject = clrObject.GetObjectField("_right"); } }