public override Table GetTableByName(string name, ParameterSet param) { if (name == ObjectTable.TableName) { ulong obj; if (!TryGetParam(param, ObjectTable.ObjParamName, out obj)) { return(null); } int iType; if (!TryGetParam(param, ObjectTable.TypeParamName, out iType)) { iType = -1; } ObjectData od = ObjectData.FromManagedPointer(m_Snapshot, obj, iType); var table = new ObjectSingleTable(this, formatter, m_Snapshot, m_Snapshot.CrawledData, od, od.isNative ? ObjectTable.ObjectMetaType.Native : ObjectTable.ObjectMetaType.Managed); return(table); } else if (name == ObjectReferenceTable.kObjectReferenceTableName) { int objUnifiedIndex; if (!TryGetParam(param, ObjectTable.ObjParamName, out objUnifiedIndex)) { return(null); } var od = ObjectData.FromUnifiedObjectIndex(m_Snapshot, objUnifiedIndex); var table = new ObjectReferenceTable(this, formatter, m_Snapshot, m_Snapshot.CrawledData, od, ObjectTable.ObjectMetaType.All); //, od.isNative ? ObjectTable.ObjectMetaType.Native : ObjectTable.ObjectMetaType.Managed); return(table); //ObjectReferenceTable } else { return(GetTableByName(name)); } }
public static ObjectData[] GetAllObjectConnectingTo(CachedSnapshot snapshot, ObjectData obj) { var o = new List <ObjectData>(); int objIndex = -1; switch (obj.dataType) { case ObjectDataType.Array: case ObjectDataType.BoxedValue: case ObjectDataType.Object: { ManagedObjectInfo moi; if (snapshot.CrawledData.ManagedObjectByAddress.TryGetValue(obj.hostManagedObjectPtr, out moi)) { objIndex = snapshot.ManagedObjectIndexToUnifiedObjectIndex(moi.ManagedObjectIndex); //add crawled connections for (int i = 0; i != snapshot.CrawledData.Connections.Count; ++i) { var c = snapshot.CrawledData.Connections[i]; switch (c.connectionType) { case ManagedConnection.ConnectionType.Global_To_ManagedObject: if (c.toManagedObjectIndex == moi.ManagedObjectIndex) { o.Add(ObjectData.global); } break; case ManagedConnection.ConnectionType.ManagedObject_To_ManagedObject: if (c.toManagedObjectIndex == moi.ManagedObjectIndex) { var objParent = ObjectData.FromManagedObjectIndex(snapshot, c.fromManagedObjectIndex); if (c.fieldFrom >= 0) { if (objParent.dataType == ObjectDataType.Array || objParent.dataType == ObjectDataType.ReferenceArray) { o.Add(objParent); } else { o.Add(objParent.GetInstanceFieldBySnapshotFieldIndex(snapshot, c.fieldFrom, false)); } } else if (c.arrayIndexFrom >= 0) { o.Add(objParent.GetArrayElement(snapshot, c.arrayIndexFrom, false)); } else { o.Add(objParent); } } break; case ManagedConnection.ConnectionType.ManagedType_To_ManagedObject: if (c.toManagedObjectIndex == moi.ManagedObjectIndex) { var objType = ObjectData.FromManagedType(snapshot, c.fromManagedType); if (c.fieldFrom >= 0) { o.Add(objType.GetInstanceFieldBySnapshotFieldIndex(snapshot, c.fieldFrom, false)); } else if (c.arrayIndexFrom >= 0) { o.Add(objType.GetArrayElement(snapshot, c.arrayIndexFrom, false)); } else { o.Add(objType); } } break; case ManagedConnection.ConnectionType.UnityEngineObject: if (c.UnityEngineManagedObjectIndex == moi.ManagedObjectIndex) { o.Add(ObjectData.FromNativeObjectIndex(snapshot, c.UnityEngineNativeObjectIndex)); } break; } } } break; } case ObjectDataType.NativeObject: objIndex = snapshot.NativeObjectIndexToUnifiedObjectIndex(obj.nativeObjectIndex); //add crawled connection for (int i = 0; i != snapshot.CrawledData.Connections.Count; ++i) { switch (snapshot.CrawledData.Connections[i].connectionType) { case ManagedConnection.ConnectionType.Global_To_ManagedObject: case ManagedConnection.ConnectionType.ManagedObject_To_ManagedObject: case ManagedConnection.ConnectionType.ManagedType_To_ManagedObject: break; case ManagedConnection.ConnectionType.UnityEngineObject: if (snapshot.CrawledData.Connections[i].UnityEngineNativeObjectIndex == obj.nativeObjectIndex) { o.Add(ObjectData.FromManagedObjectIndex(snapshot, snapshot.CrawledData.Connections[i].UnityEngineManagedObjectIndex)); } break; } } break; default: return(null); } //add connections from the raw snapshot if (objIndex >= 0) { for (int i = 0; i != snapshot.connections.Count; ++i) { if (snapshot.connections.to[i] == objIndex) { o.Add(ObjectData.FromUnifiedObjectIndex(snapshot, snapshot.connections.from[i])); } } } return(o.ToArray()); }