Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 02b8f50

Browse files
committed
Add an event pipe that pipes to the profiler apis
1 parent 72ac464 commit 02b8f50

14 files changed

+1161
-21
lines changed

src/inc/corprof.idl

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,13 @@ typedef enum
621621

622622
COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED = 0x00000002,
623623

624+
COR_PRF_HIGH_MONITOR_EVENT_PIPE = 0x00000004,
625+
626+
COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS = 0x00000008,
627+
624628
COR_PRF_HIGH_REQUIRE_PROFILE_IMAGE = 0,
625629

626-
COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH = COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED,
630+
COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH = COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED | COR_PRF_HIGH_MONITOR_EVENT_PIPE | COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS,
627631

628632
// MONITOR_IMMUTABLE represents all flags that may only be set during initialization.
629633
// Trying to change any of these flags elsewhere will result in a
@@ -2408,6 +2412,31 @@ interface ICorProfilerCallback8 : ICorProfilerCallback7
24082412
[in] BOOL fIsSafeToBlock);
24092413
}
24102414

2415+
[
2416+
object,
2417+
uuid(27583EC3-C8F5-482F-8052-194B8CE4705A),
2418+
pointer_default(unique),
2419+
local
2420+
]
2421+
interface ICorProfilerCallback9 : ICorProfilerCallback8
2422+
{
2423+
// This event is triggered whenever a dynamic method is garbage collected
2424+
// and subsequently unloaded.
2425+
2426+
HRESULT DynamicMethodUnloaded([in] FunctionID functionId);
2427+
2428+
HRESULT EventPipeEventDelivered(
2429+
[in] REFGUID eventGuid,
2430+
[in] DWORD eventId,
2431+
[in] DWORD eventVersion,
2432+
[in] DWORD eventThreadId,
2433+
[in] LARGE_INTEGER eventTimestamp,
2434+
[in] ULONG cbEventData,
2435+
[in, size_is(cbEventData)] LPCBYTE eventData,
2436+
[in] ULONG numStackFrames,
2437+
[in, length_is(numStackFrames)] UINT_PTR stackFrames[]);
2438+
}
2439+
24112440

24122441
/*
24132442
* COR_PRF_CODEGEN_FLAGS controls various flags and hooks for a specific

src/inc/profilepriv.inl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,36 @@ inline BOOL CORProfilerInMemorySymbolsUpdatesEnabled()
736736
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED));
737737
}
738738

739+
inline BOOL CORProfilerIsMonitoringEventPipe()
740+
{
741+
CONTRACTL
742+
{
743+
NOTHROW;
744+
GC_NOTRIGGER;
745+
CANNOT_TAKE_LOCK;
746+
SO_NOT_MAINLINE;
747+
}
748+
CONTRACTL_END;
749+
750+
return (CORProfilerPresent() &&
751+
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_MONITOR_EVENT_PIPE));
752+
}
753+
754+
inline BOOL CORProfilerIsMonitoringDynamicFunctionUnloads()
755+
{
756+
CONTRACTL
757+
{
758+
NOTHROW;
759+
GC_NOTRIGGER;
760+
CANNOT_TAKE_LOCK;
761+
SO_NOT_MAINLINE;
762+
}
763+
CONTRACTL_END;
764+
765+
return (CORProfilerPresent() &&
766+
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS));
767+
}
768+
739769
#if defined(PROFILING_SUPPORTED) && !defined(CROSSGEN_COMPILE)
740770

741771
#if defined(FEATURE_PROFAPI_ATTACH_DETACH)

src/pal/prebuilt/idl/corprof_i.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/* link this file in with the server and any clients */
88

99

10-
/* File created by MIDL compiler version 8.00.0603 */
10+
/* File created by MIDL compiler version 8.01.0622 */
1111
/* @@MIDL_FILE_HEADING( ) */
1212

1313
#pragma warning( disable: 4049 ) /* more than 64k source lines */
@@ -55,9 +55,9 @@ typedef IID CLSID;
5555
#endif // CLSID_DEFINED
5656

5757
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
58-
const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
58+
EXTERN_C __declspec(selectany) const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
5959

60-
#endif !_MIDL_USE_GUIDDEF_
60+
#endif // !_MIDL_USE_GUIDDEF_
6161

6262
MIDL_DEFINE_GUID(IID, IID_ICorProfilerCallback,0x176FBED1,0xA55C,0x4796,0x98,0xCA,0xA9,0xDA,0x0E,0xF8,0x83,0xE7);
6363

@@ -83,6 +83,9 @@ MIDL_DEFINE_GUID(IID, IID_ICorProfilerCallback7,0xF76A2DBA,0x1D52,0x4539,0x86,0x
8383
MIDL_DEFINE_GUID(IID, IID_ICorProfilerCallback8,0x5BED9B15,0xC079,0x4D47,0xBF,0xE2,0x21,0x5A,0x14,0x0C,0x07,0xE0);
8484

8585

86+
MIDL_DEFINE_GUID(IID, IID_ICorProfilerCallback9,0x27583EC3,0xC8F5,0x482F,0x80,0x52,0x19,0x4B,0x8C,0xE4,0x70,0x5A);
87+
88+
8689
MIDL_DEFINE_GUID(IID, IID_ICorProfilerInfo,0x28B5557D,0x3F3F,0x48b4,0x90,0xB2,0x5F,0x9E,0xEA,0x2F,0x6C,0x48);
8790

8891

0 commit comments

Comments
 (0)