-
Notifications
You must be signed in to change notification settings - Fork 5k
Add the ability for profilers to listen to EventPipe events #37002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
40d9308
Proof of concept synchronous profiler EventPipe events
davmason 7e2bbd8
Add provider callback and ability to query provider name
davmason a6ecda8
add guids to API
davmason af29c79
stop creating a buffer manager for synchronous sessions
davmason 7198ac5
Take lock before adding provider to session
davmason 7f3642c
fix linux build error
davmason 1eb39d7
refactoring
davmason ce70d00
Get rid of enablecpusampling argument
davmason d644cba
move EventPipeProviderCreated profiler callback outside of lock
davmason 8d1b5bc
refactor SuspendWriteEvent so it covers the synchronous callback case…
davmason 7cb9a1a
after EventPipe starts shutting down return an error for EventPipeSta…
davmason c132d07
switch to spinlock since we can't use crst in gc_notrigger/coop
davmason ee9aee8
Add assert and remove unused variable
davmason 540d8e3
Move storing null to the session array before EventPipeSession::Suspe…
davmason 5eca5ef
remove spurious assert
davmason 619f4b8
Fix SampleProfiler refcount issue, double profiler callback, remove u…
davmason 7905bcf
remove the concept of m_writeEventSuspending from the buffer manager …
davmason 96d8cc4
Add test
davmason 87ceca4
add description of filter data format
davmason 0cc9a28
fix x86 test build issues
davmason 008dabd
exlcude test from mono
davmason 68e3479
move waiting on threads to finish writing outside of the lock
davmason 2c3429e
allow call to GetProviderInfo to get the length of the name
davmason 5ab6fd0
Fix formatting
davmason File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -640,11 +640,14 @@ typedef enum | |
// 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, | ||
|
||
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_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 | ||
|
@@ -738,9 +741,11 @@ typedef enum | |
|
||
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 | ||
davmason marked this conversation as resolved.
Show resolved
Hide resolved
|
||
COR_PRF_EVENTPIPE_BOOLEAN = 3, // Boolean | ||
COR_PRF_EVENTPIPE_CHAR = 4, // Unicode character | ||
COR_PRF_EVENTPIPE_SBYTE = 5, // Signed 8-bit integer | ||
|
@@ -770,6 +775,18 @@ typedef enum | |
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; | ||
davmason marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} COR_PRF_EVENTPIPE_PROVIDER_CONFIG; | ||
|
||
typedef struct | ||
{ | ||
UINT32 type; | ||
|
@@ -2510,6 +2527,34 @@ interface ICorProfilerCallback9 : ICorProfilerCallback8 | |
HRESULT DynamicMethodUnloaded([in] FunctionID functionId); | ||
} | ||
|
||
[ | ||
object, | ||
uuid(CEC5B60E-C69C-495F-87F6-84D28EE16FFB), | ||
pointer_default(unique), | ||
local | ||
] | ||
interface ICorProfilerCallback10 : ICorProfilerCallback9 | ||
{ | ||
// This event is triggered whenever an EventPipe event is configured to be delivered. | ||
// | ||
// Documentation Note: All pointers are only valid during the callback | ||
|
||
HRESULT EventPipeEventDelivered( | ||
[in] EVENTPIPE_PROVIDER provider, | ||
[in] DWORD eventId, | ||
[in] DWORD eventVersion, | ||
[in] ULONG cbMetadataBlob, | ||
[in, size_is(cbMetadataBlob)] LPCBYTE metadataBlob, | ||
[in] ULONG cbEventData, | ||
[in, size_is(cbEventData)] LPCBYTE eventData, | ||
[in] LPCGUID pActivityId, | ||
[in] LPCGUID pRelatedActivityId, | ||
[in] ThreadID eventThread, | ||
[in] ULONG numStackFrames, | ||
[in, length_is(numStackFrames)] UINT_PTR stackFrames[]); | ||
|
||
HRESULT EventPipeProviderCreated([in] EVENTPIPE_PROVIDER provider); | ||
davmason marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/* | ||
* COR_PRF_CODEGEN_FLAGS controls various flags and hooks for a specific | ||
|
@@ -4076,13 +4121,34 @@ interface ICorProfilerInfo11 : ICorProfilerInfo10 | |
] | ||
interface ICorProfilerInfo12 : ICorProfilerInfo11 | ||
{ | ||
HRESULT EventPipeStartSession( | ||
[in] UINT32 cProviderConfigs, | ||
[in, size_is(cProviderConfigs)] | ||
COR_PRF_EVENTPIPE_PROVIDER_CONFIG pProviderConfigs[], | ||
[in] BOOL requestRundown, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. requestMetadataDump? |
||
[out] EVENTPIPE_SESSION* pSession); | ||
|
||
HRESULT EventPipeAddProviderToSession( | ||
davmason marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[in] EVENTPIPE_SESSION session, | ||
[in] COR_PRF_EVENTPIPE_PROVIDER_CONFIG providerConfig); | ||
|
||
HRESULT EventPipeStopSession( | ||
[in] EVENTPIPE_SESSION session); | ||
|
||
HRESULT EventPipeCreateProvider( | ||
[in, string] const WCHAR *szName, | ||
[out] EVENTPIPE_PROVIDER *pProviderHandle); | ||
[in, string] const WCHAR *providerName, | ||
[out] EVENTPIPE_PROVIDER *pProvider); | ||
|
||
HRESULT EventPipeGetProviderInfo( | ||
[in] EVENTPIPE_PROVIDER provider, | ||
[in] ULONG cchName, | ||
[out] ULONG *pcchName, | ||
[out, annotation("_Out_writes_to_(cchName, *pcchName)")] | ||
WCHAR providerName[]); | ||
|
||
HRESULT EventPipeDefineEvent( | ||
[in] EVENTPIPE_PROVIDER provHandle, | ||
[in, string] const WCHAR *szName, | ||
[in] EVENTPIPE_PROVIDER provider, | ||
[in, string] const WCHAR *eventName, | ||
[in] UINT32 eventID, | ||
[in] UINT64 keywords, | ||
[in] UINT32 eventVersion, | ||
|
@@ -4092,10 +4158,10 @@ interface ICorProfilerInfo12 : ICorProfilerInfo11 | |
[in] UINT32 cParamDescs, | ||
[in, size_is(cParamDescs)] | ||
COR_PRF_EVENTPIPE_PARAM_DESC pParamDescs[], | ||
[out] EVENTPIPE_EVENT *pEventHandle); | ||
[out] EVENTPIPE_EVENT *pEvent); | ||
|
||
HRESULT EventPipeWriteEvent( | ||
[in] EVENTPIPE_EVENT eventHandle, | ||
[in] EVENTPIPE_EVENT event, | ||
[in] UINT32 cData, | ||
[in, size_is(cData)] | ||
COR_PRF_EVENT_DATA data[], | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.