1 // The .NET Foundation licenses this file to you under the MIT license.
2 // See the LICENSE file in the project root for more information.
4 #ifndef __EVENTPIPE_CONFIGURATION_H__
5 #define __EVENTPIPE_CONFIGURATION_H__
7 #ifdef FEATURE_PERFTRACING
12 class EventPipeSessionProvider;
14 class EventPipeEventInstance;
15 class EventPipeProvider;
16 class EventPipeSession;
17 enum class EventPipeSessionType;
19 enum class EventPipeEventLevel
29 class EventPipeConfiguration
32 EventPipeConfiguration();
33 ~EventPipeConfiguration();
35 // Perform initialization that cannot be performed in the constructor.
38 // Create a new provider.
39 EventPipeProvider *CreateProvider(const SString &providerName, EventPipeCallback pCallbackFunction, void *pCallbackData);
42 void DeleteProvider(EventPipeProvider *pProvider);
44 // Register a provider.
45 bool RegisterProvider(EventPipeProvider &provider);
47 // Unregister a provider.
48 bool UnregisterProvider(EventPipeProvider &provider);
50 // Get the provider with the specified provider ID if it exists.
51 EventPipeProvider *GetProvider(const SString &providerID);
53 // Create a new session.
54 EventPipeSession *CreateSession(
55 EventPipeSessionType sessionType,
56 unsigned int circularBufferSizeInMB,
57 const EventPipeProviderConfiguration *pProviders,
58 uint32_t numProviders);
61 void DeleteSession(EventPipeSession *pSession);
63 // Get the configured size of the circular buffer.
64 size_t GetCircularBufferSize() const;
66 // Enable a session in the event pipe.
67 void Enable(EventPipeSession *pSession);
69 // Disable a session in the event pipe.
70 void Disable(EventPipeSession *pSession);
72 // Get the status of the event pipe.
75 // Determine if rundown is enabled.
76 bool RundownEnabled() const;
78 // Enable rundown using the specified configuration.
79 void EnableRundown(EventPipeSession *pSession);
81 // Get the event used to write metadata to the event stream.
82 EventPipeEventInstance *BuildEventMetadataEvent(EventPipeEventInstance &sourceInstance, unsigned int metdataId);
84 // Delete deferred providers.
85 void DeleteDeferredProviders();
87 // Determine if the specified thread is the rundown thread.
88 // Used during rundown to ignore events from all other threads so that we don't corrupt the trace file.
89 inline bool IsRundownThread(Thread *pThread)
91 LIMITED_METHOD_CONTRACT;
93 return (pThread == m_pRundownThread);
97 // Get the provider without taking the lock.
98 EventPipeProvider *GetProviderNoLock(const SString &providerID);
100 // Get the enabled provider.
101 EventPipeSessionProvider *GetSessionProvider(EventPipeSession *pSession, EventPipeProvider *pProvider);
103 // The one and only EventPipe session.
104 EventPipeSession *m_pSession;
106 // Determines whether or not the event pipe is enabled.
107 Volatile<bool> m_enabled;
109 // The list of event pipe providers.
110 SList<SListElem<EventPipeProvider *>> *m_pProviderList;
112 // The provider used to write configuration events to the event stream.
113 EventPipeProvider *m_pConfigProvider;
115 // The event used to write event information to the event stream.
116 EventPipeEvent *m_pMetadataEvent;
118 // The provider name for the configuration event pipe provider.
119 // This provider is used to emit configuration events.
120 const static WCHAR *s_configurationProviderName;
122 // True if rundown is enabled.
123 Volatile<bool> m_rundownEnabled;
125 // The rundown thread. If rundown is not enabled, this is NULL.
126 Thread *m_pRundownThread;
129 #endif // FEATURE_PERFTRACING
131 #endif // __EVENTPIPE_CONFIGURATION_H__