@@ -79,14 +79,14 @@ enum EtwThreadFlags
7979// if the fields in the event are not cheap to calculate
8080//
8181#define ETW_EVENT_ENABLED (Context, EventDescriptor ) \
82- ((MCGEN_ENABLE_CHECK(Context, EventDescriptor)) || EVENT_PIPE_ENABLED( ))
82+ ((MCGEN_ENABLE_CHECK(Context.EtwProvider , EventDescriptor)) || EventPipeHelper::IsEnabled(Context, EventDescriptor.Level, EventDescriptor.Keyword ))
8383
8484//
8585// Use this macro to check if a category of events is enabled
8686//
8787
8888#define ETW_CATEGORY_ENABLED (Context, Level, Keyword ) \
89- ((Context.IsEnabled && McGenEventProviderEnabled(&Context, Level, Keyword)) || EVENT_PIPE_ENABLED( ))
89+ ((Context.EtwProvider. IsEnabled && McGenEventProviderEnabled(&( Context.EtwProvider) , Level, Keyword)) || EventPipeHelper::IsEnabled(Context, Level, Keyword ))
9090
9191
9292// This macro only checks if a provider is enabled
@@ -95,26 +95,29 @@ enum EtwThreadFlags
9595 ((ProviderSymbol##_Context.IsEnabled) || EVENT_PIPE_ENABLED())
9696
9797
98- #else // defined(FEATURE_PAL)
98+ #else // ! defined(FEATURE_PAL)
9999#if defined(FEATURE_PERFTRACING)
100100#define ETW_INLINE
101101#define ETWOnStartup (StartEventName, EndEventName )
102102#define ETWFireEvent (EventName )
103103
104104#define ETW_TRACING_INITIALIZED (RegHandle ) (TRUE )
105- #define ETW_EVENT_ENABLED (Context, EventDescriptor ) (EventPipeHelper::Enabled() || XplatEventLogger::IsEventLoggingEnabled())
106- #define ETW_CATEGORY_ENABLED (Context, Level, Keyword ) (EventPipeHelper::Enabled() || XplatEventLogger::IsEventLoggingEnabled())
105+ #define ETW_EVENT_ENABLED (Context, EventDescriptor ) (EventPipeHelper::IsEnabled(Context, EventDescriptor.Level, EventDescriptor.Keyword) || \
106+ (XplatEventLogger::IsEventLoggingEnabled()))
107+ #define ETW_CATEGORY_ENABLED (Context, Level, Keyword ) (EventPipeHelper::IsEnabled(Context, Level, Keyword) || \
108+ (XplatEventLogger::IsEventLoggingEnabled())
107109#define ETW_TRACING_ENABLED (Context, EventDescriptor ) (EventEnabled##EventDescriptor())
108- #define ETW_TRACING_CATEGORY_ENABLED (Context, Level, Keyword ) (EventPipeHelper::Enabled() || XplatEventLogger::IsEventLoggingEnabled())
110+ #define ETW_TRACING_CATEGORY_ENABLED (Context, Level, Keyword ) (EventPipeHelper::IsEnabled(Context, Level, Keyword) || \
111+ (XplatEventLogger::IsEventLoggingEnabled()))
109112#define ETW_PROVIDER_ENABLED (ProviderSymbol ) (TRUE )
110113#else // defined(FEATURE_PERFTRACING)
111114#define ETW_INLINE
112115#define ETWOnStartup (StartEventName, EndEventName )
113116#define ETWFireEvent (EventName )
114117
115118#define ETW_TRACING_INITIALIZED (RegHandle ) (TRUE )
116- #define ETW_EVENT_ENABLED (Context, EventDescriptor ) (XplatEventLogger::IsEventLoggingEnabled())
117119#define ETW_CATEGORY_ENABLED (Context, Level, Keyword ) (XplatEventLogger::IsEventLoggingEnabled())
120+ #define ETW_EVENT_ENABLED (Context, EventDescriptor ) (XplatEventLogger::IsEventLoggingEnabled())
118121#define ETW_TRACING_ENABLED (Context, EventDescriptor ) (EventEnabled##EventDescriptor())
119122#define ETW_TRACING_CATEGORY_ENABLED (Context, Level, Keyword ) (XplatEventLogger::IsEventLoggingEnabled())
120123#define ETW_PROVIDER_ENABLED (ProviderSymbol ) (TRUE )
@@ -175,7 +178,8 @@ struct ProfilingScanContext;
175178// Use this macro to check if ETW is initialized and the event is enabled
176179//
177180#define ETW_TRACING_ENABLED (Context, EventDescriptor ) \
178- ((Context.IsEnabled && ETW_TRACING_INITIALIZED(Context.RegistrationHandle) && ETW_EVENT_ENABLED(Context, EventDescriptor)) || EVENT_PIPE_ENABLED())
181+ ((Context.EtwProvider.IsEnabled && ETW_TRACING_INITIALIZED(Context.EtwProvider.RegistrationHandle) && ETW_EVENT_ENABLED(Context, EventDescriptor))|| \
182+ EventPipeHelper::IsEnabled (Context, EventDescriptor.Level, EventDescriptor.Keyword))
179183
180184//
181185// Using KEYWORDZERO means when checking the events category ignore the keyword
@@ -186,12 +190,12 @@ struct ProfilingScanContext;
186190// Use this macro to check if ETW is initialized and the category is enabled
187191//
188192#define ETW_TRACING_CATEGORY_ENABLED (Context, Level, Keyword ) \
189- (( ETW_TRACING_INITIALIZED(Context.RegistrationHandle) && ETW_CATEGORY_ENABLED(Context, Level, Keyword)) || EVENT_PIPE_ENABLED( ))
193+ (ETW_TRACING_INITIALIZED(Context.EtwProvider. RegistrationHandle) && ETW_CATEGORY_ENABLED(Context, Level, Keyword))
190194
191- #define ETWOnStartup (StartEventName, EndEventName ) \
192- ETWTraceStartup trace##StartEventName##(Microsoft_Windows_DotNETRuntimePrivateHandle, &StartEventName, &StartupId, &EndEventName, &StartupId);
193- #define ETWFireEvent (EventName ) \
194- ETWTraceStartup::StartupTraceEvent (Microsoft_Windows_DotNETRuntimePrivateHandle, &EventName, &StartupId);
195+ #define ETWOnStartup (StartEventName, EndEventName ) \
196+ ETWTraceStartup trace##StartEventName##(Microsoft_Windows_DotNETRuntimePrivateHandle, &StartEventName, &StartupId, &EndEventName, &StartupId);
197+ #define ETWFireEvent (EventName ) \
198+ ETWTraceStartup::StartupTraceEvent (Microsoft_Windows_DotNETRuntimePrivateHandle, &EventName, &StartupId);
195199
196200#ifndef FEATURE_REDHAWK
197201// Headers
@@ -217,14 +221,24 @@ struct ProfilingScanContext;
217221extern UINT32 g_nClrInstanceId;
218222
219223#define GetClrInstanceId () (static_cast <UINT16>(g_nClrInstanceId))
224+ #if defined(FEATURE_PAL) && (defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT))
225+ #define KEYWORDZERO 0x0
226+
227+ /* **************************************/
228+ /* Tracing levels supported by CLR ETW */
229+ /* **************************************/
230+ #define MAX_TRACE_LEVEL 6 // Maximum Number of Trace Levels supported
231+ #define TRACE_LEVEL_FATAL 1 // Abnormal exit or termination
232+ #define TRACE_LEVEL_ERROR 2 // Severe errors that need logging
233+ #define TRACE_LEVEL_WARNING 3 // Warnings such as allocation failure
234+ #define TRACE_LEVEL_INFORMATION 4 // Includes non-error cases such as Entry-Exit
235+ #define TRACE_LEVEL_VERBOSE 5 // Detailed traces from intermediate steps
236+
237+ #define DEF_LTTNG_KEYWORD_ENABLED 1
238+ #include " clrproviders.h"
239+ #include " clrconfig.h"
240+ #endif // defined(FEATURE_PAL) && (defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT))
220241
221- #if defined(FEATURE_PERFTRACING)
222- class EventPipeHelper
223- {
224- public:
225- static bool Enabled ();
226- };
227- #endif // defined(FEATURE_PERFTRACING)
228242
229243#if defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT)
230244
@@ -334,6 +348,14 @@ extern "C" {
334348#endif // !FEATURE_PAL
335349
336350#include " clretwallmain.h"
351+ #if defined(FEATURE_PERFTRACING)
352+ class EventPipeHelper
353+ {
354+ public:
355+ static bool Enabled ();
356+ static bool IsEnabled (DOTNET_TRACE_CONTEXT Context, UCHAR Level, ULONGLONG Keyword);
357+ };
358+ #endif // defined(FEATURE_PERFTRACING)
337359
338360#endif // FEATURE_EVENT_TRACE
339361
@@ -1043,7 +1065,7 @@ class ETWTraceStartup {
10431065 }
10441066 static void StartupTraceEvent (REGHANDLE _TraceHandle, PCEVENT_DESCRIPTOR _EventDescriptor, LPCGUID _EventGuid) {
10451067 EVENT_DESCRIPTOR desc = *_EventDescriptor;
1046- if (ETW_TRACING_ENABLED (MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_Context , desc))
1068+ if (ETW_TRACING_ENABLED (MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context , desc))
10471069 {
10481070 CoMofTemplate_h (MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_Context.RegistrationHandle , _EventDescriptor, _EventGuid, GetClrInstanceId ());
10491071 }
0 commit comments