Ejemplo n.º 1
0
            public static GCEventSource Create(string sourceName, uint typeSize, ulong options)
            {
                uint qos = QualityOfService.RecyclableEvents;

                if (options != 0)
                {
                    qos |= QualityOfService.OOM_BreakOnRecycle;
                }

                EventingStorage storage = EventingStorage.CreateLocalStorage(qos, typeSize);

                if (storage == null)
                {
                    return(null);
                }

                GCEventSource Logger = new GCEventSource(sourceName,
                                                         storage,
                                                         ENABLE_ALL_MASK);

                if (Logger != null)
                {
                    Logger.Register();
                }

                return(Logger);
            }
Ejemplo n.º 2
0
        // Initialization, prior to attempting to set this profiler into the GC.  It's
        // inappropriate to do this stuff inside a constructor.
        internal void Initialize(ulong Size, ulong Flags)
        {
            options             = Flags;
            typeTable           = new Hashtable();
            stackTable          = new Hashtable();
            funcTable           = new Hashtable();
            stackEips           = new UIntPtr[stackSize];
            stackNos            = new uint[stackSize];
            generations         = new int[maxGeneration];
            functionsIDs        = new uint[stackSize];
            Buffer              = new ProfilerBuffer();
            tempGCBuffer        = new UIntPtr[tempBufferSize];
            tempGCBufferEntries = 0;
#if LEGACY_GCTRACING
            bufferSize = Size;
            unsafe {
                //  Allocate the memory indicated as parameter, as nonGC

#if SINGULARITY_KERNEL
                UIntPtr pages = Microsoft.Singularity.Memory.MemoryManager.PagesFromBytes(bufferSize);
                bufferMemory = (byte *)Microsoft.Singularity.Memory.MemoryManager.KernelAllocate(
                    pages, null, 0, System.GCs.PageType.NonGC).ToPointer();
#else  // !SINGULARITY_KERNEL
                bufferMemory = (byte *)PageTableService.Allocate(bufferSize);
#endif  //SINGULARITY_KERNEL

                if (bufferMemory != null)
                {
                    // When we set this, we are no longer single-threaded:
                    ProfilerBuffer.SetupBuffer(bufferMemory, bufferSize);
                    this.enabled = true;
                }
            }
#else  // LEGACY_GCTRACING
            typeSource  = GCTypeSource.Create("GC.TypeDefinitions", (uint)Size, options);
            EventSource = GCEventSource.Create("GC.Events", (uint)Size, options);

            if ((typeSource == null) || (EventSource == null))
            {
                typeSource   = null;
                EventSource  = null;
                this.enabled = false;
            }
            else
            {
                TypeStorageHandle = typeSource.Storage.GetHandle();
                StorageHandle     = EventSource.Storage.GetHandle();
                this.enabled      = true;
            }
#endif // LEGACY_GCTRACING
        }