public EventSource(Controller controller, string sourceName, UIntPtr storageHandle) { SourceName = sourceName; Storage = EventingStorage.CreateStorageFromHandle(storageHandle); ControlFlags = ENABLE_ALL_MASK; HostController = controller; }
// Storage registration routines public bool RegisterStorage(EventingStorage Storage) { Lock.AcquireMutex(); bool success = RegisterStorageImpl(Storage.GetHandle()); Lock.ReleaseMutex(); return(success); }
public void UnRegisterStorage(EventingStorage Storage) { if (!Controller.Finalized) { Lock.AcquireMutex(); UnRegisterStorageImpl(Storage.GetHandle()); Lock.ReleaseMutex(); } }
public static ControllerLogger Create(string sourceName, EventingStorage storage) { ControllerLogger Logger = new ControllerLogger(sourceName, storage, CAPTURE_STACK_TRACE | ENABLE_ALL_MASK); if (Logger != null) { Logger.Register(); } return(Logger); }
public EventSource(string sourceName, EventingStorage storage, uint controlFlags) { SourceName = sourceName; Storage = storage; ControlFlags = controlFlags; if (storage != null) { HostController = storage.GetController(); } else { HostController = Controller.GetLocalController(); } }
internal override void Initialize() { if (KernelControllerObject != null) { // Already initialized return; } base.Initialize(); ProcessContext.Initialize(); GeneralPurposeStorage = EventingStorage.CreateLocalStorage(QualityOfService.RecyclableEvents, BUFFER_EXPANSION_SIZE); KernelControllerObject = this; }
public bool Initialize(EventingStorage storage, bool forward) { if (EntryBuffer == null) { EntryBuffer = new QueryBuffer(256); if ((EntryBuffer == null) || (EntryBuffer.GetBuffer() == null)) { return(false); } } // Cleanup for the previous states. if (QueryHandle != 0) { QueryStorage.DeleteQueryView(QueryHandle); QueryHandle = 0; QueryStorage = null; } // Initialize the new query states QueryStorage = storage; if (QueryStorage == null) { return(false); } QueryHandle = QueryStorage.CreateQueryView(forward); if (QueryHandle == 0) { QueryStorage = null; return(false); } return(true); }
public static SystemAllocationLogger Create(string sourceName) { EventingStorage storage = EventingStorage.CreateLocalStorage(QualityOfService.RecyclableEvents, DefaultLogSize); if (storage == null) { return(null); } SystemAllocationLogger Logger = new SystemAllocationLogger(sourceName, storage, ENABLE_ALL_MASK); if (Logger != null) { Logger.Register(); } return(Logger); }
public static ProcessorLogger Create(string sourceName) { EventingStorage storage = EventingStorage.CreateLocalStorage(QualityOfService.RecyclableEvents, DefaultProcessorLogSize); if (storage == null) { return(null); } ProcessorLogger Logger = new ProcessorLogger(sourceName, storage, CAPTURE_STACK_TRACE | ENABLE_ALL_MASK); if (Logger != null) { Logger.Register(); } return(Logger); }
public static SamplingProfiler Create(string sourceName, int maxStackSize, uint storageSize) { EventingStorage storage = EventingStorage.CreateLocalStorage(QualityOfService.RecyclableEvents, storageSize); if (storage == null) { return(null); } SamplingProfiler Logger = new SamplingProfiler(sourceName, maxStackSize, storage, ENABLE_ALL_MASK); if (Logger != null) { Logger.Register(); } return(Logger); }
SystemAllocationLogger(string sourceName, EventingStorage storage, uint controlFlags) : base(sourceName, storage, controlFlags) { }
SamplingProfiler(string sourceName, int maxStackSize, EventingStorage storage, uint controlFlags) : base(sourceName, storage, controlFlags) { MaxStackSize = maxStackSize; StackTrace = new UIntPtr[maxStackSize]; }
ProcessorLogger(string sourceName, EventingStorage storage, uint controlFlags) : base(sourceName, storage, controlFlags) { }
// Public methods // Private methods internal override void Initialize() { base.Initialize(); EventTable = new Hashtable(); SourcesLookupTable = new Hashtable(); SourcesHandleTable = new Hashtable(); UIntPtr RepositoryStorageHandle = FetchLocalStorage(); if (RepositoryStorageHandle != 0) { TypesRepository = EventingStorage.CreateStorageFromHandle(RepositoryStorageHandle); // Fetch now the existing source list created before initializing the controller int currentSize = 20; UIntPtr [] sourceArray = new UIntPtr[currentSize]; if (sourceArray != null) { unsafe { fixed(UIntPtr *ptr = sourceArray) { int sourceCount = QuerySystemSources(ptr, (ushort)currentSize); while (sourceCount > currentSize) { sourceArray = new UIntPtr[sourceCount]; sourceCount = QuerySystemSources(ptr, (ushort)currentSize); } for (int i = 0; i < sourceCount; i++) { UIntPtr sourceHandle = sourceArray[i]; UIntPtr storageHandle = 0; string bufferName = ""; if (GetNativeSourceName(sourceHandle, ref storageHandle, ref bufferName)) { EventSource source = new EventSource(this, bufferName, storageHandle); if (source != null) { source.Register(); } } } } } } } else { TypesRepository = EventingStorage.CreateLocalStorage(QualityOfService.PermanentEvents, BUFFER_EXPANSION_SIZE); SetRepositoryStorage(TypesRepository.GetHandle()); } string sourceName = "ControllerLog"; #if SINGULARITY_KERNEL sourceName = sourceName + "{kernel}"; #else unsafe { int argMaxLen = ProcessService.GetStartupArg(0, null, 0); char[] argArray = new char [argMaxLen]; fixed(char *argptr = &argArray[0]) { int len = ProcessService.GetStartupArg(0, argptr, argArray.Length); sourceName = sourceName + "{" + String.StringCTOR(argptr, 0, len) + "}"; sourceName = sourceName + "(PID:" + ProcessService.GetCurrentProcessId() + ")"; } } #endif InternalSource = ControllerLogger.Create(sourceName, TypesRepository); }
public virtual void EnumerateActiveSources(QuerySourceDelegate sourceDelegate, ActiveSourceEntryDelegate activeEntryDelegate, QueryEntryDelegate entryDelegate, ushort maxEntrySize, ref EnumerationContext context) { if (maxEntrySize == 0) { maxEntrySize = DefaultEntrySize; } // Create a temporary buffer to store the temporary query information QueryBuffer entryBuffer = new QueryBuffer(maxEntrySize); if ((entryBuffer == null) || (sourceDelegate == null)) { return; } // Prepare to query the controller for the source list. We just pick up an number // that would represent the limit for most common cases as the initial guess. int currentSize = 100; UIntPtr [] sourceArray = new UIntPtr[currentSize]; if (sourceArray != null) { // Query the controller for the actual source list int sourceCount = QuerySourcesList(sourceArray, currentSize); // // The array was not large enough, attempt again with the new size while (sourceCount > currentSize) { sourceArray = new UIntPtr[sourceCount]; sourceCount = QuerySourcesList(sourceArray, currentSize); } // // We sucessfully received an array of entries. We walk them and build the // required information // for (int i = 0; i < sourceCount; i++) { UIntPtr sourceHandle = sourceArray[i]; UIntPtr storageHandle = 0; UIntPtr eventType = 0; UInt16 count = 0; string bufferName = ""; if (GetSourceInformation(sourceHandle, ref storageHandle, ref eventType, ref count, ref bufferName)) { if (storageHandle == 0) { // // This is an active source. The eventing has no information // about the storage, it has instead information about the // types of events handled by this source // EventDescriptor descriptor = QuerySession.GetEventDescriptor(this, eventType); if (descriptor != null) { // The source is valid, call the delegate with the appropriate // arguments filled in // TODO: Also retrieve the control flags status if (!sourceDelegate(sourceHandle, storageHandle, eventType, count, bufferName, descriptor, ref context)) { break; } if (entryDelegate != null) { // The caller also provided an entry delegate. We need in that // case to also enumerate all entries from the active source for (int index = 0; index < count; index++) { if (!QueryActiveEntry(sourceHandle, index, ref entryBuffer)) { break; } activeEntryDelegate(sourceHandle, index, descriptor, entryBuffer, ref context); } } } } else { // This source has an associated storage. Enumerate the entries from // the storage // TODO: we might also want to filter the sources inside the storage // since multiple sources can share the same storage if (!sourceDelegate(sourceHandle, storageHandle, eventType, count, bufferName, null, ref context)) { break; } EventingStorage storage = OpenStorage(storageHandle); if (storage != null) { // Instantiate a query session for the storage and // enumerate the entries passing the provided delegate QuerySession query = new QuerySession(); if ((query != null) && (context != null) && query.Initialize(storage, false)) { query.EnumerateEntries(entryDelegate, ref context); } } } } } } }