-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
eventtrace.cpp
7833 lines (6752 loc) · 292 KB
/
eventtrace.cpp
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// File: eventtrace.cpp
// Abstract: This module implements Event Tracing support
//
//
//
// ============================================================================
#include "common.h"
#ifdef FEATURE_NATIVEAOT
#include "commontypes.h"
#include "daccess.h"
#include "debugmacrosext.h"
#include "palredhawkcommon.h"
#include "gcrhenv.h"
#define Win32EventWrite PalEtwEventWrite
#define InterlockedExchange64 PalInterlockedExchange64
#else // !FEATURE_NATIVEAOT
#include "eventtrace.h"
#include "winbase.h"
#include "contract.h"
#include "ex.h"
#include "dbginterface.h"
#include "finalizerthread.h"
#include "clrversion.h"
#include "typestring.h"
#define Win32EventWrite EventWrite
#ifdef FEATURE_COMINTEROP
#include "comcallablewrapper.h"
#include "runtimecallablewrapper.h"
#endif
#endif // FEATURE_NATIVEAOT
#include "eventtracepriv.h"
#ifndef HOST_UNIX
DOTNET_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context = { &MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_Context, MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_EVENTPIPE_Context };
DOTNET_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context = { &MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_Context, MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_EVENTPIPE_Context };
DOTNET_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_DOTNET_Context = { &MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_Context, MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_EVENTPIPE_Context };
DOTNET_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_STRESS_PROVIDER_DOTNET_Context = { &MICROSOFT_WINDOWS_DOTNETRUNTIME_STRESS_PROVIDER_Context, MICROSOFT_WINDOWS_DOTNETRUNTIME_STRESS_PROVIDER_EVENTPIPE_Context };
#else
DOTNET_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context = { MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_EVENTPIPE_Context, &MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_LTTNG_Context };
DOTNET_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context = { MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_EVENTPIPE_Context, &MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_LTTNG_Context };
DOTNET_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_DOTNET_Context = { MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_EVENTPIPE_Context, &MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_LTTNG_Context };
DOTNET_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_STRESS_PROVIDER_DOTNET_Context = { MICROSOFT_WINDOWS_DOTNETRUNTIME_STRESS_PROVIDER_EVENTPIPE_Context, &MICROSOFT_WINDOWS_DOTNETRUNTIME_STRESS_PROVIDER_LTTNG_Context };
#endif // HOST_UNIX
#ifdef FEATURE_NATIVEAOT
volatile LONGLONG ETW::GCLog::s_l64LastClientSequenceNumber = 0;
#else // FEATURE_NATIVEAOT
Volatile<LONGLONG> ETW::GCLog::s_l64LastClientSequenceNumber = 0;
#endif // FEATURE_NATIVEAOT
#ifndef FEATURE_NATIVEAOT
//---------------------------------------------------------------------------------------
// Helper macros to determine which version of the Method events to use
//
// The V2 versions of these events include the NativeCodeId, the V1 versions do not.
// Historically, when we version events, we'd just stop sending the old version and only
// send the new one. However, now that we have xperf in heavy use internally and soon to be
// used externally, we need to be a bit careful. In particular, we'd like to allow
// current xperf to continue working without knowledge of NativeCodeIds, and allow future
// xperf to decode symbols in ReJITted functions. Thus,
// * During a first-JIT, only issue the existing V1 MethodLoad, etc. events (NOT v0,
// NOT v2). This event does not include a NativeCodeId, and can thus continue to be
// parsed by older decoders.
// * During a rejit, only issue the new V2 events (NOT v0 or v1), which will include a
// nonzero NativeCodeId. Thus, your unique key for a method extent would be MethodID +
// NativeCodeId + extent (hot/cold). These events will be ignored by older decoders
// (including current xperf) because of the version number, but xperf will be
// updated to decode these in the future.
#define FireEtwMethodLoadVerbose_V1_or_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID, nativeCodeId) \
{ \
if (nativeCodeId == 0) \
{ FireEtwMethodLoadVerbose_V1(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID); } \
else \
{ FireEtwMethodLoadVerbose_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID, nativeCodeId); } \
}
#define FireEtwMethodLoad_V1_or_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulMethodFlags, clrInstanceID, nativeCodeId) \
{ \
if (nativeCodeId == 0) \
{ FireEtwMethodLoad_V1(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulMethodFlags, clrInstanceID); } \
else \
{ FireEtwMethodLoad_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulMethodFlags, clrInstanceID, nativeCodeId); } \
}
#define FireEtwMethodUnloadVerbose_V1_or_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID, nativeCodeId) \
{ \
if (nativeCodeId == 0) \
{ FireEtwMethodUnloadVerbose_V1(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID); } \
else \
{ FireEtwMethodUnloadVerbose_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID, nativeCodeId); } \
}
#define FireEtwMethodUnload_V1_or_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, clrInstanceID, nativeCodeId) \
{ \
if (nativeCodeId == 0) \
{ FireEtwMethodUnload_V1(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, clrInstanceID); } \
else \
{ FireEtwMethodUnload_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, clrInstanceID, nativeCodeId); } \
}
#define FireEtwMethodDCStartVerbose_V1_or_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID, nativeCodeId) \
{ \
if (nativeCodeId == 0) \
{ FireEtwMethodDCStartVerbose_V1(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID); } \
else \
{ FireEtwMethodDCStartVerbose_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID, nativeCodeId); } \
}
#define FireEtwMethodDCStart_V1_or_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, clrInstanceID, nativeCodeId) \
{ \
if (nativeCodeId == 0) \
{ FireEtwMethodDCStart_V1(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, clrInstanceID); } \
else \
{ FireEtwMethodDCStart_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, clrInstanceID, nativeCodeId); } \
}
#define FireEtwMethodDCEndVerbose_V1_or_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID, nativeCodeId) \
{ \
if (nativeCodeId == 0) \
{ FireEtwMethodDCEndVerbose_V1(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID); } \
else \
{ FireEtwMethodDCEndVerbose_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, szDtraceOutput1, szDtraceOutput2, szDtraceOutput3, clrInstanceID, nativeCodeId); } \
}
#define FireEtwMethodDCEnd_V1_or_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, clrInstanceID, nativeCodeId) \
{ \
if (nativeCodeId == 0) \
{ FireEtwMethodDCEnd_V1(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, clrInstanceID); } \
else \
{ FireEtwMethodDCEnd_V2(ullMethodIdentifier, ullModuleID, ullMethodStartAddress, ulMethodSize, ulMethodToken, ulColdMethodFlags, clrInstanceID, nativeCodeId); } \
}
// Module load / unload events:
#define FireEtwModuleLoad_V1_or_V2(ullModuleId, ullAssemblyId, ulFlags, ulReservedFlags, szDtraceOutput1, szDtraceOutput2, clrInstanceId, ManagedPdbSignature, ManagedPdbAge, ManagedPdbPath, NativePdbSignature, NativePdbAge, NativePdbPath) \
FireEtwModuleLoad_V2(ullModuleId, ullAssemblyId, ulFlags, ulReservedFlags, szDtraceOutput1, szDtraceOutput2, clrInstanceId, ManagedPdbSignature, ManagedPdbAge, ManagedPdbPath, NativePdbSignature, NativePdbAge, NativePdbPath)
#define FireEtwModuleUnload_V1_or_V2(ullModuleId, ullAssemblyId, ulFlags, ulReservedFlags, szDtraceOutput1, szDtraceOutput2, clrInstanceId, ManagedPdbSignature, ManagedPdbAge, ManagedPdbPath, NativePdbSignature, NativePdbAge, NativePdbPath) \
FireEtwModuleUnload_V2(ullModuleId, ullAssemblyId, ulFlags, ulReservedFlags, szDtraceOutput1, szDtraceOutput2, clrInstanceId, ManagedPdbSignature, ManagedPdbAge, ManagedPdbPath, NativePdbSignature, NativePdbAge, NativePdbPath)
#define FireEtwModuleDCStart_V1_or_V2(ullModuleId, ullAssemblyId, ulFlags, ulReservedFlags, szDtraceOutput1, szDtraceOutput2, clrInstanceId, ManagedPdbSignature, ManagedPdbAge, ManagedPdbPath, NativePdbSignature, NativePdbAge, NativePdbPath) \
FireEtwModuleDCStart_V2(ullModuleId, ullAssemblyId, ulFlags, ulReservedFlags, szDtraceOutput1, szDtraceOutput2, clrInstanceId, ManagedPdbSignature, ManagedPdbAge, ManagedPdbPath, NativePdbSignature, NativePdbAge, NativePdbPath)
#define FireEtwModuleDCEnd_V1_or_V2(ullModuleId, ullAssemblyId, ulFlags, ulReservedFlags, szDtraceOutput1, szDtraceOutput2, clrInstanceId, ManagedPdbSignature, ManagedPdbAge, ManagedPdbPath, NativePdbSignature, NativePdbAge, NativePdbPath) \
FireEtwModuleDCEnd_V2(ullModuleId, ullAssemblyId, ulFlags, ulReservedFlags, szDtraceOutput1, szDtraceOutput2, clrInstanceId, ManagedPdbSignature, ManagedPdbAge, ManagedPdbPath, NativePdbSignature, NativePdbAge, NativePdbPath)
//---------------------------------------------------------------------------------------
//
// Rather than checking the NGEN keyword on the runtime provider directly, use this
// helper that checks that the NGEN runtime provider keyword is enabled AND the
// OverrideAndSuppressNGenEvents keyword on the runtime provider is NOT enabled.
//
// OverrideAndSuppressNGenEvents allows controllers to set the expensive NGEN keyword for
// older runtimes (< 4.0) where NGEN PDB info is NOT available, while suppressing those
// expensive events on newer runtimes (>= 4.5) where NGEN PDB info IS available. Note
// that 4.0 has NGEN PDBS but unfortunately not the OverrideAndSuppressNGenEvents
// keyword, b/c NGEN PDBs were made publicly only after 4.0 shipped. So tools that need
// to consume both <4.0 and 4.0 events would need to enable the expensive NGEN events to
// deal properly with 3.5, even though those events aren't necessary on 4.0.
//
// On CoreCLR, this keyword is a no-op, because coregen PDBs don't exist (and thus we'll
// need the NGEN rundown to still work on Silverligth).
//
// Return Value:
// nonzero iff NGenKeyword is enabled on the runtime provider and
// OverrideAndSuppressNGenEventsKeyword is not enabled on the runtime provider.
//
BOOL IsRuntimeNgenKeywordEnabledAndNotSuppressed()
{
LIMITED_METHOD_CONTRACT;
return
(
ETW_TRACING_CATEGORY_ENABLED(
MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context,
TRACE_LEVEL_INFORMATION,
CLR_NGEN_KEYWORD)
&& ! ( ETW_TRACING_CATEGORY_ENABLED(
MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context,
TRACE_LEVEL_INFORMATION,
CLR_OVERRIDEANDSUPPRESSNGENEVENTS_KEYWORD) )
);
}
// Same as above, but for the rundown provider
BOOL IsRundownNgenKeywordEnabledAndNotSuppressed()
{
LIMITED_METHOD_CONTRACT;
return
#ifdef FEATURE_PERFTRACING
EventPipeHelper::Enabled() ||
#endif // FEATURE_PERFTRACING
(
ETW_TRACING_CATEGORY_ENABLED(
MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_DOTNET_Context,
TRACE_LEVEL_INFORMATION,
CLR_RUNDOWNNGEN_KEYWORD)
&& ! ( ETW_TRACING_CATEGORY_ENABLED(
MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_DOTNET_Context,
TRACE_LEVEL_INFORMATION,
CLR_RUNDOWNOVERRIDEANDSUPPRESSNGENEVENTS_KEYWORD) )
);
}
/*******************************************************/
/* Fast assembly function to get the topmost EBP frame */
/*******************************************************/
#if defined(TARGET_X86)
extern "C"
{
CallStackFrame* GetEbp()
{
CallStackFrame *frame=NULL;
__asm
{
mov frame, ebp
}
return frame;
}
}
#endif //TARGET_X86
/*************************************/
/* Function to append a frame to an existing stack */
/*************************************/
#if !defined(HOST_UNIX)
void ETW::SamplingLog::Append(SIZE_T currentFrame)
{
LIMITED_METHOD_CONTRACT;
if(m_FrameCount < (ETW::SamplingLog::s_MaxStackSize-1) &&
currentFrame != 0)
{
m_EBPStack[m_FrameCount] = currentFrame;
m_FrameCount++;
}
};
/********************************************************/
/* Function to get the callstack on the current thread */
/********************************************************/
ETW::SamplingLog::EtwStackWalkStatus ETW::SamplingLog::GetCurrentThreadsCallStack(UINT32 *frameCount, PVOID **Stack)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;
// The stack walk performed below can cause allocations (thus entering the host). But
// this is acceptable, since we're not supporting the use of SQL/F1 profiling and
// full-blown ETW CLR stacks (which would be redundant).
PERMANENT_CONTRACT_VIOLATION(HostViolation, ReasonUnsupportedForSQLF1Profiling);
m_FrameCount = 0;
ETW::SamplingLog::EtwStackWalkStatus stackwalkStatus = SaveCurrentStack();
_ASSERTE(m_FrameCount < ETW::SamplingLog::s_MaxStackSize);
// this not really needed, but let's do it
// because we use the framecount while dumping the stack event
for(int i=m_FrameCount; i<ETW::SamplingLog::s_MaxStackSize; i++)
{
m_EBPStack[i] = 0;
}
// This is for consumers to work correctly because the number of
// frames in the manifest file is specified to be 2
if(m_FrameCount < 2)
m_FrameCount = 2;
*frameCount = m_FrameCount;
*Stack = (PVOID *)m_EBPStack;
return stackwalkStatus;
};
/*************************************/
/* Function to save the stack on the current thread */
/*************************************/
ETW::SamplingLog::EtwStackWalkStatus ETW::SamplingLog::SaveCurrentStack(int skipTopNFrames)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;
if (!IsGarbageCollectorFullyInitialized())
{
// If the GC isn't ready yet, then there won't be any interesting
// managed code on the stack to walk. Plus, the stack walk itself may
// hit problems (e.g., when calling into the code manager) if it's run
// too early during startup.
return ETW::SamplingLog::UnInitialized;
}
#ifndef DACCESS_COMPILE
#ifdef TARGET_AMD64
if (RtlVirtualUnwind_Unsafe == NULL)
{
// We haven't even set up the RtlVirtualUnwind function pointer yet,
// so it's too early to try stack walking.
return ETW::SamplingLog::UnInitialized;
}
#endif // TARGET_AMD64
Thread *pThread = GetThreadNULLOk();
if (pThread == NULL)
{
return ETW::SamplingLog::UnInitialized;
}
// The thread should not have a hijack set up or we can't walk the stack.
if (pThread->m_State & Thread::TS_Hijacked) {
return ETW::SamplingLog::UnInitialized;
}
if (pThread->IsEtwStackWalkInProgress())
{
return ETW::SamplingLog::InProgress;
}
pThread->MarkEtwStackWalkInProgress();
EX_TRY
{
#ifdef TARGET_X86
CallStackFrame *currentEBP = GetEbp();
CallStackFrame *lastEBP = NULL;
// The EBP stack walk below is meant to be extremely fast. It does not attempt to protect
// against cases of stack corruption. *BUT* it does need to validate a "sane" EBP chain.
// Ensure the EBP in the starting frame is "reasonable" (i.e. above the address of a local)
if ((SIZE_T) currentEBP > (SIZE_T)¤tEBP)
{
while(currentEBP)
{
lastEBP = currentEBP;
currentEBP = currentEBP->m_Next;
// Check for stack upper limit; we don't check the lower limit on each iteration
// (we did it at the top) and each subsequent value in the loop is larger than
// the previous (see the check "currentEBP < lastEBP" below)
if((SIZE_T)currentEBP > (SIZE_T)Thread::GetStackUpperBound())
{
break;
}
// If we have a too small address, we are probably bad
if((SIZE_T)currentEBP < (SIZE_T)0x10000)
break;
if((SIZE_T)currentEBP < (SIZE_T)lastEBP)
{
break;
}
// Skip the top N frames
if(skipTopNFrames) {
skipTopNFrames--;
continue;
}
// Save the Return Address for symbol decoding
Append(lastEBP->m_ReturnAddress);
}
}
#else
CONTEXT ctx;
ClrCaptureContext(&ctx);
UINT_PTR ControlPc = 0;
UINT_PTR CurrentSP = 0, PrevSP = 0;
while(1)
{
// Unwind to the caller
ControlPc = Thread::VirtualUnwindCallFrame(&ctx);
// This is to take care of recursion
CurrentSP = (UINT_PTR)GetSP(&ctx);
// when to break from this loop
if ( ControlPc == 0 || ( PrevSP == CurrentSP ) )
{
break;
}
// Skip the top N frames
if ( skipTopNFrames ) {
skipTopNFrames--;
continue;
}
// Add the stack frame to the list
Append(ControlPc);
PrevSP = CurrentSP;
}
#endif //TARGET_X86
} EX_CATCH { } EX_END_CATCH(SwallowAllExceptions);
pThread->MarkEtwStackWalkCompleted();
#endif //!DACCESS_COMPILE
return ETW::SamplingLog::Completed;
}
#endif // !defined(HOST_UNIX)
#endif // !FEATURE_NATIVEAOT
/****************************************************************************/
/* Methods that are called from the runtime */
/****************************************************************************/
/****************************************************************************/
/* Methods for rundown events */
/****************************************************************************/
/***************************************************************************/
/* This function should be called from the event tracing callback routine
when the private CLR provider is enabled */
/***************************************************************************/
#ifndef FEATURE_NATIVEAOT
VOID ETW::GCLog::GCSettingsEvent()
{
if (GCHeapUtilities::IsGCHeapInitialized())
{
if (ETW_TRACING_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context,
GCSettings))
{
ETW::GCLog::ETW_GC_INFO Info;
Info.GCSettings.ServerGC = GCHeapUtilities::IsServerHeap ();
Info.GCSettings.SegmentSize = GCHeapUtilities::GetGCHeap()->GetValidSegmentSize (false);
Info.GCSettings.LargeObjectSegmentSize = GCHeapUtilities::GetGCHeap()->GetValidSegmentSize (true);
FireEtwGCSettings_V1(Info.GCSettings.SegmentSize, Info.GCSettings.LargeObjectSegmentSize, Info.GCSettings.ServerGC, GetClrInstanceId());
}
GCHeapUtilities::GetGCHeap()->DiagTraceGCSegments();
}
};
#endif // !FEATURE_NATIVEAOT
//---------------------------------------------------------------------------------------
// Code for sending GC heap object events is generally the same for both FEATURE_NATIVEAOT
// and !FEATURE_NATIVEAOT builds
//---------------------------------------------------------------------------------------
bool s_forcedGCInProgress = false;
class ForcedGCHolder
{
public:
ForcedGCHolder() { LIMITED_METHOD_CONTRACT; s_forcedGCInProgress = true; }
~ForcedGCHolder() { LIMITED_METHOD_CONTRACT; s_forcedGCInProgress = false; }
};
BOOL ETW::GCLog::ShouldWalkStaticsAndCOMForEtw()
{
LIMITED_METHOD_CONTRACT;
return s_forcedGCInProgress &&
ETW_TRACING_CATEGORY_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context,
TRACE_LEVEL_INFORMATION,
CLR_GCHEAPDUMP_KEYWORD);
}
// Simple helpers called by the GC to decide whether it needs to do a walk of heap
// objects and / or roots.
BOOL ETW::GCLog::ShouldWalkHeapObjectsForEtw()
{
LIMITED_METHOD_CONTRACT;
return s_forcedGCInProgress &&
ETW_TRACING_CATEGORY_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context,
TRACE_LEVEL_INFORMATION,
CLR_GCHEAPDUMP_KEYWORD);
}
BOOL ETW::GCLog::ShouldWalkHeapRootsForEtw()
{
LIMITED_METHOD_CONTRACT;
return s_forcedGCInProgress &&
ETW_TRACING_CATEGORY_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context,
TRACE_LEVEL_INFORMATION,
CLR_GCHEAPDUMP_KEYWORD);
}
BOOL ETW::GCLog::ShouldTrackMovementForEtw()
{
LIMITED_METHOD_CONTRACT;
return ETW_TRACING_CATEGORY_ENABLED(
MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context,
TRACE_LEVEL_INFORMATION,
CLR_GCHEAPSURVIVALANDMOVEMENT_KEYWORD);
}
// Batches the list of moved/surviving references for the GCBulkMovedObjectRanges /
// GCBulkSurvivingObjectRanges events
struct EtwGcMovementContext
{
public:
// An instance of EtwGcMovementContext is dynamically allocated and stored
// inside of MovedReferenceContextForEtwAndProfapi, which in turn is dynamically
// allocated and pointed to by a profiling_context pointer created by the GC on the stack.
// This is used to batch and send GCBulkSurvivingObjectRanges events and
// GCBulkMovedObjectRanges events. This method is passed a pointer to
// MovedReferenceContextForEtwAndProfapi::pctxEtw; if non-NULL it gets returned;
// else, a new EtwGcMovementContext is allocated, stored in that pointer, and
// then returned. Callers should test for NULL, which can be returned if out of
// memory
static EtwGcMovementContext * GetOrCreateInGCContext(EtwGcMovementContext ** ppContext)
{
LIMITED_METHOD_CONTRACT;
_ASSERTE(ppContext != NULL);
EtwGcMovementContext * pContext = *ppContext;
if (pContext == NULL)
{
pContext = new (nothrow) EtwGcMovementContext;
*ppContext = pContext;
}
return pContext;
}
EtwGcMovementContext() :
iCurBulkSurvivingObjectRanges(0),
iCurBulkMovedObjectRanges(0)
{
LIMITED_METHOD_CONTRACT;
Clear();
}
// Resets structure for reuse on construction, and after each flush.
// (Intentionally leave iCurBulk* as is, since they persist across flushes within a GC.)
void Clear()
{
LIMITED_METHOD_CONTRACT;
cBulkSurvivingObjectRanges = 0;
cBulkMovedObjectRanges = 0;
ZeroMemory(rgGCBulkSurvivingObjectRanges, sizeof(rgGCBulkSurvivingObjectRanges));
ZeroMemory(rgGCBulkMovedObjectRanges, sizeof(rgGCBulkMovedObjectRanges));
}
//---------------------------------------------------------------------------------------
// GCBulkSurvivingObjectRanges
//---------------------------------------------------------------------------------------
// Sequence number for each GCBulkSurvivingObjectRanges event
UINT iCurBulkSurvivingObjectRanges;
// Number of surviving object ranges currently filled out in rgGCBulkSurvivingObjectRanges array
UINT cBulkSurvivingObjectRanges;
// Struct array containing the primary data for each GCBulkSurvivingObjectRanges
// event. Fix the size so the total event stays well below the 64K limit (leaving
// lots of room for non-struct fields that come before the values data)
EventStructGCBulkSurvivingObjectRangesValue rgGCBulkSurvivingObjectRanges[
(cbMaxEtwEvent - 0x100) / sizeof(EventStructGCBulkSurvivingObjectRangesValue)];
//---------------------------------------------------------------------------------------
// GCBulkMovedObjectRanges
//---------------------------------------------------------------------------------------
// Sequence number for each GCBulkMovedObjectRanges event
UINT iCurBulkMovedObjectRanges;
// Number of Moved object ranges currently filled out in rgGCBulkMovedObjectRanges array
UINT cBulkMovedObjectRanges;
// Struct array containing the primary data for each GCBulkMovedObjectRanges
// event. Fix the size so the total event stays well below the 64K limit (leaving
// lots of room for non-struct fields that come before the values data)
EventStructGCBulkMovedObjectRangesValue rgGCBulkMovedObjectRanges[
(cbMaxEtwEvent - 0x100) / sizeof(EventStructGCBulkMovedObjectRangesValue)];
};
// Contains above struct for ETW, plus extra info (opaque to us) used by the profiling
// API to track its own information.
struct MovedReferenceContextForEtwAndProfapi
{
// An instance of MovedReferenceContextForEtwAndProfapi is dynamically allocated and
// pointed to by a profiling_context pointer created by the GC on the stack. This is used to
// batch and send GCBulkSurvivingObjectRanges events and GCBulkMovedObjectRanges
// events and the corresponding callbacks for profapi profilers. This method is
// passed a pointer to a MovedReferenceContextForEtwAndProfapi; if non-NULL it gets
// returned; else, a new MovedReferenceContextForEtwAndProfapi is allocated, stored
// in that pointer, and then returned. Callers should test for NULL, which can be
// returned if out of memory
static MovedReferenceContextForEtwAndProfapi * CreateInGCContext(LPVOID pvContext)
{
LIMITED_METHOD_CONTRACT;
_ASSERTE(pvContext != NULL);
MovedReferenceContextForEtwAndProfapi * pContext = *(MovedReferenceContextForEtwAndProfapi **) pvContext;
// Shouldn't be called if the context was already created. Perhaps someone made
// one too many BeginMovedReferences calls, or didn't have an EndMovedReferences
// in between?
_ASSERTE(pContext == NULL);
pContext = new (nothrow) MovedReferenceContextForEtwAndProfapi;
*(MovedReferenceContextForEtwAndProfapi **) pvContext = pContext;
return pContext;
}
MovedReferenceContextForEtwAndProfapi() :
pctxProfAPI(NULL),
pctxEtw(NULL)
{
LIMITED_METHOD_CONTRACT;
}
LPVOID pctxProfAPI;
EtwGcMovementContext * pctxEtw;
};
//---------------------------------------------------------------------------------------
//
// Called by the GC for each moved or surviving reference that it encounters. This
// batches the info into our context's buffer, and flushes that buffer to ETW as it fills
// up.
//
// Arguments:
// * pbMemBlockStart - Start of moved/surviving block
// * pbMemBlockEnd - Next pointer after end of moved/surviving block
// * cbRelocDistance - How far did the block move? (0 for non-compacted / surviving
// references; negative if moved to earlier addresses)
// * profilingContext - Where our context is stored
// * fCompacting - Is this a compacting GC? Used to decide whether to send the moved
// or surviving event
//
// static
void ETW::GCLog::MovedReference(
BYTE * pbMemBlockStart,
BYTE * pbMemBlockEnd,
ptrdiff_t cbRelocDistance,
size_t profilingContext,
BOOL fCompacting,
BOOL fAllowProfApiNotification /* = TRUE */)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
CAN_TAKE_LOCK; // EEToProfInterfaceImpl::AllocateMovedReferencesData takes lock
}
CONTRACTL_END;
MovedReferenceContextForEtwAndProfapi * pCtxForEtwAndProfapi =
(MovedReferenceContextForEtwAndProfapi *) profilingContext;
if (pCtxForEtwAndProfapi == NULL)
{
_ASSERTE(!"MovedReference() encountered a NULL profilingContext");
return;
}
#ifdef PROFILING_SUPPORTED
// ProfAPI
if (fAllowProfApiNotification)
{
BEGIN_PROFILER_CALLBACK(CORProfilerTrackGC() || CORProfilerTrackGCMovedObjects());
(&g_profControlBlock)->MovedReference(pbMemBlockStart,
pbMemBlockEnd,
cbRelocDistance,
&(pCtxForEtwAndProfapi->pctxProfAPI),
fCompacting);
END_PROFILER_CALLBACK();
}
#endif // PROFILING_SUPPORTED
// ETW
if (!ShouldTrackMovementForEtw())
return;
EtwGcMovementContext * pContext =
EtwGcMovementContext::GetOrCreateInGCContext(&pCtxForEtwAndProfapi->pctxEtw);
if (pContext == NULL)
return;
if (fCompacting)
{
// Moved references
_ASSERTE(pContext->cBulkMovedObjectRanges < ARRAY_SIZE(pContext->rgGCBulkMovedObjectRanges));
EventStructGCBulkMovedObjectRangesValue * pValue =
&pContext->rgGCBulkMovedObjectRanges[pContext->cBulkMovedObjectRanges];
pValue->OldRangeBase = pbMemBlockStart;
pValue->NewRangeBase = pbMemBlockStart + cbRelocDistance;
pValue->RangeLength = pbMemBlockEnd - pbMemBlockStart;
pContext->cBulkMovedObjectRanges++;
// If buffer is now full, empty it into ETW
if (pContext->cBulkMovedObjectRanges == ARRAY_SIZE(pContext->rgGCBulkMovedObjectRanges))
{
FireEtwGCBulkMovedObjectRanges(
pContext->iCurBulkMovedObjectRanges,
pContext->cBulkMovedObjectRanges,
GetClrInstanceId(),
sizeof(pContext->rgGCBulkMovedObjectRanges[0]),
&pContext->rgGCBulkMovedObjectRanges[0]);
pContext->iCurBulkMovedObjectRanges++;
pContext->Clear();
}
}
else
{
// Surviving references
_ASSERTE(pContext->cBulkSurvivingObjectRanges < ARRAY_SIZE(pContext->rgGCBulkSurvivingObjectRanges));
EventStructGCBulkSurvivingObjectRangesValue * pValue =
&pContext->rgGCBulkSurvivingObjectRanges[pContext->cBulkSurvivingObjectRanges];
pValue->RangeBase = pbMemBlockStart;
pValue->RangeLength = pbMemBlockEnd - pbMemBlockStart;
pContext->cBulkSurvivingObjectRanges++;
// If buffer is now full, empty it into ETW
if (pContext->cBulkSurvivingObjectRanges == ARRAY_SIZE(pContext->rgGCBulkSurvivingObjectRanges))
{
FireEtwGCBulkSurvivingObjectRanges(
pContext->iCurBulkSurvivingObjectRanges,
pContext->cBulkSurvivingObjectRanges,
GetClrInstanceId(),
sizeof(pContext->rgGCBulkSurvivingObjectRanges[0]),
&pContext->rgGCBulkSurvivingObjectRanges[0]);
pContext->iCurBulkSurvivingObjectRanges++;
pContext->Clear();
}
}
}
//---------------------------------------------------------------------------------------
//
// Called by the GC just before it begins enumerating plugs. Gives us a chance to
// allocate our context structure, to allow us to batch plugs before firing events
// for them
//
// Arguments:
// * pProfilingContext - Points to location on stack (in GC function) where we can
// store a pointer to the context we allocate
//
// static
VOID ETW::GCLog::BeginMovedReferences(size_t * pProfilingContext)
{
LIMITED_METHOD_CONTRACT;
MovedReferenceContextForEtwAndProfapi::CreateInGCContext(LPVOID(pProfilingContext));
}
//---------------------------------------------------------------------------------------
//
// Called by the GC at the end of a heap walk to give us a place to flush any remaining
// buffers of data to ETW or the profapi profiler
//
// Arguments:
// profilingContext - Our context we built up during the heap walk
//
// static
VOID ETW::GCLog::EndMovedReferences(size_t profilingContext, BOOL fAllowProfApiNotification /* = TRUE */)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
CAN_TAKE_LOCK;
}
CONTRACTL_END;
MovedReferenceContextForEtwAndProfapi * pCtxForEtwAndProfapi = (MovedReferenceContextForEtwAndProfapi *) profilingContext;
if (pCtxForEtwAndProfapi == NULL)
{
_ASSERTE(!"EndMovedReferences() encountered a NULL profilingContext");
return;
}
#ifdef PROFILING_SUPPORTED
// ProfAPI
if (fAllowProfApiNotification)
{
BEGIN_PROFILER_CALLBACK(CORProfilerTrackGC() || CORProfilerTrackGCMovedObjects());
(&g_profControlBlock)->EndMovedReferences(&(pCtxForEtwAndProfapi->pctxProfAPI));
END_PROFILER_CALLBACK();
}
#endif //PROFILING_SUPPORTED
// ETW
if (!ShouldTrackMovementForEtw())
return;
// If context isn't already set up for us, then we haven't been collecting any data
// for ETW events.
EtwGcMovementContext * pContext = pCtxForEtwAndProfapi->pctxEtw;
if (pContext == NULL)
return;
// Flush any remaining moved or surviving range data
if (pContext->cBulkMovedObjectRanges > 0)
{
FireEtwGCBulkMovedObjectRanges(
pContext->iCurBulkMovedObjectRanges,
pContext->cBulkMovedObjectRanges,
GetClrInstanceId(),
sizeof(pContext->rgGCBulkMovedObjectRanges[0]),
&pContext->rgGCBulkMovedObjectRanges[0]);
}
if (pContext->cBulkSurvivingObjectRanges > 0)
{
FireEtwGCBulkSurvivingObjectRanges(
pContext->iCurBulkSurvivingObjectRanges,
pContext->cBulkSurvivingObjectRanges,
GetClrInstanceId(),
sizeof(pContext->rgGCBulkSurvivingObjectRanges[0]),
&pContext->rgGCBulkSurvivingObjectRanges[0]);
}
pCtxForEtwAndProfapi->pctxEtw = NULL;
delete pContext;
}
/***************************************************************************/
/* This implements the public runtime provider's GCHeapCollectKeyword. It
performs a full, gen-2, blocking GC. */
/***************************************************************************/
VOID ETW::GCLog::ForceGC(LONGLONG l64ClientSequenceNumber)
{
CONTRACTL
{
NOTHROW;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
#ifndef FEATURE_NATIVEAOT
if (!IsGarbageCollectorFullyInitialized())
return;
#endif // FEATURE_NATIVEAOT
InterlockedExchange64(&s_l64LastClientSequenceNumber, l64ClientSequenceNumber);
ForceGCForDiagnostics();
}
//---------------------------------------------------------------------------------------
//
// Helper to fire the GCStart event. Figures out which version of GCStart to fire, and
// includes the client sequence number, if available.
//
// Arguments:
// pGcInfo - ETW_GC_INFO containing details from GC about this collection
//
// static
VOID ETW::GCLog::FireGcStart(ETW_GC_INFO * pGcInfo)
{
LIMITED_METHOD_CONTRACT;
if (ETW_TRACING_CATEGORY_ENABLED(
MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context,
TRACE_LEVEL_INFORMATION,
CLR_GC_KEYWORD))
{
// If the controller specified a client sequence number for us to log with this
// GCStart, then retrieve it
LONGLONG l64ClientSequenceNumberToLog = 0;
if ((s_l64LastClientSequenceNumber != 0) &&
(pGcInfo->GCStart.Depth == GCHeapUtilities::GetGCHeap()->GetMaxGeneration()) &&
(pGcInfo->GCStart.Reason == ETW_GC_INFO::GC_INDUCED))
{
l64ClientSequenceNumberToLog = InterlockedExchange64(&s_l64LastClientSequenceNumber, 0);
}
FireEtwGCStart_V2(pGcInfo->GCStart.Count, pGcInfo->GCStart.Depth, pGcInfo->GCStart.Reason, pGcInfo->GCStart.Type, GetClrInstanceId(), l64ClientSequenceNumberToLog);
}
}
//---------------------------------------------------------------------------------------
//
// Contains code common to profapi and ETW scenarios where the profiler wants to force
// the CLR to perform a GC. The important work here is to create a managed thread for
// the current thread BEFORE the GC begins. On both ETW and profapi threads, there may
// not yet be a managed thread object. But some scenarios require a managed thread
// object be present..
//
// Return Value:
// HRESULT indicating success or failure
//
// Assumptions:
// Caller should ensure that the EE has fully started up and that the GC heap is
// initialized enough to actually perform a GC
//
// static
HRESULT ETW::GCLog::ForceGCForDiagnostics()
{
CONTRACTL
{
NOTHROW;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
HRESULT hr = E_FAIL;
#ifndef FEATURE_NATIVEAOT
// Caller should ensure we're past startup.
_ASSERTE(IsGarbageCollectorFullyInitialized());
// In immersive apps the GarbageCollect() call below will call into the WinUI reference tracker,
// which will call back into the runtime to track references. This call
// chain would cause a Thread object to be created for this thread while code
// higher on the stack owns the ThreadStoreLock. This will lead to asserts
// since the ThreadStoreLock is non-reentrant. To avoid this we'll create
// the Thread object here instead.
if (GetThreadNULLOk() == NULL)
{
HRESULT hr = E_FAIL;
SetupThreadNoThrow(&hr);
if (FAILED(hr))
return hr;
}
ASSERT_NO_EE_LOCKS_HELD();
EX_TRY
{
// Need to switch to cooperative mode as the thread will access managed
// references (through reference tracker callbacks).
GCX_COOP();
#endif // FEATURE_NATIVEAOT
ForcedGCHolder forcedGCHolder;
hr = GCHeapUtilities::GetGCHeap()->GarbageCollect(
-1, // all generations should be collected
false, // low_memory_p
collection_blocking);
#ifndef FEATURE_NATIVEAOT
}
EX_CATCH { }
EX_END_CATCH(RethrowTerminalExceptions);
#endif // FEATURE_NATIVEAOT
return hr;
}
//---------------------------------------------------------------------------------------
// WalkStaticsAndCOMForETW walks both CCW/RCW objects and static variables.
//---------------------------------------------------------------------------------------
VOID ETW::GCLog::WalkStaticsAndCOMForETW()
{
CONTRACTL
{
NOTHROW;
GC_TRIGGERS;
}
CONTRACTL_END;