Example #1
0
		public static void AddOrUpdateChild64(FunctionInfo* parent, FunctionInfo* child, Profiler profiler)
		{
			int slot = child->Id;
			while (true) {
				slot &= parent->LastChildIndex;
				FunctionInfo* slotContent = (FunctionInfo*)profiler.TranslatePointer(GetChildren64(parent)[slot]);
				if (slotContent == null || slotContent->Id == child->Id) {
					GetChildren64(parent)[slot] = profiler.TranslatePointerBack64(child);
					break;
				}
				slot++;
			}
		}
Example #2
0
		public static TargetProcessPointer32* GetChildren32(FunctionInfo* f)
		{
			if (f == null)
				throw new NullReferenceException();
			return (TargetProcessPointer32*)(f + 1);
		}
Example #3
0
        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);
            }
        }