1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5#ifndef __EVENTPIPE_EVENT_H__
6#define __EVENTPIPE_EVENT_H__
7
8#ifdef FEATURE_PERFTRACING
9
10#include "eventpipeprovider.h"
11
12class EventPipeEvent
13{
14 // Declare friends.
15 friend class EventPipeProvider;
16
17private:
18
19 // The provider that contains the event.
20 EventPipeProvider *m_pProvider;
21
22 // Bit vector containing the keywords that enable the event.
23 INT64 m_keywords;
24
25 // The ID (within the provider) of the event.
26 unsigned int m_eventID;
27
28 // The version of the event.
29 unsigned int m_eventVersion;
30
31 // The verbosity of the event.
32 EventPipeEventLevel m_level;
33
34 // True if a call stack should be captured when writing the event.
35 bool m_needStack;
36
37 // True if the event is current enabled.
38 Volatile<bool> m_enabled;
39
40 // Metadata
41 BYTE *m_pMetadata;
42
43 // Metadata length;
44 unsigned int m_metadataLength;
45
46 // Refreshes the runtime state for this event.
47 // Called by EventPipeProvider when the provider configuration changes.
48 void RefreshState();
49
50 // Only EventPipeProvider can create events.
51 // The provider is responsible for allocating and freeing events.
52 EventPipeEvent(EventPipeProvider &provider, INT64 keywords, unsigned int eventID, unsigned int eventVersion, EventPipeEventLevel level, bool needStack, BYTE *pMetadata = NULL, unsigned int metadataLength = 0);
53
54 public:
55 ~EventPipeEvent();
56
57 // Get the provider associated with this event.
58 EventPipeProvider* GetProvider() const;
59
60 // Get the keywords that enable the event.
61 INT64 GetKeywords() const;
62
63 // Get the ID (within the provider) of the event.
64 unsigned int GetEventID() const;
65
66 // Get the version of the event.
67 unsigned int GetEventVersion() const;
68
69 // Get the verbosity of the event.
70 EventPipeEventLevel GetLevel() const;
71
72 // True if a call stack should be captured when writing the event.
73 bool NeedStack() const;
74
75 // True if the event is currently enabled.
76 bool IsEnabled() const;
77
78 BYTE *GetMetadata() const;
79
80 unsigned int GetMetadataLength() const;
81
82 private:
83 // used when Metadata is not provided
84 BYTE *BuildMinimumMetadata();
85
86 unsigned int GetMinimumMetadataLength();
87};
88
89#endif // FEATURE_PERFTRACING
90
91#endif // __EVENTPIPE_EVENT_H__
92