Skip to content
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

Update runtime providers' context object on EventPipe rundown #36733

Merged
merged 4 commits into from
May 26, 2020
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
9 changes: 9 additions & 0 deletions src/coreclr/src/vm/eventpipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ void EventPipe::Disable(EventPipeSessionID id)
if (s_numberOfSessions > 0)
DisableInternal(id, pEventPipeProviderCallbackDataQueue);
});

#ifdef DEBUG
if ((int)s_numberOfSessions == 0)
{
_ASSERTE(!MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context.EventPipeProvider.IsEnabled);
_ASSERTE(!MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context.EventPipeProvider.IsEnabled);
_ASSERTE(!MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_DOTNET_Context.EventPipeProvider.IsEnabled);
}
#endif
}

static void LogProcessInformationEvent(EventPipeEventSource &eventSource)
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/src/vm/eventpipeprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,14 @@ void EventPipeProvider::AddEvent(EventPipeEvent &event)
isEventFilterDescriptorInitialized = true;
}

// NOTE: When we call the callback, we pass in enabled (which is either 1 or 0) as the ControlCode.
// If we want to add new ControlCode, we have to make corresponding change in eventtrace.cpp:EtwCallbackCommon
// to address this. See https://github.com/dotnet/runtime/pull/36733 for more discussions on this.
if (pCallbackFunction != NULL && !g_fEEShutDown)
{
(*pCallbackFunction)(
NULL, /* providerId */
enabled,
enabled, /* ControlCode */
(UCHAR)providerLevel,
keywords,
0 /* matchAllKeywords */,
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/src/vm/eventtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4267,6 +4267,10 @@ VOID EtwCallbackCommon(
{
ctxToUpdate->EventPipeProvider.Level = Level;
ctxToUpdate->EventPipeProvider.EnabledKeywordsBitmask = MatchAnyKeyword;
ctxToUpdate->EventPipeProvider.IsEnabled = ControlCode;
sywhang marked this conversation as resolved.
Show resolved Hide resolved

// For EventPipe, ControlCode can only be either 0 or 1.
_ASSERTE(ControlCode == 0 || ControlCode == 1);
}

if (
Expand Down Expand Up @@ -7612,6 +7616,11 @@ bool EventPipeHelper::IsEnabled(DOTNET_TRACE_CONTEXT Context, UCHAR Level, ULONG
}
CONTRACTL_END

if (!Context.EventPipeProvider.IsEnabled)
{
return false;
}

if (Level <= Context.EventPipeProvider.Level)
{
return (Keyword == (ULONGLONG)0) || (Keyword & Context.EventPipeProvider.EnabledKeywordsBitmask) != 0;
Expand Down