Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TplEventSource.cs
Go to the documentation of this file.
5
7
8[EventSource(Name = "System.Threading.Tasks.TplEventSource", Guid = "2e5dba47-a3d2-4d16-8ee0-6671ffdcd7b5", LocalizationResources = "System.Private.CoreLib.Strings")]
9internal sealed class TplEventSource : EventSource
10{
11 public enum TaskWaitBehavior
12 {
13 Synchronous = 1,
15 }
16
17 public static class Tasks
18 {
19 public const EventTask Loop = (EventTask)1;
20
21 public const EventTask Invoke = (EventTask)2;
22
23 public const EventTask TaskExecute = (EventTask)3;
24
25 public const EventTask TaskWait = (EventTask)4;
26
27 public const EventTask ForkJoin = (EventTask)5;
28
30
32
34
36 }
37
64
65 private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe";
66
67 internal bool TasksSetActivityIds;
68
69 internal bool Debug;
70
71 private bool DebugActivityId;
72
73 private const int DefaultAppDomainID = 1;
74
75 public static readonly TplEventSource Log = new TplEventSource();
76
77 private const int TASKSCHEDULED_ID = 7;
78
79 private const int TASKSTARTED_ID = 8;
80
81 private const int TASKCOMPLETED_ID = 9;
82
83 private const int TASKWAITBEGIN_ID = 10;
84
85 private const int TASKWAITEND_ID = 11;
86
87 private const int AWAITTASKCONTINUATIONSCHEDULED_ID = 12;
88
89 private const int TASKWAITCONTINUATIONCOMPLETE_ID = 13;
90
91 private const int TASKWAITCONTINUATIONSTARTED_ID = 19;
92
93 private const int TRACEOPERATIONSTART_ID = 14;
94
95 private const int TRACEOPERATIONSTOP_ID = 15;
96
97 private const int TRACEOPERATIONRELATION_ID = 16;
98
99 private const int TRACESYNCHRONOUSWORKSTART_ID = 17;
100
101 private const int TRACESYNCHRONOUSWORKSTOP_ID = 18;
102
103 private protected override ReadOnlySpan<byte> ProviderMetadata => new byte[40]
104 {
105 40, 0, 83, 121, 115, 116, 101, 109, 46, 84,
106 104, 114, 101, 97, 100, 105, 110, 103, 46, 84,
107 97, 115, 107, 115, 46, 84, 112, 108, 69, 118,
108 101, 110, 116, 83, 111, 117, 114, 99, 101, 0
109 };
110
111 protected override void OnEventCommand(EventCommandEventArgs command)
112 {
113 if (IsEnabled(EventLevel.Informational, (EventKeywords)128L))
114 {
115 ActivityTracker.Instance.Enable();
116 }
117 else
118 {
120 }
121 Debug = IsEnabled(EventLevel.Informational, (EventKeywords)131072L);
122 DebugActivityId = IsEnabled(EventLevel.Informational, (EventKeywords)262144L);
123 }
124
125 private TplEventSource(int _)
126 {
127 }
128
129 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
130 [Event(7, Task = (EventTask)6, Version = 1, Opcode = EventOpcode.Send, Level = EventLevel.Informational, Keywords = (EventKeywords)3L)]
131 public unsafe void TaskScheduled(int OriginatingTaskSchedulerID, int OriginatingTaskID, int TaskID, int CreatingTaskID, int TaskCreationOptions, int appDomain = 1)
132 {
133 if (IsEnabled() && IsEnabled(EventLevel.Informational, (EventKeywords)3L))
134 {
135 EventData* ptr = stackalloc EventData[6];
136 ptr->Size = 4;
137 ptr->DataPointer = (IntPtr)(&OriginatingTaskSchedulerID);
138 ptr->Reserved = 0;
139 ptr[1].Size = 4;
140 ptr[1].DataPointer = (IntPtr)(&OriginatingTaskID);
141 ptr[1].Reserved = 0;
142 ptr[2].Size = 4;
143 ptr[2].DataPointer = (IntPtr)(&TaskID);
144 ptr[2].Reserved = 0;
145 ptr[3].Size = 4;
146 ptr[3].DataPointer = (IntPtr)(&CreatingTaskID);
147 ptr[3].Reserved = 0;
148 ptr[4].Size = 4;
150 ptr[4].Reserved = 0;
151 ptr[5].Size = 4;
152 ptr[5].DataPointer = (IntPtr)(&appDomain);
153 ptr[5].Reserved = 0;
155 {
156 Guid guid = CreateGuidForTaskID(TaskID);
157 WriteEventWithRelatedActivityIdCore(7, &guid, 6, ptr);
158 }
159 else
160 {
161 WriteEventCore(7, 6, ptr);
162 }
163 }
164 }
165
166 [Event(8, Level = EventLevel.Informational, Keywords = (EventKeywords)2L)]
167 public void TaskStarted(int OriginatingTaskSchedulerID, int OriginatingTaskID, int TaskID)
168 {
169 if (IsEnabled(EventLevel.Informational, (EventKeywords)2L))
170 {
171 WriteEvent(8, OriginatingTaskSchedulerID, OriginatingTaskID, TaskID);
172 }
173 }
174
175 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
176 [Event(9, Version = 1, Level = EventLevel.Informational, Keywords = (EventKeywords)64L)]
177 public unsafe void TaskCompleted(int OriginatingTaskSchedulerID, int OriginatingTaskID, int TaskID, bool IsExceptional)
178 {
179 if (IsEnabled() && IsEnabled(EventLevel.Informational, (EventKeywords)2L))
180 {
181 EventData* ptr = stackalloc EventData[4];
182 int num = (IsExceptional ? 1 : 0);
183 ptr->Size = 4;
184 ptr->DataPointer = (IntPtr)(&OriginatingTaskSchedulerID);
185 ptr->Reserved = 0;
186 ptr[1].Size = 4;
187 ptr[1].DataPointer = (IntPtr)(&OriginatingTaskID);
188 ptr[1].Reserved = 0;
189 ptr[2].Size = 4;
190 ptr[2].DataPointer = (IntPtr)(&TaskID);
191 ptr[2].Reserved = 0;
192 ptr[3].Size = 4;
193 ptr[3].DataPointer = (IntPtr)(&num);
194 ptr[3].Reserved = 0;
195 WriteEventCore(9, 4, ptr);
196 }
197 }
198
199 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
200 [Event(10, Version = 3, Task = (EventTask)4, Opcode = EventOpcode.Send, Level = EventLevel.Informational, Keywords = (EventKeywords)3L)]
201 public unsafe void TaskWaitBegin(int OriginatingTaskSchedulerID, int OriginatingTaskID, int TaskID, TaskWaitBehavior Behavior, int ContinueWithTaskID)
202 {
203 if (IsEnabled() && IsEnabled(EventLevel.Informational, (EventKeywords)3L))
204 {
205 EventData* ptr = stackalloc EventData[5];
206 ptr->Size = 4;
207 ptr->DataPointer = (IntPtr)(&OriginatingTaskSchedulerID);
208 ptr->Reserved = 0;
209 ptr[1].Size = 4;
210 ptr[1].DataPointer = (IntPtr)(&OriginatingTaskID);
211 ptr[1].Reserved = 0;
212 ptr[2].Size = 4;
213 ptr[2].DataPointer = (IntPtr)(&TaskID);
214 ptr[2].Reserved = 0;
215 ptr[3].Size = 4;
216 ptr[3].DataPointer = (IntPtr)(&Behavior);
217 ptr[3].Reserved = 0;
218 ptr[4].Size = 4;
219 ptr[4].DataPointer = (IntPtr)(&ContinueWithTaskID);
220 ptr[4].Reserved = 0;
222 {
223 Guid guid = CreateGuidForTaskID(TaskID);
224 WriteEventWithRelatedActivityIdCore(10, &guid, 5, ptr);
225 }
226 else
227 {
228 WriteEventCore(10, 5, ptr);
229 }
230 }
231 }
232
233 [Event(11, Level = EventLevel.Verbose, Keywords = (EventKeywords)2L)]
234 public void TaskWaitEnd(int OriginatingTaskSchedulerID, int OriginatingTaskID, int TaskID)
235 {
236 if (IsEnabled() && IsEnabled(EventLevel.Verbose, (EventKeywords)2L))
237 {
238 WriteEvent(11, OriginatingTaskSchedulerID, OriginatingTaskID, TaskID);
239 }
240 }
241
242 [Event(13, Level = EventLevel.Verbose, Keywords = (EventKeywords)64L)]
243 public void TaskWaitContinuationComplete(int TaskID)
244 {
245 if (IsEnabled() && IsEnabled(EventLevel.Verbose, (EventKeywords)64L))
246 {
247 WriteEvent(13, TaskID);
248 }
249 }
250
251 [Event(19, Level = EventLevel.Verbose, Keywords = (EventKeywords)2L)]
252 public void TaskWaitContinuationStarted(int TaskID)
253 {
254 if (IsEnabled() && IsEnabled(EventLevel.Verbose, (EventKeywords)2L))
255 {
256 WriteEvent(19, TaskID);
257 }
258 }
259
260 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
261 [Event(12, Task = (EventTask)7, Opcode = EventOpcode.Send, Level = EventLevel.Informational, Keywords = (EventKeywords)3L)]
262 public unsafe void AwaitTaskContinuationScheduled(int OriginatingTaskSchedulerID, int OriginatingTaskID, int ContinueWithTaskId)
263 {
264 if (IsEnabled() && IsEnabled(EventLevel.Informational, (EventKeywords)3L))
265 {
266 EventData* ptr = stackalloc EventData[3];
267 ptr->Size = 4;
268 ptr->DataPointer = (IntPtr)(&OriginatingTaskSchedulerID);
269 ptr->Reserved = 0;
270 ptr[1].Size = 4;
271 ptr[1].DataPointer = (IntPtr)(&OriginatingTaskID);
272 ptr[1].Reserved = 0;
273 ptr[2].Size = 4;
274 ptr[2].DataPointer = (IntPtr)(&ContinueWithTaskId);
275 ptr[2].Reserved = 0;
277 {
278 Guid guid = CreateGuidForTaskID(ContinueWithTaskId);
279 WriteEventWithRelatedActivityIdCore(12, &guid, 3, ptr);
280 }
281 else
282 {
283 WriteEventCore(12, 3, ptr);
284 }
285 }
286 }
287
288 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
289 [Event(14, Version = 1, Level = EventLevel.Informational, Keywords = (EventKeywords)8L)]
290 public unsafe void TraceOperationBegin(int TaskID, string OperationName, long RelatedContext)
291 {
292 if (IsEnabled() && IsEnabled(EventLevel.Informational, (EventKeywords)8L))
293 {
294 fixed (char* ptr2 = OperationName)
295 {
296 EventData* ptr = stackalloc EventData[3];
297 ptr->Size = 4;
298 ptr->DataPointer = (IntPtr)(&TaskID);
299 ptr->Reserved = 0;
300 ptr[1].Size = (OperationName.Length + 1) * 2;
301 ptr[1].DataPointer = (IntPtr)ptr2;
302 ptr[1].Reserved = 0;
303 ptr[2].Size = 8;
304 ptr[2].DataPointer = (IntPtr)(&RelatedContext);
305 ptr[2].Reserved = 0;
306 WriteEventCore(14, 3, ptr);
307 }
308 }
309 }
310
311 [Event(16, Version = 1, Level = EventLevel.Informational, Keywords = (EventKeywords)16L)]
312 public void TraceOperationRelation(int TaskID, CausalityRelation Relation)
313 {
314 if (IsEnabled() && IsEnabled(EventLevel.Informational, (EventKeywords)16L))
315 {
316 WriteEvent(16, TaskID, (int)Relation);
317 }
318 }
319
320 [Event(15, Version = 1, Level = EventLevel.Informational, Keywords = (EventKeywords)8L)]
321 public void TraceOperationEnd(int TaskID, AsyncCausalityStatus Status)
322 {
323 if (IsEnabled() && IsEnabled(EventLevel.Informational, (EventKeywords)8L))
324 {
325 WriteEvent(15, TaskID, (int)Status);
326 }
327 }
328
329 [Event(17, Version = 1, Level = EventLevel.Informational, Keywords = (EventKeywords)32L)]
331 {
332 if (IsEnabled() && IsEnabled(EventLevel.Informational, (EventKeywords)32L))
333 {
334 WriteEvent(17, TaskID, (int)Work);
335 }
336 }
337
338 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
339 [Event(18, Version = 1, Level = EventLevel.Informational, Keywords = (EventKeywords)32L)]
341 {
342 if (IsEnabled() && IsEnabled(EventLevel.Informational, (EventKeywords)32L))
343 {
344 EventData* ptr = stackalloc EventData[1];
345 ptr->Size = 4;
346 ptr->DataPointer = (IntPtr)(&Work);
347 ptr->Reserved = 0;
348 WriteEventCore(18, 1, ptr);
349 }
350 }
351
352 [NonEvent]
353 public unsafe void RunningContinuation(int TaskID, object Object)
354 {
355 RunningContinuation(TaskID, (long)(nuint)(*(nint*)Unsafe.AsPointer(ref Object)));
356 }
357
358 [Event(20, Keywords = (EventKeywords)131072L)]
359 private void RunningContinuation(int TaskID, long Object)
360 {
361 if (Debug)
362 {
363 WriteEvent(20, TaskID, Object);
364 }
365 }
366
367 [NonEvent]
368 public unsafe void RunningContinuationList(int TaskID, int Index, object Object)
369 {
370 RunningContinuationList(TaskID, Index, (long)(nuint)(*(nint*)Unsafe.AsPointer(ref Object)));
371 }
372
373 [Event(21, Keywords = (EventKeywords)131072L)]
374 public void RunningContinuationList(int TaskID, int Index, long Object)
375 {
376 if (Debug)
377 {
378 WriteEvent(21, TaskID, Index, Object);
379 }
380 }
381
382 [Event(23, Keywords = (EventKeywords)131072L)]
383 public void DebugFacilityMessage(string Facility, string Message)
384 {
385 WriteEvent(23, Facility, Message);
386 }
387
388 [Event(24, Keywords = (EventKeywords)131072L)]
389 public void DebugFacilityMessage1(string Facility, string Message, string Value1)
390 {
391 WriteEvent(24, Facility, Message, Value1);
392 }
393
394 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Guid parameter is safe with WriteEvent")]
395 [Event(25, Keywords = (EventKeywords)262144L)]
396 public void SetActivityId(Guid NewId)
397 {
398 if (DebugActivityId)
399 {
400 WriteEvent(25, NewId);
401 }
402 }
403
404 [Event(26, Keywords = (EventKeywords)131072L)]
405 public void NewID(int TaskID)
406 {
407 if (Debug)
408 {
409 WriteEvent(26, TaskID);
410 }
411 }
412
413 [NonEvent]
414 public void IncompleteAsyncMethod(IAsyncStateMachineBox stateMachineBox)
415 {
416 if (IsEnabled() && IsEnabled(EventLevel.Warning, (EventKeywords)256L))
417 {
418 IAsyncStateMachine stateMachineObject = stateMachineBox.GetStateMachineObject();
419 if (stateMachineObject != null)
420 {
421 string asyncStateMachineDescription = AsyncMethodBuilderCore.GetAsyncStateMachineDescription(stateMachineObject);
422 IncompleteAsyncMethod(asyncStateMachineDescription);
423 }
424 }
425 }
426
427 [Event(27, Level = EventLevel.Warning, Keywords = (EventKeywords)256L)]
428 private void IncompleteAsyncMethod(string stateMachineDescription)
429 {
430 WriteEvent(27, stateMachineDescription);
431 }
432
433 internal static Guid CreateGuidForTaskID(int taskID)
434 {
435 int processId = Environment.ProcessId;
436 return new Guid(taskID, 1, 0, (byte)processId, (byte)(processId >> 8), (byte)(processId >> 16), (byte)(processId >> 24), byte.MaxValue, 220, 215, 181);
437 }
438
440 : base(new Guid(777894471u, 41938, 19734, 142, 224, 102, 113, byte.MaxValue, 220, 215, 181), "System.Threading.Tasks.TplEventSource")
441 {
442 }
443}
unsafe void WriteEventCore(int eventId, int eventDataCount, EventData *data)
unsafe void WriteEventWithRelatedActivityIdCore(int eventId, Guid *relatedActivityId, int eventDataCount, EventData *data)
unsafe void WriteEvent(int eventId)
static int ProcessId
static string GetAsyncStateMachineDescription(IAsyncStateMachine stateMachine)
unsafe void TaskScheduled(int OriginatingTaskSchedulerID, int OriginatingTaskID, int TaskID, int CreatingTaskID, int TaskCreationOptions, int appDomain=1)
void IncompleteAsyncMethod(string stateMachineDescription)
void DebugFacilityMessage1(string Facility, string Message, string Value1)
void TraceOperationEnd(int TaskID, AsyncCausalityStatus Status)
static readonly TplEventSource Log
unsafe void RunningContinuationList(int TaskID, int Index, object Object)
void IncompleteAsyncMethod(IAsyncStateMachineBox stateMachineBox)
unsafe void RunningContinuation(int TaskID, object Object)
void RunningContinuationList(int TaskID, int Index, long Object)
void RunningContinuation(int TaskID, long Object)
static Guid CreateGuidForTaskID(int taskID)
unsafe void TaskCompleted(int OriginatingTaskSchedulerID, int OriginatingTaskID, int TaskID, bool IsExceptional)
override void OnEventCommand(EventCommandEventArgs command)
unsafe void TraceSynchronousWorkEnd(CausalitySynchronousWork Work)
void DebugFacilityMessage(string Facility, string Message)
void TaskWaitEnd(int OriginatingTaskSchedulerID, int OriginatingTaskID, int TaskID)
void TaskStarted(int OriginatingTaskSchedulerID, int OriginatingTaskID, int TaskID)
override ReadOnlySpan< byte > ProviderMetadata
unsafe void TaskWaitBegin(int OriginatingTaskSchedulerID, int OriginatingTaskID, int TaskID, TaskWaitBehavior Behavior, int ContinueWithTaskID)
unsafe void AwaitTaskContinuationScheduled(int OriginatingTaskSchedulerID, int OriginatingTaskID, int ContinueWithTaskId)
void TraceSynchronousWorkBegin(int TaskID, CausalitySynchronousWork Work)
void TraceOperationRelation(int TaskID, CausalityRelation Relation)
unsafe void TraceOperationBegin(int TaskID, string OperationName, long RelatedContext)