示例#1
0
 internal static void MarshalToNative(EventPipeProviderConfiguration managed, ref EventPipeProviderConfigurationNative native)
 {
     native.m_pProviderName = (char *)Marshal.StringToCoTaskMemUni(managed.ProviderName);
     native.m_keywords      = managed.Keywords;
     native.m_loggingLevel  = managed.LoggingLevel;
     native.m_pFilterData   = (char *)Marshal.StringToCoTaskMemUni(managed.FilterData);
 }
        private void CommitDispatchConfiguration()
        {
            Debug.Assert(Monitor.IsEntered(m_dispatchControlLock));

            // Ensure that the dispatch task is stopped.
            // This is a no-op if the task is already stopped.
            StopDispatchTask();

            // Stop tracing.
            // This is a no-op if it's already disabled.
            EventPipeInternal.Disable(m_sessionID);

            // Check to see if tracing should be enabled.
            if (m_subscriptions.Count <= 0)
            {
                return;
            }

            // Determine the keywords and level that should be used based on the set of enabled EventListeners.
            EventKeywords aggregatedKeywords = EventKeywords.None;
            EventLevel    highestLevel       = EventLevel.LogAlways;

            foreach (EventListenerSubscription subscription in m_subscriptions.Values)
            {
                aggregatedKeywords |= subscription.MatchAnyKeywords;
                highestLevel        = (subscription.Level > highestLevel) ? subscription.Level : highestLevel;
            }

            // Enable the EventPipe session.
            EventPipeProviderConfiguration[] providerConfiguration = new EventPipeProviderConfiguration[]
            {
                new EventPipeProviderConfiguration(RuntimeEventSource.EventSourceName, (ulong)aggregatedKeywords, (uint)highestLevel, null)
            };

            m_sessionID = EventPipeInternal.Enable(null, 1024, 1, providerConfiguration, 1, 0);
            Debug.Assert(m_sessionID != 0);

            // Get the session information that is required to properly dispatch events.
            EventPipeSessionInfo sessionInfo;

            unsafe
            {
                if (!EventPipeInternal.GetSessionInfo(m_sessionID, &sessionInfo))
                {
                    Debug.Assert(false, "GetSessionInfo returned false.");
                }
            }

            m_syncTimeUtc      = DateTime.FromFileTimeUtc(sessionInfo.StartTimeAsUTCFileTime);
            m_syncTimeQPC      = sessionInfo.StartTimeStamp;
            m_timeQPCFrequency = sessionInfo.TimeStampFrequency;

            // Start the dispatch task.
            StartDispatchTask();
        }
        private void CommitDispatchConfiguration()
        {
            // Ensure that the dispatch task is stopped.
            // This is a no-op if the task is already stopped.
            StopDispatchTask();

            // Stop tracing.
            // This is a no-op if it's already disabled.
            EventPipeInternal.Disable();

            // Check to see if tracing should be enabled.
            if (m_subscriptions.Count <= 0)
            {
                return;
            }

            // Start collecting events.
            EventKeywords aggregatedKeywords = EventKeywords.None;
            EventLevel    highestLevel       = EventLevel.LogAlways;

            foreach (EventListenerSubscription subscription in m_subscriptions.Values)
            {
                aggregatedKeywords |= subscription.MatchAnyKeywords;
                highestLevel        = (subscription.Level > highestLevel) ? subscription.Level : highestLevel;
            }

            EventPipeProviderConfiguration[] providerConfiguration = new EventPipeProviderConfiguration[]
            {
                new EventPipeProviderConfiguration(RuntimeEventSource.EventSourceName, (ulong)aggregatedKeywords, (uint)highestLevel)
            };

            EventPipeInternal.Enable(null, 1024, 1, providerConfiguration, 1);

            // Start the dispatch task.
            StartDispatchTask();
        }
示例#4
0
 private void EnableProviderConfiguration(EventPipeProviderConfiguration providerConfig)
 {
     m_providers.Add(providerConfig);
 }