Skip to content

FIX #87983 - Enable events for LogAlways #89326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/coreclr/vm/eventtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,27 @@ private void CommitDispatchConfiguration()

// 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);
Expand Down
9 changes: 7 additions & 2 deletions src/native/eventpipe/ep-provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down