From: Nickolas McDonald <43690021+n77y@users.noreply.github.com> Date: Tue, 25 Jul 2023 08:06:07 +0000 (-0400) Subject: Enable events for LogAlways (#89326) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~806 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3473158d8049119a8b4decd1680e1607a8980ff;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Enable events for LogAlways (#89326) --- diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index 77281f9..9b73e7b 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -5806,7 +5806,8 @@ bool EventPipeHelper::IsEnabled(DOTNET_TRACE_CONTEXT Context, UCHAR Level, ULONG return false; } - if (Level <= Context.EventPipeProvider.Level) + if ((Level <= Context.EventPipeProvider.Level) || + (Context.EventPipeProvider.Level == EP_EVENT_LEVEL_LOGALWAYS)) { return (Keyword == (ULONGLONG)0) || (Keyword & Context.EventPipeProvider.EnabledKeywordsBitmask) != 0; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipeEventDispatcher.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipeEventDispatcher.cs index abcbf93..c9daf4e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipeEventDispatcher.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipeEventDispatcher.cs @@ -98,18 +98,27 @@ namespace System.Diagnostics.Tracing // Determine the keywords and level that should be used based on the set of enabled EventListeners. EventKeywords aggregatedKeywords = EventKeywords.None; - EventLevel highestLevel = EventLevel.LogAlways; + EventLevel enableLevel = EventLevel.Critical; foreach (EventListenerSubscription subscription in m_subscriptions.Values) { aggregatedKeywords |= subscription.MatchAnyKeywords; - highestLevel = (subscription.Level > highestLevel) ? subscription.Level : highestLevel; + + if (enableLevel is EventLevel.LogAlways) + { + continue; + } + if ((enableLevel < subscription.Level) || + (subscription.Level is EventLevel.LogAlways)) + { + enableLevel = subscription.Level; + } } // Enable the EventPipe session. EventPipeProviderConfiguration[] providerConfiguration = new EventPipeProviderConfiguration[] { - new EventPipeProviderConfiguration(NativeRuntimeEventSource.EventSourceName, (ulong)aggregatedKeywords, (uint)highestLevel, null) + new EventPipeProviderConfiguration(NativeRuntimeEventSource.EventSourceName, (ulong)aggregatedKeywords, (uint)enableLevel, null) }; m_sessionID = EventPipeInternal.Enable(null, EventPipeSerializationFormat.NetTrace, DefaultEventListenerCircularMBSize, providerConfiguration); diff --git a/src/native/eventpipe/ep-provider.c b/src/native/eventpipe/ep-provider.c index 73cf4df..d8fe72d 100644 --- a/src/native/eventpipe/ep-provider.c +++ b/src/native/eventpipe/ep-provider.c @@ -153,9 +153,14 @@ provider_compute_event_enable_mask ( // The event is enabled if: // - The provider is enabled. // - The event keywords are unspecified in the manifest (== 0) or when masked with the enabled config are != 0. - // - The event level is LogAlways or the provider's verbosity level is set to greater than the event's verbosity level in the manifest. + // - The event level is LogAlways + // or the provider's verbosity level is LogAlways + // or the provider's verbosity level is set to greater than the event's verbosity level in the manifest. bool keyword_enabled = (keywords == 0) || ((session_keyword & keywords) != 0); - bool level_enabled = ((event_level == EP_EVENT_LEVEL_LOGALWAYS) || (session_level >= event_level)); + bool level_enabled = (event_level == EP_EVENT_LEVEL_LOGALWAYS) || + (session_level == EP_EVENT_LEVEL_LOGALWAYS) || + (session_level >= event_level); + if (provider_enabled && keyword_enabled && level_enabled) result = result | ep_session_get_mask (session); }