Skip to content

Commit

Permalink
Add profiler APIs for writing EventPipe events (dotnet#2173)
Browse files Browse the repository at this point in the history
* Profiler APIs for writing events

* Code review feedback

* Change EVENTPIPE_EVENTID to EVENTPIPE_EVENT to avoid confusion with EventID

* have the runtime pack the arguments instead of the profiler

* Add more checks in asserts
  • Loading branch information
davmason authored Jan 31, 2020
1 parent be41d62 commit 9db6eea
Show file tree
Hide file tree
Showing 8 changed files with 3,363 additions and 1,986 deletions.
79 changes: 79 additions & 0 deletions src/coreclr/src/inc/corprof.idl
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,51 @@ typedef enum
COR_PRF_REJIT_INLINING_CALLBACKS = 0x2
} COR_PRF_REJIT_FLAGS;

typedef UINT_PTR EVENTPIPE_PROVIDER;
typedef UINT_PTR EVENTPIPE_EVENT;

typedef enum
{
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_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
{
UINT32 type;
const WCHAR *name;
} COR_PRF_EVENTPIPE_PARAM_DESC;

typedef struct
{
UINT64 ptr;
UINT32 size;
UINT32 reserved;
} COR_PRF_EVENT_DATA;

/* -------------------------------------------------------------------------- *
* Forward declarations
Expand Down Expand Up @@ -4019,6 +4064,40 @@ interface ICorProfilerInfo11 : ICorProfilerInfo10
[in, string] const WCHAR *szValue);
}

[
object,
uuid(27b24ccd-1cb1-47c5-96ee-98190dc30959),
pointer_default(unique),
local
]
interface ICorProfilerInfo12 : ICorProfilerInfo11
{
HRESULT EventPipeCreateProvider(
[in, string] const WCHAR *szName,
[out] EVENTPIPE_PROVIDER *pProviderHandle);

HRESULT EventPipeDefineEvent(
[in] EVENTPIPE_PROVIDER provHandle,
[in, string] const WCHAR *szName,
[in] UINT32 eventID,
[in] UINT64 keywords,
[in] UINT32 eventVersion,
[in] UINT32 level,
[in] BOOL needStack,
[in] UINT32 cParamDescs,
[in, size_is(cParamDescs)]
COR_PRF_EVENTPIPE_PARAM_DESC pParamDescs[],
[out] EVENTPIPE_EVENT *pEventHandle);

HRESULT EventPipeWriteEvent(
[in] EVENTPIPE_EVENT eventHandle,
[in, size_is(cData)]
COR_PRF_EVENT_DATA data[],
[in] UINT32 cData,
[in] LPCGUID pActivityId,
[in] LPCGUID pRelatedActivityId);
}

/*
* This interface lets you iterate over methods in the runtime.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/src/pal/prebuilt/idl/corprof_i.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ MIDL_DEFINE_GUID(IID, IID_ICorProfilerInfo10,0x2F1B5152,0xC869,0x40C9,0xAA,0x5F,
MIDL_DEFINE_GUID(IID, IID_ICorProfilerInfo11,0x06398876,0x8987,0x4154,0xB6,0x21,0x40,0xA0,0x0D,0x6E,0x4D,0x04);


MIDL_DEFINE_GUID(IID, IID_ICorProfilerInfo12,0x27b24ccd,0x1cb1,0x47c5,0x96,0xee,0x98,0x19,0x0d,0xc3,0x09,0x59);


MIDL_DEFINE_GUID(IID, IID_ICorProfilerMethodEnum,0xFCCEE788,0x0088,0x454B,0xA8,0x11,0xC9,0x9F,0x29,0x8D,0x19,0x42);


Expand Down
Loading

0 comments on commit 9db6eea

Please sign in to comment.