-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventHeaderExtensionKind.cs
More file actions
115 lines (108 loc) · 4.88 KB
/
EventHeaderExtensionKind.cs
File metadata and controls
115 lines (108 loc) · 4.88 KB
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace Microsoft.LinuxTracepoints
{
/// <summary>
/// Values for EventHeaderExtension.Kind.
/// </summary>
public enum EventHeaderExtensionKind : ushort
{
/// <summary>
/// Mask for the base extension kind (low 15 bits).
/// </summary>
ValueMask = 0x7fff,
/// <summary>
/// If not set, this is the last extension block (event payload data follows).
/// If set, this is not the last extension block (another extension block follows).
/// </summary>
ChainFlag = 0x8000,
/// <summary>
/// Invalid extension kind.
/// </summary>
Invalid = 0,
/// <summary>
/// <para>
/// Extension contains an event definition (i.e. event metadata).
/// </para><para>
/// Event definition format:
/// </para><list type="bullet"><item>
/// char EventName[]; // Nul-terminated utf-8 string: "eventName{;attribName=attribValue}"
/// </item><item>
/// 0 or more field definition blocks.
/// </item></list><para>
/// Field definition block:
/// </para><list type="bullet"><item>
/// char FieldName[]; // Nul-terminated utf-8 string: "fieldName{;attribName=attribValue}"
/// </item><item>
/// uint8_t Encoding; // Encoding is 0..31, with 3 flag bits.
/// </item><item>
/// uint8_t Format; // Present if (Encoding & 128). Format is 0..127, with 1 flag bit.
/// </item><item>
/// uint16_t Tag; // Present if (Format & 128). Contains provider-defined value.
/// </item><item>
/// uint16_t ArrayLength; // Present if (Encoding & 32). Contains element count of constant-length array.
/// </item></list><para>
/// Notes:
/// </para><list type="bullet"><item>
/// eventName and fieldName may not contain any ';' characters.
/// </item><item>
/// eventName and fieldName may be followed by attribute strings.
/// </item><item>
/// attribute string is: ';' + attribName + '=' + attribValue.
/// </item><item>
/// attribName may not contain any ';' or '=' characters.
/// </item><item>
/// Semicolons in attribValue must be escaped by doubling, e.g.
/// "my;value" is escaped as "my;;value".
/// </item></list>
/// </summary>
Metadata,
/// <summary>
/// <para>
/// Extension contains activity id information.
/// </para><para>
/// Any event that is part of an activity has an ActivityId extension.
/// </para><list type="bullet"><item>
/// Activity is started by an event with opcode = ActivityStart. The
/// ActivityId extension for the start event must contain a newly-generated
/// activity id and may optionally contain the parent activity id.
/// </item><item>
/// Activity may contain any number of normal events (opcode something other
/// than ActivityStart or ActivityStop). The ActivityId extension for each
/// normal event must contain the id of the associated activity (otherwise
/// it is not considered to be part of the activity).
/// </item><item>
/// Activity is ended by an event with opcode = ActivityStop. The ActivityId
/// extension for the stop event must contain the id of the activity that is
/// ending.
/// </item></list><para>
/// An activity id is a 128-bit value that is unique within this trace
/// session. It may be a UUID. Since UUID generation can be expensive, this
/// may also be a 128-bit LUID (locally-unique id), generated using any method
/// that is unlikely to conflict with other activity ids in the same trace.
/// </para><para>
/// If extension.Size == 16 then value is a 128-bit activity id.
/// </para><para>
/// If extension.Size == 32 then value is a 128-bit activity id followed by a
/// 128-bit related (parent) activity id.
/// </para>
/// </summary>
ActivityId,
}
/// <summary>
/// Extension methods for <see cref="EventHeaderExtensionKind"/>.
/// </summary>
public static class EventHeaderExtensionKindExtensions
{
/// <summary>
/// Returns the format without any flags (format & ValueMask).
/// </summary>
public static EventHeaderExtensionKind BaseKind(this EventHeaderExtensionKind kind) =>
kind & EventHeaderExtensionKind.ValueMask;
/// <summary>
/// Returns true if ChainFlag is present (more extensions are present in event).
/// </summary>
public static bool HasChainFlag(this EventHeaderExtensionKind kind) =>
0 != (kind & EventHeaderExtensionKind.ChainFlag);
}
}