-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
corprof.idl
4429 lines (3950 loc) · 174 KB
/
corprof.idl
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.
/**************************************************************************************
** **
** Corprof.idl - CLR Profiling interfaces. **
** **
**************************************************************************************/
/* -------------------------------------------------------------------------- *
* Imported types
* -------------------------------------------------------------------------- */
#if !DEFINITIONS_FROM_NON_IMPORTABLE_PLACES
cpp_quote("#if 0")
import "unknwn.idl";
typedef LONG32 mdToken;
typedef mdToken mdModule;
typedef mdToken mdTypeDef;
typedef mdToken mdMethodDef;
typedef mdToken mdFieldDef;
typedef ULONG CorElementType;
// Forward declaration of enum in CorHdr.h
enum CorElementType;
// Forward declaration of structs in Cor.h
typedef struct
{
DWORD dwOSPlatformId; // Operating system platform.
DWORD dwOSMajorVersion; // OS Major version.
DWORD dwOSMinorVersion; // OS Minor version.
} OSINFO;
typedef struct
{
USHORT usMajorVersion; // Major Version.
USHORT usMinorVersion; // Minor Version.
USHORT usBuildNumber; // Build Number.
USHORT usRevisionNumber; // Revision Number.
LPWSTR szLocale; // Locale.
ULONG cbLocale; // [IN/OUT] Size of the buffer in wide chars/Actual size.
DWORD *rProcessor; // Processor ID array.
ULONG ulProcessor; // [IN/OUT] Size of the Processor ID array/Actual # of entries filled in.
OSINFO *rOS; // OSINFO array.
ULONG ulOS; // [IN/OUT]Size of the OSINFO array/Actual # of entries filled in.
} ASSEMBLYMETADATA;
cpp_quote("#endif")
typedef const BYTE *LPCBYTE;
typedef BYTE *LPBYTE;
typedef BYTE COR_SIGNATURE;
typedef COR_SIGNATURE* PCOR_SIGNATURE;
typedef const COR_SIGNATURE* PCCOR_SIGNATURE;
#endif
cpp_quote("#ifndef _COR_IL_MAP")
cpp_quote("#define _COR_IL_MAP")
#ifdef INTERNAL_DOCS
// Note that this structure is also defined in CorDebug.idl - PROPAGATE CHANGES
// BOTH WAYS, or this'll become a really insidious bug some day.
#endif
typedef struct _COR_IL_MAP
{
ULONG32 oldOffset; // Old IL offset relative to beginning of function
ULONG32 newOffset; // New IL offset relative to beginning of function
BOOL fAccurate; //put here for compatibility with the Debugger structure.
} COR_IL_MAP;
cpp_quote("#endif //_COR_IL_MAP")
cpp_quote("#ifndef _COR_DEBUG_IL_TO_NATIVE_MAP_")
cpp_quote("#define _COR_DEBUG_IL_TO_NATIVE_MAP_")
/* ICorProfilerInfo:: GetILToNativeMapping returns an array of
* COR_DEBUG_IL_TO_NATIVE_MAP structures. In order to convey that certain
* ranges of native instructions correspond to special regions of code (for
* example, the prolog), an entry in the array may have it's ilOffset field set
* to one of these values.
*/
typedef enum CorDebugIlToNativeMappingTypes
{
NO_MAPPING = -1,
PROLOG = -2,
EPILOG = -3
} CorDebugIlToNativeMappingTypes;
typedef struct COR_DEBUG_IL_TO_NATIVE_MAP
{
ULONG32 ilOffset;
ULONG32 nativeStartOffset;
ULONG32 nativeEndOffset;
} COR_DEBUG_IL_TO_NATIVE_MAP;
cpp_quote("#endif // _COR_DEBUG_IL_TO_NATIVE_MAP_")
cpp_quote("#ifndef _COR_FIELD_OFFSET_")
cpp_quote("#define _COR_FIELD_OFFSET_")
typedef struct _COR_FIELD_OFFSET
{
mdFieldDef ridOfField; // fieldDef token of the field
ULONG ulOffset; // offset (from the ObjectID pointer) of the field
} COR_FIELD_OFFSET;
cpp_quote("#endif // _COR_FIELD_OFFSET_")
#ifndef DO_NO_IMPORTS
import "wtypes.idl";
import "unknwn.idl";
#endif
#define STDMETHODCALLTYPE
typedef UINT_PTR ProcessID;
typedef UINT_PTR AssemblyID;
typedef UINT_PTR AppDomainID;
typedef UINT_PTR ModuleID;
typedef UINT_PTR ClassID;
typedef UINT_PTR ThreadID;
typedef UINT_PTR ContextID;
typedef UINT_PTR FunctionID;
typedef UINT_PTR ObjectID;
typedef UINT_PTR GCHandleID;
typedef UINT_PTR COR_PRF_ELT_INFO;
typedef UINT_PTR ReJITID;
typedef union {FunctionID functionID; UINT_PTR clientID;} FunctionIDOrClientID;
/*
* The FunctionIDMapper type definition is used by the
* ICorProfilerInfo::SetFunctionIDMapper method to specify
* a function that will be called to map FunctionIDs to alternative
* values that will be passed to the function entry and function exit
* callbacks supplied to the ICorProfilerInfo::SetEnterLeaveFunctionHooks
* method. The mapper can be set only once and it is recommended to do so
* in the Initialize callback.
*
* NOTE: There is a known bug in this API that must be worked around.
* The return value of FunctionIDMapper cannot be NULL (unless the boolean
* value in pbHookTheFunction is FALSE). All other values are treated as
* opaque data to be passed to the entry/exit callback functions. The use
* of a NULL return value will produce unpredictable results, including
* possibly halting the process.
*
* NOTE: Profilers should be tolerant of cases where multiple threads of
* a profiled app are calling the same method simultaneously. In such
* cases, the profiler may receive multiple FunctionIDMapper callbacks
* for the same functionId. The profiler should be certain to return
* the same values from this callback when it is called multiple times
* with the same functionId.
*
*/
typedef UINT_PTR __stdcall FunctionIDMapper(
FunctionID funcId,
BOOL *pbHookFunction);
typedef UINT_PTR __stdcall FunctionIDMapper2(
FunctionID funcId,
void *clientData,
BOOL *pbHookFunction);
/*
* Enum for specifying how much data to pass back with a stack snapshot
*/
typedef enum _COR_PRF_SNAPSHOT_INFO
{
COR_PRF_SNAPSHOT_DEFAULT = 0x0,
// Return a register context for each frame
COR_PRF_SNAPSHOT_REGISTER_CONTEXT = 0x1,
// Use a quicker stack walk algorithm based on the EBP frame chain. This is available
// on x86 only.
COR_PRF_SNAPSHOT_X86_OPTIMIZED = 0x2,
} COR_PRF_SNAPSHOT_INFO;
/*
* Opaque handle that represents information about a given stack frame. It is only
* valid during the callback to which it is passed.
*/
typedef UINT_PTR COR_PRF_FRAME_INFO;
/*
* Describes a range of function arguments stored contiguously in left-to-right
* order in memory.
*/
typedef struct _COR_PRF_FUNCTION_ARGUMENT_RANGE
{
UINT_PTR startAddress; // start address of the range
ULONG length; // contiguous length of the range
} COR_PRF_FUNCTION_ARGUMENT_RANGE;
/*
* Describes the locations in memory of a function's arguments, in
* left-to-right order. Note that arguments stored in registers are
* spilled to memory to build these structures.
*/
typedef struct _COR_PRF_FUNCTION_ARGUMENT_INFO
{
ULONG numRanges; // number of chunks of arguments
ULONG totalArgumentSize; // total size of arguments
COR_PRF_FUNCTION_ARGUMENT_RANGE ranges[1]; // chunks
} COR_PRF_FUNCTION_ARGUMENT_INFO;
/*
* Represents one contiguous chunk of native code
*/
typedef struct _COR_PRF_CODE_INFO
{
UINT_PTR startAddress;
SIZE_T size;
} COR_PRF_CODE_INFO;
/*
* Enum for describing the type of static a field is. These may be bit-wise
* or'ed with each other if the field is multiple types.
*/
typedef enum
{
COR_PRF_FIELD_NOT_A_STATIC = 0x0,
COR_PRF_FIELD_APP_DOMAIN_STATIC = 0x1,
COR_PRF_FIELD_THREAD_STATIC = 0x2,
COR_PRF_FIELD_CONTEXT_STATIC = 0x4,
COR_PRF_FIELD_RVA_STATIC = 0x8
} COR_PRF_STATIC_TYPE;
/*
* Represents a function uniquely by combining the FunctionID
* with a ReJITID.
*/
typedef struct _COR_PRF_FUNCTION
{
FunctionID functionId;
ReJITID reJitId;
} COR_PRF_FUNCTION;
/*
* Structure populated by profiler when declaring additional assembly references
* that the CLR should consider when performing an assembly reference closure
* walk. See ICorProfilerCallback6::GetAssemblyReferences and
* ICorProfilerAssemblyReferenceProvider::AddAssemblyReference
*/
typedef struct _COR_PRF_ASSEMBLY_REFERENCE_INFO
{
void *pbPublicKeyOrToken; // Public key or token of the assembly.
ULONG cbPublicKeyOrToken; // Count of bytes in the public key or token.
LPCWSTR szName; // Name of the assembly being referenced.
ASSEMBLYMETADATA * pMetaData; // Assembly MetaData, as defined in cor.h
void *pbHashValue; // Hash Blob.
ULONG cbHashValue; // Count of bytes in the Hash Blob.
DWORD dwAssemblyRefFlags; // Flags.
} COR_PRF_ASSEMBLY_REFERENCE_INFO;
/*
* Represents a IL methods uniquely by combining the module ID and method token.
*/
typedef struct _COR_PRF_METHOD
{
ModuleID moduleId;
mdMethodDef methodId;
} COR_PRF_METHOD;
/*
* NOTE!!!
*
* The following applies to ALL FunctionEnter[2,3], FunctionLeave[2,3],
* FunctionTailcall[2,3] hooks below:
*
* It is VERY IMPORTANT to note that these function implementations must be
* __declspec(naked), since the EE is not saving any registers before calling
* any of them. YOU MUST SAVE ALL REGISTERS YOU USE, INCLUDING FPU REGISTERS
* IF THE FPU STACK IS NOT EMPTY AND YOU INTEND TO USE IT.
*
* NOTE: The profiler should not block here, since the stack may not be in a
* GC-friendly state and so preemptive GC cannot be enabled. If the
* profiler blocks here and a GC is attempted, the runtime will block
* until this callback returns. Also, the profiler may NOT call into
* managed code or in any way cause a managed memory allocation.
*/
/*
* NOTE: DEPRECATED IN V2
*
* These functions are considered deprecated in V2 and higher. They will
* continue to work, but incur a performance penalty for usage. For equivalent
* functionality, use the FunctionEnter3/Leave3/Tailcall3 callbacks with
* bits cleared for COR_PRF_ENABLE_FRAME_INFO, COR_PRF_ENABLE_FUNCTION_RETVAL
* and COR_PRF_ENABLE_FUNCTION_ARGS.
*/
typedef void STDMETHODCALLTYPE FunctionEnter(
FunctionID funcID);
typedef void STDMETHODCALLTYPE FunctionLeave(
FunctionID funcID);
typedef void STDMETHODCALLTYPE FunctionTailcall(
FunctionID funcID);
/*
* NOTE: DEPRECATED IN V4
*
* These functions are considered deprecated in V4 and higher. They will
* continue to work, but incur a performance penalty for usage. For equivalent
* functionality, use the FunctionEnter3/Leave3/Tailcall3 callbacks.
*/
typedef void STDMETHODCALLTYPE FunctionEnter2(
FunctionID funcId,
UINT_PTR clientData,
COR_PRF_FRAME_INFO func,
COR_PRF_FUNCTION_ARGUMENT_INFO *argumentInfo);
typedef void STDMETHODCALLTYPE FunctionLeave2(
FunctionID funcId,
UINT_PTR clientData,
COR_PRF_FRAME_INFO func,
COR_PRF_FUNCTION_ARGUMENT_RANGE *retvalRange);
typedef void STDMETHODCALLTYPE FunctionTailcall2(
FunctionID funcId,
UINT_PTR clientData,
COR_PRF_FRAME_INFO func);
/*
* When you are not interested in inspecting arguments or return values, then
* use these to be notified as functions are called and return. Use
* SetEnterLeaveFunctionHooks3 to register your implementations of these
* functions.
*
* functionIDOrClientID: if the profiler returned a remapped value from
* FunctionIDMapper[2], then this is that remapped value; else it is the
* true FunctionID of the function.
*/
typedef void STDMETHODCALLTYPE FunctionEnter3(
FunctionIDOrClientID functionIDOrClientID);
typedef void STDMETHODCALLTYPE FunctionLeave3(
FunctionIDOrClientID functionIDOrClientID);
typedef void STDMETHODCALLTYPE FunctionTailcall3(
FunctionIDOrClientID functionIDOrClientID);
/*
* When you are interested in inspecting arguments and return values, then
* use these to be notified as functions are called and return. Use
* SetEnterLeaveFunctionHooks3WithInfo to register your implementations of these
* functions.
*
* functionIDOrClientID: if the profiler returned a remapped value from
* FunctionIDMapper[2], then this is that remapped value; else it is the
* true FunctionID of the function.
*
* eltInfo is an opaque handle that represents information about a given stack frame.
* It is only valid during the callback to which it is passed.
*/
typedef void STDMETHODCALLTYPE FunctionEnter3WithInfo(
FunctionIDOrClientID functionIDOrClientID,
COR_PRF_ELT_INFO eltInfo);
typedef void STDMETHODCALLTYPE FunctionLeave3WithInfo(
FunctionIDOrClientID functionIDOrClientID,
COR_PRF_ELT_INFO eltInfo);
typedef void STDMETHODCALLTYPE FunctionTailcall3WithInfo(
FunctionIDOrClientID functionIDOrClientID,
COR_PRF_ELT_INFO eltInfo);
/*
* Stack snapshot callback definition.
*
* This callback is called once per managed frame or run of unmanaged frames.
*
* funcID is the FunctionID of the managed function. If funcID == 0, the callback is
* for a run of unmanaged frames. The profiler may either ignore the frame, or use
* the register context to perform its own unmanaged stackwalk.
*
* ip is the native IP in the frame
*
* frameInfo is the COR_PRF_FRAME_INFO for this frame. It is only valid for
* use during this callback.
*
* context is a Win32 CONTEXT struct for the current platform (size given in
* contextSize). It will only be valid if the COR_PRF_SNAPSHOT_CONTEXT flag
* was passed to DoStackSnapshot.
*
* clientData is a void* passed straight through from DoStackSnapshot
*
* NOTE: One must limit the complexity of work done in StackSnapshotCallback.
* For example, particularly when using DoStackSnapshot in an asynchronous manner,
* the target thread may be holding locks. Executing code within StackSnapshotCallback
* that requires the same locks could lead to deadlock.
*/
typedef HRESULT __stdcall StackSnapshotCallback(
FunctionID funcId,
UINT_PTR ip,
COR_PRF_FRAME_INFO frameInfo,
ULONG32 contextSize,
BYTE context[],
void *clientData);
/* Callback for each object reference */
typedef BOOL STDMETHODCALLTYPE ObjectReferenceCallback(ObjectID root, ObjectID* reference, void *clientData);
typedef enum
{
// These flags represent classes of callback events
COR_PRF_MONITOR_NONE = 0x00000000,
// MONITOR_FUNCTION_UNLOADS controls the
// FunctionUnloadStarted callback.
COR_PRF_MONITOR_FUNCTION_UNLOADS = 0x00000001,
// MONITOR_CLASS_LOADS controls the ClassLoad*
// and ClassUnload* callbacks.
// See the comments on those callbacks for important
// behavior changes in V2.
COR_PRF_MONITOR_CLASS_LOADS = 0x00000002,
// MONITOR_MODULE_LOADS controls the
// ModuleLoad*, ModuleUnload*, and ModuleAttachedToAssembly
// callbacks.
COR_PRF_MONITOR_MODULE_LOADS = 0x00000004,
// MONITOR_ASSEMBLY_LOADS controls the
// AssemblyLoad* and AssemblyUnload* callbacks
COR_PRF_MONITOR_ASSEMBLY_LOADS = 0x00000008,
// MONITOR_APPDOMAIN_LOADS controls the
// AppDomainCreation* and AppDomainShutdown* callbacks
COR_PRF_MONITOR_APPDOMAIN_LOADS = 0x00000010,
// MONITOR_JIT_COMPILATION controls the
// JITCompilation*, JITFunctionPitched, and JITInlining
// callbacks.
COR_PRF_MONITOR_JIT_COMPILATION = 0x00000020,
// MONITOR_EXCEPTIONS controls the ExceptionThrown,
// ExceptionSearch*, ExceptionOSHandler*, ExceptionUnwind*,
// and ExceptionCatcher* callbacks.
COR_PRF_MONITOR_EXCEPTIONS = 0x00000040,
// MONITOR_GC controls the GarbageCollectionStarted/Finished,
// MovedReferences, SurvivingReferences,
// ObjectReferences, ObjectsAllocatedByClass,
// RootReferences*, HandleCreated/Destroyed, and FinalizeableObjectQueued
// callbacks.
COR_PRF_MONITOR_GC = 0x00000080,
// MONITOR_OBJECT_ALLOCATED controls the
// ObjectAllocated callback.
COR_PRF_MONITOR_OBJECT_ALLOCATED = 0x00000100,
// MONITOR_THREADS controls the ThreadCreated,
// ThreadDestroyed, ThreadAssignedToOSThread,
// and ThreadNameChanged callbacks.
COR_PRF_MONITOR_THREADS = 0x00000200,
// CORECLR DEPRECATION WARNING: Remoting no longer exists in coreclr
// MONITOR_REMOTING controls the Remoting*
// callbacks.
COR_PRF_MONITOR_REMOTING = 0x00000400,
// MONITOR_CODE_TRANSITIONS controls the
// UnmanagedToManagedTransition and
// ManagedToUnmanagedTransition callbacks.
COR_PRF_MONITOR_CODE_TRANSITIONS = 0x00000800,
// MONITOR_ENTERLEAVE controls the
// FunctionEnter*/Leave*/Tailcall* callbacks
COR_PRF_MONITOR_ENTERLEAVE = 0x00001000,
// MONITOR_CCW controls the COMClassicVTable*
// callbacks.
COR_PRF_MONITOR_CCW = 0x00002000,
// CORECLR DEPRECATION WARNING: Remoting no longer exists in coreclr
// MONITOR_REMOTING_COOKIE controls whether
// a cookie will be passed to the Remoting* callbacks
COR_PRF_MONITOR_REMOTING_COOKIE = 0x00004000 | COR_PRF_MONITOR_REMOTING,
// CORECLR DEPRECATION WARNING: Remoting no longer exists in coreclr
// MONITOR_REMOTING_ASYNC controls whether
// the Remoting* callbacks will monitor async events
COR_PRF_MONITOR_REMOTING_ASYNC = 0x00008000 | COR_PRF_MONITOR_REMOTING,
// MONITOR_SUSPENDS controls the RuntimeSuspend*,
// RuntimeResume*, RuntimeThreadSuspended, and
// RuntimeThreadResumed callbacks.
COR_PRF_MONITOR_SUSPENDS = 0x00010000,
// MONITOR_CACHE_SEARCHES controls the
// JITCachedFunctionSearch* callbacks.
// See the comments on those callbacks for important
// behavior changes in V2.
COR_PRF_MONITOR_CACHE_SEARCHES = 0x00020000,
// NOTE: ReJIT is now supported again. The profiler must set this flag on
// startup in order to use RequestReJIT or RequestRevert. If the profiler specifies
// this flag, then the profiler must also specify COR_PRF_DISABLE_ALL_NGEN_IMAGES
COR_PRF_ENABLE_REJIT = 0x00040000,
// V2 MIGRATION WARNING: DEPRECATED
// Inproc debugging is no longer supported. ENABLE_INPROC_DEBUGGING
// has no effect.
COR_PRF_ENABLE_INPROC_DEBUGGING = 0x00080000,
// V2 MIGRATION NOTE: DEPRECATED
// The runtime now always tracks IL-native maps; this flag is thus always
// considered to be set.
COR_PRF_ENABLE_JIT_MAPS = 0x00100000,
// DISABLE_INLINING tells the runtime to disable all inlining
COR_PRF_DISABLE_INLINING = 0x00200000,
// DISABLE_OPTIMIZATIONS tells the runtime to disable all code optimizations
COR_PRF_DISABLE_OPTIMIZATIONS = 0x00400000,
// ENABLE_OBJECT_ALLOCATED tells the runtime that the profiler may want
// object allocation notifications. This must be set during initialization if the profiler
// ever wants object notifications (using COR_PRF_MONITOR_OBJECT_ALLOCATED)
COR_PRF_ENABLE_OBJECT_ALLOCATED = 0x00800000,
// MONITOR_CLR_EXCEPTIONS controls the ExceptionCLRCatcher*
// callbacks.
COR_PRF_MONITOR_CLR_EXCEPTIONS = 0x01000000,
// All callback events are enabled with this flag
COR_PRF_MONITOR_ALL = 0x0107FFFF,
// ENABLE_FUNCTION_ARGS enables argument tracing through FunctionEnter2.
COR_PRF_ENABLE_FUNCTION_ARGS = 0X02000000,
// ENABLE_FUNCTION_RETVAL enables retval tracing through FunctionLeave2.
COR_PRF_ENABLE_FUNCTION_RETVAL = 0X04000000,
// ENABLE_FRAME_INFO enables retrieval of exact ClassIDs for generic functions using
// GetFunctionInfo2 with a COR_PRF_FRAME_INFO obtained from FunctionEnter2.
COR_PRF_ENABLE_FRAME_INFO = 0X08000000,
// ENABLE_STACK_SNAPSHOT enables the used of DoStackSnapshot calls.
COR_PRF_ENABLE_STACK_SNAPSHOT = 0X10000000,
// USE_PROFILE_IMAGES causes the native image search to look for profiler-enhanced
// images. If no profiler-enhanced image is found for a given assembly the
// runtime will fallback to JIT for that assembly.
COR_PRF_USE_PROFILE_IMAGES = 0x20000000,
// COR_PRF_DISABLE_TRANSPARENCY_CHECKS_UNDER_FULL_TRUST will disable security
// transparency checks normally done during JIT compilation and class loading for
// full trust assemblies. This can make some instrumentation easier to perform.
COR_PRF_DISABLE_TRANSPARENCY_CHECKS_UNDER_FULL_TRUST
= 0x40000000,
// Prevents all NGEN images (including profiler-enhanced images) from loading. If
// this and COR_PRF_USE_PROFILE_IMAGES are both specified,
// COR_PRF_DISABLE_ALL_NGEN_IMAGES wins.
COR_PRF_DISABLE_ALL_NGEN_IMAGES = 0x80000000,
// The mask for valid mask bits
COR_PRF_ALL = 0x8FFFFFFF,
// COR_PRF_REQUIRE_PROFILE_IMAGE represents all flags that require profiler-enhanced
// images.
COR_PRF_REQUIRE_PROFILE_IMAGE = COR_PRF_USE_PROFILE_IMAGES |
COR_PRF_MONITOR_CODE_TRANSITIONS |
COR_PRF_MONITOR_ENTERLEAVE,
COR_PRF_ALLOWABLE_AFTER_ATTACH = COR_PRF_MONITOR_THREADS |
COR_PRF_MONITOR_MODULE_LOADS |
COR_PRF_MONITOR_ASSEMBLY_LOADS |
COR_PRF_MONITOR_APPDOMAIN_LOADS |
COR_PRF_ENABLE_STACK_SNAPSHOT |
COR_PRF_MONITOR_GC |
COR_PRF_MONITOR_SUSPENDS |
COR_PRF_MONITOR_CLASS_LOADS |
COR_PRF_MONITOR_EXCEPTIONS |
COR_PRF_MONITOR_JIT_COMPILATION |
COR_PRF_ENABLE_REJIT,
COR_PRF_ALLOWABLE_NOTIFICATION_PROFILER
= COR_PRF_MONITOR_FUNCTION_UNLOADS |
COR_PRF_MONITOR_CLASS_LOADS |
COR_PRF_MONITOR_MODULE_LOADS |
COR_PRF_MONITOR_ASSEMBLY_LOADS |
COR_PRF_MONITOR_APPDOMAIN_LOADS |
COR_PRF_MONITOR_JIT_COMPILATION |
COR_PRF_MONITOR_EXCEPTIONS |
COR_PRF_MONITOR_OBJECT_ALLOCATED |
COR_PRF_MONITOR_THREADS |
COR_PRF_MONITOR_CODE_TRANSITIONS |
COR_PRF_MONITOR_CCW |
COR_PRF_MONITOR_SUSPENDS |
COR_PRF_MONITOR_CACHE_SEARCHES |
COR_PRF_DISABLE_INLINING |
COR_PRF_DISABLE_OPTIMIZATIONS |
COR_PRF_ENABLE_OBJECT_ALLOCATED |
COR_PRF_MONITOR_CLR_EXCEPTIONS |
COR_PRF_ENABLE_STACK_SNAPSHOT |
COR_PRF_USE_PROFILE_IMAGES |
COR_PRF_DISABLE_ALL_NGEN_IMAGES,
// MONITOR_IMMUTABLE represents all flags that may only be set during initialization.
// Trying to change any of these flags elsewhere will result in a
// failed HRESULT.
COR_PRF_MONITOR_IMMUTABLE = COR_PRF_MONITOR_CODE_TRANSITIONS |
COR_PRF_MONITOR_REMOTING |
COR_PRF_MONITOR_REMOTING_COOKIE |
COR_PRF_MONITOR_REMOTING_ASYNC |
COR_PRF_ENABLE_INPROC_DEBUGGING |
COR_PRF_ENABLE_JIT_MAPS |
COR_PRF_DISABLE_OPTIMIZATIONS |
COR_PRF_DISABLE_INLINING |
COR_PRF_ENABLE_OBJECT_ALLOCATED |
COR_PRF_ENABLE_FUNCTION_ARGS |
COR_PRF_ENABLE_FUNCTION_RETVAL |
COR_PRF_ENABLE_FRAME_INFO |
COR_PRF_USE_PROFILE_IMAGES |
COR_PRF_DISABLE_TRANSPARENCY_CHECKS_UNDER_FULL_TRUST |
COR_PRF_DISABLE_ALL_NGEN_IMAGES
} COR_PRF_MONITOR;
/*
* Additional flags the profiler can specify via SetEventMask2 when loading
*/
typedef enum
{
COR_PRF_HIGH_MONITOR_NONE = 0x00000000,
// CORECLR DEPRECATION WARNING: This flag is no longer checked by the runtime
COR_PRF_HIGH_ADD_ASSEMBLY_REFERENCES = 0x00000001,
COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED = 0x00000002,
COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS = 0x00000004,
COR_PRF_HIGH_DISABLE_TIERED_COMPILATION = 0x00000008,
COR_PRF_HIGH_BASIC_GC = 0x00000010,
// Enables the MovedReferences/MovedReferences2 callback for compacting GCs only.
COR_PRF_HIGH_MONITOR_GC_MOVED_OBJECTS = 0x00000020,
COR_PRF_HIGH_REQUIRE_PROFILE_IMAGE = 0,
// Enables the large object allocation monitoring according to the LOH threshold.
COR_PRF_HIGH_MONITOR_LARGEOBJECT_ALLOCATED = 0x00000040,
COR_PRF_HIGH_MONITOR_EVENT_PIPE = 0x00000080,
// Enables the pinned object allocation monitoring.
COR_PRF_HIGH_MONITOR_PINNEDOBJECT_ALLOCATED = 0x00000100,
COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH = COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED |
COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS |
COR_PRF_HIGH_BASIC_GC |
COR_PRF_HIGH_MONITOR_GC_MOVED_OBJECTS |
COR_PRF_HIGH_MONITOR_LARGEOBJECT_ALLOCATED |
COR_PRF_HIGH_MONITOR_EVENT_PIPE,
COR_PRF_HIGH_ALLOWABLE_NOTIFICATION_PROFILER
= COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED |
COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS |
COR_PRF_HIGH_DISABLE_TIERED_COMPILATION |
COR_PRF_HIGH_BASIC_GC |
COR_PRF_HIGH_MONITOR_GC_MOVED_OBJECTS |
COR_PRF_HIGH_MONITOR_LARGEOBJECT_ALLOCATED |
COR_PRF_HIGH_MONITOR_EVENT_PIPE,
// MONITOR_IMMUTABLE represents all flags that may only be set during initialization.
// Trying to change any of these flags elsewhere will result in a
// failed HRESULT.
COR_PRF_HIGH_MONITOR_IMMUTABLE = COR_PRF_HIGH_DISABLE_TIERED_COMPILATION,
} COR_PRF_HIGH_MONITOR;
/*
* COR_PRF_MISC contains miscellaneous constant ID's used for special
* purposes.
*/
typedef enum
{
// PROFILER_PARENT_UNKNOWN is the AssemblyID used by GetModuleInfo
// when a module has not yet been attached to an assembly.
PROFILER_PARENT_UNKNOWN = 0xFFFFFFFD,
// PROFILER_GLOBAL_CLASS is a ClassID used for globals that belong to no class
PROFILER_GLOBAL_CLASS = 0xFFFFFFFE,
// PROFILER_GLOBAL_MODULE is a ModuleID used for globals that belong
// to no module in particular
PROFILER_GLOBAL_MODULE = 0xFFFFFFFF
} COR_PRF_MISC;
/*
* COR_PRF_JIT_CACHE contains values used to express the result of a
* cached function search. Note that FOUND is 0, and thus this is not truly
* a boolean.
*/
typedef enum
{
COR_PRF_CACHED_FUNCTION_FOUND,
COR_PRF_CACHED_FUNCTION_NOT_FOUND
} COR_PRF_JIT_CACHE;
/*
* COR_PRF_TRANSITION_REASON contains values used to describe
* the reason for a ManagedToUnmanaged or UnmanagedToManagedTransition
* callback.
*/
typedef enum
{
COR_PRF_TRANSITION_CALL,
COR_PRF_TRANSITION_RETURN
} COR_PRF_TRANSITION_REASON;
/*
* COR_PRF_SUSPEND_REASON contains values used to describe the
* reason for suspending the runtime. See the RuntimeSuspension*
* callbacks for detailed descriptions of each.
*/
typedef enum
{
COR_PRF_SUSPEND_OTHER = 0,
COR_PRF_SUSPEND_FOR_GC = 1,
COR_PRF_SUSPEND_FOR_APPDOMAIN_SHUTDOWN = 2,
COR_PRF_SUSPEND_FOR_CODE_PITCHING = 3,
COR_PRF_SUSPEND_FOR_SHUTDOWN = 4,
COR_PRF_SUSPEND_FOR_INPROC_DEBUGGER = 6,
COR_PRF_SUSPEND_FOR_GC_PREP = 7,
COR_PRF_SUSPEND_FOR_REJIT = 8,
COR_PRF_SUSPEND_FOR_PROFILER = 9,
} COR_PRF_SUSPEND_REASON;
/*
* COR_PRF_RUNTIME_TYPE contains values used to indicate the
* type of runtime.
*/
typedef enum
{
COR_PRF_DESKTOP_CLR = 0x1,
COR_PRF_CORE_CLR = 0x2,
} COR_PRF_RUNTIME_TYPE;
/*
* COR_PRF_REJIT_FLAGS contains values used to control the behavior of
* RequestReJITWithInliners.
*/
typedef enum
{
// ReJITted methods will be prevented from being inlined
COR_PRF_REJIT_BLOCK_INLINING = 0x1,
// This flag controls whether the runtime will call GetReJITParameters
// on methods that are ReJITted because they inline a method that was requested
// for ReJIT
COR_PRF_REJIT_INLINING_CALLBACKS = 0x2
} COR_PRF_REJIT_FLAGS;
typedef UINT_PTR EVENTPIPE_PROVIDER;
typedef UINT_PTR EVENTPIPE_EVENT;
typedef UINT64 EVENTPIPE_SESSION;
typedef enum
{
COR_PRF_EVENTPIPE_OBJECT = 1, // Instance that isn't a value
COR_PRF_EVENTPIPE_BOOLEAN = 3, // Boolean
COR_PRF_EVENTPIPE_CHAR = 4, // Unicode character
COR_PRF_EVENTPIPE_SBYTE = 5, // Signed 8-bit integer
COR_PRF_EVENTPIPE_BYTE = 6, // Unsigned 8-bit integer
COR_PRF_EVENTPIPE_INT16 = 7, // Signed 16-bit integer
COR_PRF_EVENTPIPE_UINT16 = 8, // Unsigned 16-bit integer
COR_PRF_EVENTPIPE_INT32 = 9, // Signed 32-bit integer
COR_PRF_EVENTPIPE_UINT32 = 10, // Unsigned 32-bit integer
COR_PRF_EVENTPIPE_INT64 = 11, // Signed 64-bit integer
COR_PRF_EVENTPIPE_UINT64 = 12, // Unsigned 64-bit integer
COR_PRF_EVENTPIPE_SINGLE = 13, // IEEE 32-bit float
COR_PRF_EVENTPIPE_DOUBLE = 14, // IEEE 64-bit double
COR_PRF_EVENTPIPE_DECIMAL = 15, // Decimal
COR_PRF_EVENTPIPE_DATETIME = 16, // DateTime
COR_PRF_EVENTPIPE_GUID = 17, // Guid
COR_PRF_EVENTPIPE_STRING = 18, // Unicode character string
COR_PRF_EVENTPIPE_ARRAY = 19, // Arbitrary length array
} COR_PRF_EVENTPIPE_PARAM_TYPE;
typedef enum
{
COR_PRF_EVENTPIPE_LOGALWAYS = 0,
COR_PRF_EVENTPIPE_CRITICAL = 1,
COR_PRF_EVENTPIPE_ERROR = 2,
COR_PRF_EVENTPIPE_WARNING = 3,
COR_PRF_EVENTPIPE_INFORMATIONAL = 4,
COR_PRF_EVENTPIPE_VERBOSE = 5
} COR_PRF_EVENTPIPE_LEVEL;
typedef struct
{
const WCHAR* providerName;
UINT64 keywords;
UINT32 loggingLevel;
// filterData expects a semicolon delimited string that defines key value pairs
// such as "key1=value1;key2=value2;". Quotes can be used to escape the '=' and ';'
// characters. These key value pairs will be passed in the enable callback to event
// providers
const WCHAR* filterData;
} COR_PRF_EVENTPIPE_PROVIDER_CONFIG;
typedef struct
{
UINT32 type;
// Used if type == ArrayType
UINT32 elementType;
const WCHAR *name;
} COR_PRF_EVENTPIPE_PARAM_DESC;
typedef struct
{
UINT64 ptr;
UINT32 size;
UINT32 reserved;
} COR_PRF_EVENT_DATA;
typedef struct
{
UINT64 Ptr;
UINT32 Size;
UINT32 Type;
} COR_PRF_FILTER_DATA;
typedef STDMETHODCALLTYPE void EventPipeProviderCallback(
const UINT8 *source_id,
UINT32 is_enabled,
UINT8 level,
UINT64 match_any_keywords,
UINT64 match_all_keywords,
COR_PRF_FILTER_DATA *filter_data,
void *callback_data);
typedef enum _COR_PRF_HANDLE_TYPE
{
COR_PRF_HANDLE_TYPE_WEAK = 0x1,
COR_PRF_HANDLE_TYPE_STRONG = 0x2,
COR_PRF_HANDLE_TYPE_PINNED = 0x3,
} COR_PRF_HANDLE_TYPE;
typedef void** ObjectHandleID;
/*
* Callback for each object in the GC Heap
*/
typedef BOOL STDMETHODCALLTYPE (* ObjectCallback)(ObjectID object, void* callbackState);
/* -------------------------------------------------------------------------- *
* Forward declarations
* -------------------------------------------------------------------------- */
interface ICorProfilerCallback;
interface ICorProfilerCallback2;
interface ICorProfilerCallback3;
interface ICorProfilerCallback4;
interface ICorProfilerInfo;
interface ICorProfilerInfo2;
interface ICorProfilerInfo3;
interface ICorProfilerInfo4;
interface ICorProfilerObjectEnum;
interface ICorProfilerFunctionEnum;
interface ICorProfilerModuleEnum;
interface ICorProfilerThreadEnum;
interface ICorProfilerMethodEnum;
interface IMethodMalloc;
interface ICorProfilerFunctionControl;
interface ICorProfilerAssemblyReferenceProvider;
/* -------------------------------------------------------------------------- *
* User Callback interface
* -------------------------------------------------------------------------- */
/*
* The ICorProfilerCallback interface is used by the CLR to notify a
* code profiler when events have occurred that the code profiler has registered
* an in interest in receiving. This is the primary callback interface through
* which the CLR communicates with the code profiler. A code profiler
* must register this callback interface in the Win32 registry. This object has
* several methods that receive notification from the runtime when an event is
* about to occur in an executing runtime process.
*
* The methods implemented on this interface return S_OK on success, or E_FAIL
* on failure.
*/
[
object,
uuid(176FBED1-A55C-4796-98CA-A9DA0EF883E7),
pointer_default(unique),
local
]
interface ICorProfilerCallback : IUnknown
{
/*
*
* STARTUP/SHUTDOWN EVENTS
*
*/
/*
* The CLR calls Initialize to setup the code profiler
* whenever a new CLR application is started. The call provides
* an IUnknown interface pointer that should be QI'd for an ICorProfilerInfo
* interface pointer.
*
* NOTE: this is the only opportunity to enable callbacks that are a part
* of COR_PRF_MONITOR_IMMUTABLE, since they can no longer be changed after
* returning from this function. This is done through SetEventMask on the
* ICorProfilerInfo object.
*/
HRESULT Initialize(
[in] IUnknown *pICorProfilerInfoUnk);
/*
* The CLR calls Shutdown to notify the code profiler that
* the application is exiting. This is the profiler's last opportunity to
* safely call functions on the ICorProfilerInfo interface. After returning
* from this function the runtime will proceed to unravel its internal data
* structures and any calls to ICorProfilerInfo are undefined in their
* behaviour.
*
* NOTE: Certain IMMUTABLE events may still occur after Shutdown.
*
* NOTE: Shutdown will only fire where the managed application that is being
* profiled was started running managed code (i.e., the initial frame on the
* process' stack is managed). If the application being profiled started
* life as unmanaged code, which later 'jumped into' managed code (thereby
* creating an instance of the CLR), then Shutdown will not fire. In these
* cases, the profiler should include a DllMain routine in their library that
* uses Win32's DLL_PROCESS_DETACH call to free any resources and perform tidy-up
* processing of its data (flush traces to disk, etc)
*
* NOTE: The profiler must in general cope with unexpected shutdowns, such as
* when the process is "killed" by Win32's TerminateProcess.
*
* NOTE: Sometimes the CLR will violently kill certain managed threads
* (background threads) without delivering orderly destruction messages for them.
*/
HRESULT Shutdown();
/*
*
* APPLICATION DOMAIN EVENTS
*
*/
/*
* Called when an application domain creation has begun and ended.
* The ID is not valid for any information request until the Finished
* event is called.
*
* Some parts of app domain loading may take place lazily at some time
* after the Finished callback. Therefore, while a failure HRESULT in
* hrStatus definitely indicates a failure, a success HRESULT only indicates
* that the first part of app domain creation succeeded.
*/
HRESULT AppDomainCreationStarted(
[in] AppDomainID appDomainId);
HRESULT AppDomainCreationFinished(
[in] AppDomainID appDomainId,
[in] HRESULT hrStatus);
/*
* Called before and after an app domain is unloaded from a process.
* The ID is no longer valid after the Started event returns.
*
* Some parts of app domain unloading may take place lazily at some time
* after the Finished callback. Therefore, while a failure HRESULT in
* hrStatus definitely indicates a failure, a success HRESULT only indicates
* that the first part of app domain unloading succeeded.
*/
HRESULT AppDomainShutdownStarted(
[in] AppDomainID appDomainId);
HRESULT AppDomainShutdownFinished(
[in] AppDomainID appDomainId,
[in] HRESULT hrStatus);