예제 #1
0
        public static CrawledMemorySnapshot Unpack(PackedCrawlerData packedCrawlerData)
        {
            var packedSnapshot = packedCrawlerData.packedMemorySnapshot;

            var result = new CrawledMemorySnapshot
            {
                nativeObjects             = packedSnapshot.nativeObjects.Select(packedNativeUnityEngineObject => UnpackNativeUnityEngineObject(packedSnapshot, packedNativeUnityEngineObject)).ToArray(),
                managedObjects            = packedCrawlerData.managedObjects.Select(pm => UnpackManagedObject(packedSnapshot, pm)).ToArray(),
                gcHandles                 = packedSnapshot.gcHandles.Select(pgc => UnpackGCHandle(packedSnapshot)).ToArray(),
                staticFields              = packedSnapshot.typeDescriptions.Where(t => t.staticFieldBytes != null & t.staticFieldBytes.Length > 0).Select(t => UnpackStaticFields(t)).ToArray(),
                typeDescriptions          = packedSnapshot.typeDescriptions,
                managedHeap               = packedSnapshot.managedHeapSections,
                nativeTypes               = packedSnapshot.nativeTypes,
                virtualMachineInformation = packedSnapshot.virtualMachineInformation
            };

            result.FinishSnapshot();

            var referencesLists   = MakeTempLists(result.allObjects);
            var referencedByLists = MakeTempLists(result.allObjects);

            foreach (var connection in packedCrawlerData.connections)
            {
                if (connection.@from >= referencesLists.Length || connection.to >= result.allObjects.Length ||
                    connection.to >= referencedByLists.Length || connection.@from >= result.allObjects.Length)
                {
                    continue;
                }
                referencesLists[connection.@from].Add(result.allObjects[connection.to]);
                referencedByLists[connection.to].Add(result.allObjects[connection.@from]);
            }

            for (var i = 0; i != result.allObjects.Length; i++)
            {
                result.allObjects[i].references   = referencesLists[i].ToArray();
                result.allObjects[i].referencedBy = referencedByLists[i].ToArray();
            }

            return(result);
        }
예제 #2
0
 public ShortestPathToRootFinder(CrawledMemorySnapshot snapshot)
 {
     _snapshot = snapshot;
 }