summaryrefslogtreecommitdiff
path: root/src/vm/eventpipeconfiguration.h
blob: de8e79d2f3b75011932384c617fd4ffa996c0a4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#ifndef __EVENTPIPE_CONFIGURATION_H__
#define __EVENTPIPE_CONFIGURATION_H__

#ifdef FEATURE_PERFTRACING

#include "slist.h"

class EventPipeEnabledProvider;
class EventPipeEnabledProviderList;
class EventPipeEvent;
class EventPipeEventInstance;
class EventPipeProvider;
struct EventPipeProviderConfiguration;

enum class EventPipeEventLevel
{
    LogAlways,
    Critical,
    Error,
    Warning,
    Informational,
    Verbose
};

class EventPipeConfiguration
{
public:

    EventPipeConfiguration();
    ~EventPipeConfiguration();

    // Perform initialization that cannot be performed in the constructor.
    void Initialize();

    // Register a provider.
    bool RegisterProvider(EventPipeProvider &provider);

    // Unregister a provider.
    bool UnregisterProvider(EventPipeProvider &provider);

    // Get the provider with the specified provider ID if it exists.
    EventPipeProvider* GetProvider(const GUID &providerID);

    // Get the configured size of the circular buffer.
    size_t GetCircularBufferSize() const;

    // Set the configured size of the circular buffer.
    void SetCircularBufferSize(size_t circularBufferSize);

    // Enable the event pipe.
    void Enable(
        uint circularBufferSizeInMB,
        EventPipeProviderConfiguration *pProviders,
        int numProviders);

    // Disable the event pipe.
    void Disable();

    // Get the status of the event pipe.
    bool Enabled() const;

    // Determine if rundown is enabled.
    bool RundownEnabled() const;

    // Enable the well-defined symbolic rundown configuration.
    void EnableRundown();

    // Get the event used to write metadata to the event stream.
    EventPipeEventInstance* BuildEventMetadataEvent(EventPipeEventInstance &sourceInstance);

    // Delete deferred providers.
    void DeleteDeferredProviders();

private:

    // Get the provider without taking the lock.
    EventPipeProvider* GetProviderNoLock(const GUID &providerID);

    // Determines whether or not the event pipe is enabled.
    Volatile<bool> m_enabled;

    // The configured size of the circular buffer.
    size_t m_circularBufferSizeInBytes;

    // EventPipeConfiguration only supports a single session.
    // This is the set of configurations for each enabled provider.
    EventPipeEnabledProviderList *m_pEnabledProviderList;

    // The list of event pipe providers.
    SList<SListElem<EventPipeProvider*>> *m_pProviderList;

    // The provider used to write configuration events to the event stream.
    EventPipeProvider *m_pConfigProvider;

    // The event used to write event information to the event stream.
    EventPipeEvent *m_pMetadataEvent;

    // The provider ID for the configuration event pipe provider.
    // This provider is used to emit configuration events.
    static const GUID s_configurationProviderID;

    // True if rundown is enabled.
    Volatile<bool> m_rundownEnabled;
};

class EventPipeEnabledProviderList
{

private:

    // The number of providers in the list.
    unsigned int m_numProviders;

    // The list of providers.
    EventPipeEnabledProvider *m_pProviders;

    // A catch-all provider used when tracing is enabled at start-up
    // under (COMPlus_PerformanceTracing & 1) == 1.
    EventPipeEnabledProvider *m_pCatchAllProvider;

public:

    // Create a new list based on the input.
    EventPipeEnabledProviderList(EventPipeProviderConfiguration *pConfigs, unsigned int numConfigs);
    ~EventPipeEnabledProviderList();

    // Get the enabled provider for the specified provider.
    // Return NULL if one doesn't exist.
    EventPipeEnabledProvider* GetEnabledProvider(EventPipeProvider *pProvider);
};

class EventPipeEnabledProvider
{
private:

    // The provider name.
    WCHAR *m_pProviderName;

    // The enabled keywords.
    UINT64 m_keywords;

    // The loging level.
    EventPipeEventLevel m_loggingLevel;

public:

    EventPipeEnabledProvider();
    ~EventPipeEnabledProvider();

    void Set(LPCWSTR providerName, UINT64 keywords, EventPipeEventLevel loggingLevel);

    LPCWSTR GetProviderName() const;

    UINT64 GetKeywords() const;

    EventPipeEventLevel GetLevel() const;
};

#endif // FEATURE_PERFTRACING

#endif // __EVENTPIPE_CONFIGURATION_H__