Esempio n. 1
0
        bool AllThreadsWait32()
        {
            try {
                this.threadListMutex.WaitOne();
            } catch (AbandonedMutexException) {
                // profilee crashed while holding the thread list mutex
                return(true);
            }

            bool isWaiting = true;

            ThreadLocalData32 *item = (ThreadLocalData32 *)TranslatePointer(this.memHeader32->LastThreadListItem);

            while (item != null)
            {
                if (item->InLock == 1)
                {
                    isWaiting = false;
                }

                item = (ThreadLocalData32 *)TranslatePointer(item->Predecessor);
            }

            this.threadListMutex.ReleaseMutex();

            return(isWaiting);
        }
Esempio n. 2
0
        bool AllThreadsWait32()
        {
            this.threadListMutex.WaitOne();

            bool isWaiting = true;

            ThreadLocalData32 *item = (ThreadLocalData32 *)TranslatePointer(this.memHeader32->LastThreadListItem);

            while (item != null)
            {
                if (item->InLock == 1)
                {
                    isWaiting = false;
                }

                item = (ThreadLocalData32 *)TranslatePointer(item->Predecessor);
            }

            this.threadListMutex.ReleaseMutex();

            return(isWaiting);
        }
Esempio n. 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);
            }
        }