Ejemplo n.º 1
0
        internal static unsafe void MarkThreadStack(Thread thread)
        {
            int     stackVariable;
            UIntPtr stackBase = PageTable.PagePad(new UIntPtr(&stackVariable));

            CallStack.SetStackBase(thread, stackBase);
            UIntPtr topPageAddr =
                PageTable.PageAlign(CallStack.StackBase(thread) - 1);

            SetStackPages(topPageAddr, CallStack.StackBase(thread), thread);
            UIntPtr regionAddr, regionSize;
            bool    fUsed = MemoryManager.QueryMemory(topPageAddr,
                                                      out regionAddr,
                                                      out regionSize);

            VTable.Assert(fUsed);
            SetStackPages(regionAddr, topPageAddr, thread);
        }
Ejemplo n.º 2
0
        internal static unsafe void ClearThreadStack(Thread thread)
        {
            short   threadIndex = (short)thread.threadIndex;
            UIntPtr endPage     = PageTable.Page(CallStack.StackBase(thread));
            UIntPtr startPage   = endPage - 1;

            VTable.Assert(PageTable.IsStackPage(PageTable.Type(startPage)));
            VTable.Assert(PageTable.Extra(startPage) == threadIndex);
            while (startPage > 0 &&
                   PageTable.IsStackPage(PageTable.Type(startPage - 1)) &&
                   PageTable.Extra(startPage - 1) == threadIndex)
            {
                startPage--;
            }
            UIntPtr startAddr = PageTable.PageAddr(startPage);
            UIntPtr size      = PageTable.RegionSize(endPage - startPage);

            SetUnallocatedPages(startAddr, size);
        }
Ejemplo n.º 3
0
        internal unsafe static void ReportStackDetails()
        {
            VTable.DebugPrint("\nStack details:\n");
            VTable.DebugPrint("\tTotal number of reserved pages: {0}",
                              __arglist(TotalNumPages(PageType.Stack)));

            for (int i = 0; i < Thread.threadTable.Length; i++)
            {
                traceablePtrs.Initialize();
                traceablePinnedPtrs.Initialize();

                Thread t = Thread.threadTable[i];
                if (t == null)
                {
                    continue;
                }

                uint numStackFrames =
                    CallStack.ScanStack(t, traceablePtrs,
                                        traceablePinnedPtrs);

                VTable.DebugPrint("\n\tThread: {0}",
                                  __arglist(i));
                VTable.DebugPrint("\n\t\tStack frame count: {0}",
                                  __arglist(numStackFrames));
                VTable.DebugPrint("\n\t\tManaged ptrs to static data: {0}",
                                  __arglist
                                      (traceablePtrs.managedPtrsToStaticData));
                VTable.DebugPrint("\n\t\tManaged ptrs to stack: {0}",
                                  __arglist(traceablePtrs.managedPtrsToStack));
                VTable.DebugPrint("\n\t\tExterior managed heap ptrs: {0}",
                                  __arglist
                                      (traceablePtrs.exteriorManagedHeapPtrs));
                VTable.DebugPrint("\n\t\tInterior managed heap ptrs: {0}",
                                  __arglist
                                      (traceablePtrs.interiorManagedHeapPtrs));

#if !SINGULARITY
                UIntPtr stackTop  = (UIntPtr)CallStack.StackMarker(t);
                uint    stackSize = 0;
                if (stackTop != UIntPtr.Zero)
                {
                    VTable.Assert(CallStack.StackBase(t) > stackTop,
                                  @"t.asmStackBase > stackTop");

                    stackSize = (uint)(CallStack.StackBase(t) - stackTop);
                }
                VTable.DebugPrint("\n\t\tApprox. stack size: {0}B",
                                  __arglist(stackSize));
#endif

                // REVIEW: Why are these here?
                VTable.Assert(traceablePinnedPtrs.
                              managedPtrsToStaticData == 0,
                              @"traceablePinnedPtrs.
                            managedPtrsToStaticData == 0");
                VTable.Assert(traceablePinnedPtrs.
                              managedPtrsToStack == 0,
                              @"traceablePinnedPtrs.
                            managedPtrsToStack == 0");

                VTable.DebugPrint("\n\t\tPinned managed heap ptrs: {0}",
                                  __arglist
                                      (traceablePinnedPtrs.exteriorManagedHeapPtrs +
                                      traceablePinnedPtrs.interiorManagedHeapPtrs));
            }

            VTable.DebugPrint("\n");
        }