void CollectData32() { if (TranslatePointer(memHeader32->RootFuncInfoAddress) == null) { return; } ulong now = GetRdtsc(); ThreadLocalData32 *item = (ThreadLocalData32 *)TranslatePointer(this.memHeader32->LastThreadListItem); List <Stack <int> > stackList = new List <Stack <int> >(); while (item != null) { StackEntry32 *entry = (StackEntry32 *)TranslatePointer(item->Stack.Array); Stack <int> itemIDs = new Stack <int>(); while (entry != null && entry <= (StackEntry32 *)TranslatePointer(item->Stack.TopPointer)) { FunctionInfo *function = (FunctionInfo *)TranslatePointer(entry->Function); itemIDs.Push(function->Id); function->TimeSpent += now - entry->StartTime; entry++; } stackList.Add(itemIDs); item = (ThreadLocalData32 *)TranslatePointer(item->Predecessor); } if (this.enableDC) { this.AddDataset(fullView.Pointer, memHeader32->NativeAddress + memHeader32->HeapOffset, memHeader32->Allocator.startPos - memHeader32->NativeAddress, memHeader32->Allocator.pos - memHeader32->Allocator.startPos, isFirstDC, memHeader32->RootFuncInfoAddress); isFirstDC = false; } ZeroMemory(new IntPtr(TranslatePointer(memHeader32->Allocator.startPos)), new IntPtr(memHeader32->Allocator.pos - memHeader32->Allocator.startPos)); memHeader32->Allocator.pos = memHeader32->Allocator.startPos; Allocator32.ClearFreeList(&memHeader32->Allocator); FunctionInfo *root = CreateFunctionInfo(0, 0, stackList.Count); memHeader32->RootFuncInfoAddress = TranslatePointerBack32(root); item = (ThreadLocalData32 *)TranslatePointer(this.memHeader32->LastThreadListItem); now = GetRdtsc(); foreach (Stack <int> thread in stackList) { FunctionInfo *child = null; StackEntry32 *entry = (StackEntry32 *)TranslatePointer(item->Stack.TopPointer); while (thread.Count > 0) { FunctionInfo *stackItem = CreateFunctionInfo(thread.Pop(), 0, child != null ? 1 : 0); if (child != null) { FunctionInfo.AddOrUpdateChild32(stackItem, child, this); } entry->Function = TranslatePointerBack32(stackItem); entry->StartTime = now; entry--; child = stackItem; } if (child != null) { FunctionInfo.AddOrUpdateChild32(root, child, this); } item = (ThreadLocalData32 *)TranslatePointer(item->Predecessor); } }
public fixed UInt32 freeList[32]; // Need UInt32 instead of TargetProcessPointer32 // because of fixed public static void ClearFreeList(Allocator32 *a) { for (int i = 0; i < 32; i++) { a->freeList[i] = 0; } }