Exemplo n.º 1
0
        FunctionInfo *CreateFunctionInfo(int id, int indexInParent, int elementCount)
        {
            int tableSize = 4;

            while (elementCount * 4 >= tableSize * 3)
            {
                tableSize *= 2;
            }

            // Allocate the child in memory
            FunctionInfo *newFunction = (FunctionInfo *)Malloc(sizeof(FunctionInfo) + tableSize * (is64Bit ? 8 : 4));

            // the allocater takes care of zeroing the memory

            // Set field values
            newFunction->Id         = id;
            newFunction->TimeSpent  = (ulong)indexInParent << 56;
            newFunction->TimeSpent |= (ulong)1 << 55;
            newFunction->FillCount  = elementCount;
            // Initialize the table
            newFunction->LastChildIndex = tableSize - 1;
            // Return pointer to the created child

            return(newFunction);
        }
Exemplo n.º 2
0
        void CollectData64()
        {
            if (TranslatePointer(memHeader64->RootFuncInfoAddress) == null)
            {
                return;
            }
            ulong now = GetRdtsc();
            ThreadLocalData64 * item      = (ThreadLocalData64 *)TranslatePointer(memHeader64->LastThreadListItem);
            List <Stack <int> > stackList = new List <Stack <int> >();

            while (item != null)
            {
                StackEntry64 *entry   = (StackEntry64 *)TranslatePointer(item->Stack.Array);
                Stack <int>   itemIDs = new Stack <int>();
                while (entry != null && entry <= (StackEntry64 *)TranslatePointer(item->Stack.TopPointer))
                {
                    FunctionInfo *function = (FunctionInfo *)TranslatePointer(entry->Function);
                    itemIDs.Push(function->Id);
                    function->TimeSpent += now - entry->StartTime;
                    entry++;
                }
                stackList.Add(itemIDs);
                item = (ThreadLocalData64 *)TranslatePointer(item->Predecessor);
            }
            if (enableDC)
            {
                AddDataset(fullView.Pointer, memHeader64->NativeAddress + memHeader64->HeapOffset, memHeader64->Allocator.startPos - memHeader64->NativeAddress, memHeader64->Allocator.pos - memHeader64->Allocator.startPos, isFirstDC, memHeader64->RootFuncInfoAddress);
                isFirstDC = false;
            }
            ZeroMemory(new IntPtr(TranslatePointer(memHeader64->Allocator.startPos)), new IntPtr(memHeader64->Allocator.pos - memHeader64->Allocator.startPos));
            memHeader64->Allocator.pos = memHeader64->Allocator.startPos;
            Allocator64.ClearFreeList(&memHeader64->Allocator);
            FunctionInfo *root = CreateFunctionInfo(0, 0, stackList.Count);

            memHeader64->RootFuncInfoAddress = TranslatePointerBack64(root);
            item = (ThreadLocalData64 *)TranslatePointer(memHeader64->LastThreadListItem);
            now  = GetRdtsc();
            foreach (Stack <int> thread in stackList)
            {
                FunctionInfo *child = null;
                StackEntry64 *entry = (StackEntry64 *)TranslatePointer(item->Stack.TopPointer);
                while (thread.Count > 0)
                {
                    FunctionInfo *stackItem = CreateFunctionInfo(thread.Pop(), 0, child != null ? 1 : 0);
                    if (child != null)
                    {
                        FunctionInfo.AddOrUpdateChild64(stackItem, child, this);
                    }
                    entry->Function  = TranslatePointerBack64(stackItem);
                    entry->StartTime = now;
                    entry--;
                    child = stackItem;
                }
                if (child != null)
                {
                    FunctionInfo.AddOrUpdateChild64(root, child, this);
                }
                item = (ThreadLocalData64 *)TranslatePointer(item->Predecessor);
            }
        }
Exemplo n.º 3
0
 public static TargetProcessPointer32 *GetChildren32(FunctionInfo *f)
 {
     if (f == null)
     {
         throw new NullReferenceException();
     }
     return((TargetProcessPointer32 *)(f + 1));
 }
Exemplo n.º 4
0
        public static void AddOrUpdateChild32(FunctionInfo *parent, FunctionInfo *child, Profiler profiler)
        {
            int slot = child->Id;

            while (true)
            {
                slot &= parent->LastChildIndex;
                FunctionInfo *slotContent = (FunctionInfo *)profiler.TranslatePointer(GetChildren32(parent)[slot]);
                if (slotContent == null || slotContent->Id == child->Id)
                {
                    GetChildren32(parent)[slot] = profiler.TranslatePointerBack32(child);
                    break;
                }
                slot++;
            }
        }
 internal UnmanagedCallTreeNode64(UnmanagedProfilingDataSet dataSet, FunctionInfo *data, CallTreeNode parent)
 {
     this.data    = data;
     this.dataSet = dataSet;
     this.parent  = parent;
 }
		internal UnmanagedCallTreeNode64(UnmanagedProfilingDataSet dataSet, FunctionInfo* data, CallTreeNode parent)
		{
			this.data = data;
			this.dataSet = dataSet;
			this.parent = parent;
		}