Fix crossgen with large version bubble enabled
[platform/upstream/coreclr.git] / src / vm / eventpipeconfiguration.h
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.
3
4 #ifndef __EVENTPIPE_CONFIGURATION_H__
5 #define __EVENTPIPE_CONFIGURATION_H__
6
7 #ifdef FEATURE_PERFTRACING
8
9 #include "eventpipe.h"
10 #include "slist.h"
11
12 class EventPipeSessionProvider;
13 class EventPipeEvent;
14 class EventPipeEventInstance;
15 class EventPipeProvider;
16 class EventPipeSession;
17 enum class EventPipeSessionType;
18
19 enum class EventPipeEventLevel
20 {
21     LogAlways,
22     Critical,
23     Error,
24     Warning,
25     Informational,
26     Verbose
27 };
28
29 class EventPipeConfiguration
30 {
31 public:
32     EventPipeConfiguration();
33     ~EventPipeConfiguration();
34
35     // Perform initialization that cannot be performed in the constructor.
36     void Initialize();
37
38     // Create a new provider.
39     EventPipeProvider *CreateProvider(const SString &providerName, EventPipeCallback pCallbackFunction, void *pCallbackData);
40
41     // Delete a provider.
42     void DeleteProvider(EventPipeProvider *pProvider);
43
44     // Register a provider.
45     bool RegisterProvider(EventPipeProvider &provider);
46
47     // Unregister a provider.
48     bool UnregisterProvider(EventPipeProvider &provider);
49
50     // Get the provider with the specified provider ID if it exists.
51     EventPipeProvider *GetProvider(const SString &providerID);
52
53     // Create a new session.
54     EventPipeSession *CreateSession(
55         EventPipeSessionType sessionType,
56         unsigned int circularBufferSizeInMB,
57         const EventPipeProviderConfiguration *pProviders,
58         uint32_t numProviders);
59
60     // Delete a session.
61     void DeleteSession(EventPipeSession *pSession);
62
63     // Get the configured size of the circular buffer.
64     size_t GetCircularBufferSize() const;
65
66     // Enable a session in the event pipe.
67     void Enable(EventPipeSession *pSession);
68
69     // Disable a session in the event pipe.
70     void Disable(EventPipeSession *pSession);
71
72     // Get the status of the event pipe.
73     bool Enabled() const;
74
75     // Determine if rundown is enabled.
76     bool RundownEnabled() const;
77
78     // Enable rundown using the specified configuration.
79     void EnableRundown(EventPipeSession *pSession);
80
81     // Get the event used to write metadata to the event stream.
82     EventPipeEventInstance *BuildEventMetadataEvent(EventPipeEventInstance &sourceInstance, unsigned int metdataId);
83
84     // Delete deferred providers.
85     void DeleteDeferredProviders();
86
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)
90     {
91         LIMITED_METHOD_CONTRACT;
92
93         return (pThread == m_pRundownThread);
94     }
95
96 private:
97     // Get the provider without taking the lock.
98     EventPipeProvider *GetProviderNoLock(const SString &providerID);
99
100     // Get the enabled provider.
101     EventPipeSessionProvider *GetSessionProvider(EventPipeSession *pSession, EventPipeProvider *pProvider);
102
103     // The one and only EventPipe session.
104     EventPipeSession *m_pSession;
105
106     // Determines whether or not the event pipe is enabled.
107     Volatile<bool> m_enabled;
108
109     // The list of event pipe providers.
110     SList<SListElem<EventPipeProvider *>> *m_pProviderList;
111
112     // The provider used to write configuration events to the event stream.
113     EventPipeProvider *m_pConfigProvider;
114
115     // The event used to write event information to the event stream.
116     EventPipeEvent *m_pMetadataEvent;
117
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;
121
122     // True if rundown is enabled.
123     Volatile<bool> m_rundownEnabled;
124
125     // The rundown thread.  If rundown is not enabled, this is NULL.
126     Thread *m_pRundownThread;
127 };
128
129 #endif // FEATURE_PERFTRACING
130
131 #endif // __EVENTPIPE_CONFIGURATION_H__