diff options
author | Johan Lorensson <lateralusx.github@gmail.com> | 2021-04-20 18:01:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-20 18:01:33 +0300 |
commit | 58b25dfa8fae5f5a382a6ffbe89e9aee479eb31c (patch) | |
tree | 7e2711ff49f4a386238fe496faaed343b97fb5d6 /src/native/eventpipe | |
parent | ddaa1c3c503f989db48102f50a693765e4e6ae2a (diff) |
Mono runtime component infrastructure including EventPipe/DiagnosticsServer as a Mono runtime component. (#50837)
Implementation of Mono runtime component infrastructure, https://github.com/dotnet/runtime/blob/main/docs/design/mono/components.md.
This commit also includes a port of Mono EventPipe/DiagnosticsServer library over to new runtime component infrastructure.
Before all packaging/deploy have been fixed for platforms that will switch over to hosting components as shared libraries, all components will be build and linked using the static linkage scenario outline in document above. Once package and deploy is resolved for dynamic linking scenarios, we will switch this for corresponding platforms in follow up commits.
Diffstat (limited to 'src/native/eventpipe')
-rw-r--r-- | src/native/eventpipe/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/native/eventpipe/ds-ipc.c | 7 | ||||
-rw-r--r-- | src/native/eventpipe/ds-rt-config.h | 6 | ||||
-rw-r--r-- | src/native/eventpipe/ds-server.c | 2 | ||||
-rw-r--r-- | src/native/eventpipe/ep-buffer-manager.c | 1 | ||||
-rw-r--r-- | src/native/eventpipe/ep-ipc-pal-types-forward.h | 22 | ||||
-rw-r--r-- | src/native/eventpipe/ep-ipc-pal-types.h | 15 | ||||
-rw-r--r-- | src/native/eventpipe/ep-types-forward.h | 207 | ||||
-rw-r--r-- | src/native/eventpipe/ep-types.h | 198 | ||||
-rw-r--r-- | src/native/eventpipe/ep.c | 11 | ||||
-rw-r--r-- | src/native/eventpipe/ep.h | 7 |
11 files changed, 260 insertions, 218 deletions
diff --git a/src/native/eventpipe/CMakeLists.txt b/src/native/eventpipe/CMakeLists.txt index 07acdcf6800..c320b615fc4 100644 --- a/src/native/eventpipe/CMakeLists.txt +++ b/src/native/eventpipe/CMakeLists.txt @@ -41,6 +41,7 @@ if(ENABLE_PERFTRACING OR FEATURE_PERFTRACING) ep-file.h ep-getter-setter.h ep-ipc-pal-types.h + ep-ipc-pal-types-forward.h ep-ipc-stream.h ep-json-file.h ep-metadata-generator.h @@ -56,6 +57,7 @@ if(ENABLE_PERFTRACING OR FEATURE_PERFTRACING) ep-stream.h ep-thread.h ep-types.h + ep-types-forward.h ) list(APPEND SHARED_DIAGNOSTIC_SERVER_SOURCES diff --git a/src/native/eventpipe/ds-ipc.c b/src/native/eventpipe/ds-ipc.c index 8493eeab058..a8b12b1e980 100644 --- a/src/native/eventpipe/ds-ipc.c +++ b/src/native/eventpipe/ds-ipc.c @@ -7,6 +7,7 @@ #define DS_IMPL_IPC_PAL_GETTER_SETTER #include "ds-ipc.h" #include "ds-protocol.h" +#include "ep.h" #include "ds-rt.h" /* @@ -164,7 +165,7 @@ ipc_stream_factory_build_and_add_port ( bool result = false; DiagnosticsIpc *ipc = NULL; -#ifndef DS_IPC_PAL_TCP +#ifndef DS_IPC_DISABLE_LISTEN_PORTS if (!default_port && builder->type == DS_PORT_TYPE_LISTEN) { // Ignore listen type (see conversation in https://github.com/dotnet/runtime/pull/40499 for details) DS_LOG_INFO_0 ("ipc_stream_factory_build_and_add_port - Ignoring LISTEN port configuration"); @@ -238,6 +239,8 @@ ipc_log_poll_handles (ds_rt_ipc_poll_handle_array_t *ipc_poll_handles) bool ds_ipc_stream_factory_init (void) { + ep_ipc_stream_factory_callback_set (ds_ipc_stream_factory_any_suspended_ports); + ds_rt_port_array_alloc (&_ds_port_array); return ds_rt_port_array_is_valid (&_ds_port_array); } @@ -255,6 +258,8 @@ ds_ipc_stream_factory_fini (void) } ds_rt_port_array_free (&_ds_port_array);*/ + + ep_ipc_stream_factory_callback_set (NULL); } bool diff --git a/src/native/eventpipe/ds-rt-config.h b/src/native/eventpipe/ds-rt-config.h index 678ee18de2b..cb84d7d31af 100644 --- a/src/native/eventpipe/ds-rt-config.h +++ b/src/native/eventpipe/ds-rt-config.h @@ -11,7 +11,7 @@ #define DS_INCLUDE_SOURCE_FILES #endif -#ifdef FEATURE_PERFTRACING_PAL_TCP +#ifdef ENABLE_PERFTRACING_PAL_TCP #define DS_IPC_PAL_TCP #else #ifndef HOST_WIN32 @@ -21,11 +21,11 @@ #endif #endif -#ifdef FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS +#ifdef ENABLE_PERFTRACING_DISABLE_CONNECT_PORTS #define DS_IPC_DISABLE_CONNECT_PORTS #endif -#ifdef FEATURE_PERFTRACING_DISABLE_LISTEN_PORTS +#ifdef ENABLE_PERFTRACING_DISABLE_LISTEN_PORTS #define DS_IPC_DISABLE_LISTEN_PORTS #endif diff --git a/src/native/eventpipe/ds-server.c b/src/native/eventpipe/ds-server.c index 7f9c6866e03..dfce6d68604 100644 --- a/src/native/eventpipe/ds-server.c +++ b/src/native/eventpipe/ds-server.c @@ -116,7 +116,7 @@ EP_RT_DEFINE_THREAD_FUNC (server_thread) EP_ASSERT (server_volatile_load_shutting_down_state () || ds_ipc_stream_factory_has_active_ports ()); if (!ds_ipc_stream_factory_has_active_ports ()) { -#ifndef DS_IPC_PAL_TCP +#ifndef DS_IPC_DISABLE_LISTEN_PORTS DS_LOG_ERROR_0 ("Diagnostics IPC listener was undefined"); #endif return 1; diff --git a/src/native/eventpipe/ep-buffer-manager.c b/src/native/eventpipe/ep-buffer-manager.c index bcab43e1d34..5b7c0592caf 100644 --- a/src/native/eventpipe/ep-buffer-manager.c +++ b/src/native/eventpipe/ep-buffer-manager.c @@ -1371,6 +1371,7 @@ ep_buffer_manager_write_all_buffers_to_file_v4 ( } ep_on_exit: + ep_rt_thread_session_state_array_fini(&session_states_to_delete); return; ep_on_error: ep_exit_error_handler (); diff --git a/src/native/eventpipe/ep-ipc-pal-types-forward.h b/src/native/eventpipe/ep-ipc-pal-types-forward.h new file mode 100644 index 00000000000..2c890cce81a --- /dev/null +++ b/src/native/eventpipe/ep-ipc-pal-types-forward.h @@ -0,0 +1,22 @@ +#ifndef __EVENTPIPE_IPC_PAL_TYPES_FORWARD_H__ +#define __EVENTPIPE_IPC_PAL_TYPES_FORWARD_H__ + +#ifdef ENABLE_PERFTRACING + +#include <stdlib.h> +#include <stdint.h> +#ifndef __cplusplus +#include <stdbool.h> +#endif // __cplusplus + +typedef char ep_char8_t; + +/* + * IPC Stream Structs. + */ + +typedef struct _IpcStream IpcStream; +typedef struct _IpcStreamVtable IpcStreamVtable; + +#endif /* ENABLE_PERFTRACING */ +#endif /* __EVENTPIPE_IPC_PAL_TYPES_FORWARD_H__ */ diff --git a/src/native/eventpipe/ep-ipc-pal-types.h b/src/native/eventpipe/ep-ipc-pal-types.h index ac2f3d0c5bd..a353b8a3c10 100644 --- a/src/native/eventpipe/ep-ipc-pal-types.h +++ b/src/native/eventpipe/ep-ipc-pal-types.h @@ -9,20 +9,7 @@ #endif #include "ep-getter-setter.h" -#include <stdlib.h> -#include <stdint.h> -#ifndef __cplusplus -#include <stdbool.h> -#endif // __cplusplus - -typedef char ep_char8_t; - -/* - * IPC Stream Structs. - */ - -typedef struct _IpcStream IpcStream; -typedef struct _IpcStreamVtable IpcStreamVtable; +#include "ep-ipc-pal-types-forward.h" #endif /* ENABLE_PERFTRACING */ #endif /* __EVENTPIPE_IPC_PAL_TYPES_H__ */ diff --git a/src/native/eventpipe/ep-types-forward.h b/src/native/eventpipe/ep-types-forward.h new file mode 100644 index 00000000000..c6954d63296 --- /dev/null +++ b/src/native/eventpipe/ep-types-forward.h @@ -0,0 +1,207 @@ +#ifndef __EVENTPIPE_TYPES_FORWARD_H__ +#define __EVENTPIPE_TYPES_FORWARD_H__ + +#ifdef ENABLE_PERFTRACING + +/* + * EventPipe Structs. + */ + +typedef struct _EventData EventData; +typedef struct _EventFilterDescriptor EventFilterDescriptor; +typedef struct _EventPipeBuffer EventPipeBuffer; +typedef struct _EventPipeBufferList EventPipeBufferList; +typedef struct _EventPipeBufferManager EventPipeBufferManager; +typedef struct _EventPipeBlock EventPipeBlock; +typedef struct _EventPipeBlockVtable EventPipeBlockVtable; +typedef struct _EventPipeConfiguration EventPipeConfiguration; +typedef struct _EventPipeEvent EventPipeEvent; +typedef struct _EventPipeEventBlockBase EventPipeEventBlockBase; +typedef struct _EventPipeEventBlock EventPipeEventBlock; +typedef struct _EventPipeEventHeader EventPipeEventHeader; +typedef struct _EventPipeEventInstance EventPipeEventInstance; +typedef struct _EventPipeEventMetadataEvent EventPipeEventMetadataEvent; +typedef struct _EventPipeEventPayload EventPipeEventPayload; +typedef struct _EventPipeEventSource EventPipeEventSource; +typedef struct _EventPipeFile EventPipeFile; +typedef struct _EventPipeJsonFile EventPipeJsonFile; +typedef struct _EventPipeMetadataBlock EventPipeMetadataBlock; +typedef struct _EventPipeParameterDesc EventPipeParameterDesc; +typedef struct _EventPipeProvider EventPipeProvider; +typedef struct _EventPipeProviderCallbackData EventPipeProviderCallbackData; +typedef struct _EventPipeProviderCallbackDataQueue EventPipeProviderCallbackDataQueue; +typedef struct _EventPipeProviderConfiguration EventPipeProviderConfiguration; +typedef struct _EventPipeSession EventPipeSession; +typedef struct _EventPipeSessionProvider EventPipeSessionProvider; +typedef struct _EventPipeSessionProviderList EventPipeSessionProviderList; +typedef struct _EventPipeSequencePoint EventPipeSequencePoint; +typedef struct _EventPipeSequencePointBlock EventPipeSequencePointBlock; +typedef struct _EventPipeStackBlock EventPipeStackBlock; +typedef struct _EventPipeStackContents EventPipeStackContents; +typedef struct _EventPipeSystemTime EventPipeSystemTime; +typedef struct _EventPipeThread EventPipeThread; +typedef struct _EventPipeThreadHolder EventPipeThreadHolder; +typedef struct _EventPipeThreadSessionState EventPipeThreadSessionState; +typedef struct _FastSerializableObject FastSerializableObject; +typedef struct _FastSerializableObjectVtable FastSerializableObjectVtable; +typedef struct _FastSerializer FastSerializer; +typedef struct _FileStream FileStream; +typedef struct _FileStreamWriter FileStreamWriter; +typedef struct _IpcStreamWriter IpcStreamWriter; +typedef struct _StackHashEntry StackHashEntry; +typedef struct _StackHashKey StackHashKey; +typedef struct _StreamWriter StreamWriter; +typedef struct _StreamWriterVtable StreamWriterVtable; + +#define EP_MAX_NUMBER_OF_SESSIONS 64 + +#define EP_GUID_SIZE 16 + +#define EP_ACTIVITY_ID_SIZE EP_GUID_SIZE + +#define EP_MAX_STACK_DEPTH 100 + +/* + * EventPipe Enums. + */ + +typedef enum { + EP_BUFFER_STATE_WRITABLE = 0, + EP_BUFFER_STATE_READ_ONLY = 1 +} EventPipeBufferState; + +typedef enum { + EP_EVENT_LEVEL_LOGALWAYS, + EP_EVENT_LEVEL_CRITICAL, + EP_EVENT_LEVEL_ERROR, + EP_EVENT_LEVEL_WARNING, + EP_EVENT_LEVEL_INFORMATIONAL, + EP_EVENT_LEVEL_VERBOSE +} EventPipeEventLevel; + +typedef enum { + EP_FILE_FLUSH_FLAGS_EVENT_BLOCK = 1, + EP_FILE_FLUSH_FLAGS_METADATA_BLOCK = 2, + EP_FILE_FLUSH_FLAGS_STACK_BLOCK = 4, + EP_FILE_FLUSH_FLAGS_ALL_BLOCKS = EP_FILE_FLUSH_FLAGS_EVENT_BLOCK | EP_FILE_FLUSH_FLAGS_METADATA_BLOCK | EP_FILE_FLUSH_FLAGS_STACK_BLOCK +} EventPipeFileFlushFlags; + +// Represents the type of an event parameter. +// This enum is derived from the managed TypeCode type, though +// not all of these values are available in TypeCode. +// For example, Guid does not exist in TypeCode. +// Keep this in sync with COR_PRF_EVENTPIPE_PARAM_TYPE defined in +// corprof.idl +typedef enum { + EP_PARAMETER_TYPE_EMPTY = 0, // Null reference + EP_PARAMETER_TYPE_OBJECT = 1, // Instance that isn't a value + EP_PARAMETER_TYPE_DB_NULL = 2, // Database null value + EP_PARAMETER_TYPE_BOOLEAN = 3, // Boolean + EP_PARAMETER_TYPE_CHAR = 4, // Unicode character + EP_PARAMETER_TYPE_SBYTE = 5, // Signed 8-bit integer + EP_PARAMETER_TYPE_BYTE = 6, // Unsigned 8-bit integer + EP_PARAMETER_TYPE_INT16 = 7, // Signed 16-bit integer + EP_PARAMETER_TYPE_UINT16 = 8, // Unsigned 16-bit integer + EP_PARAMETER_TYPE_INT32 = 9, // Signed 32-bit integer + EP_PARAMETER_TYPE_UINT32 = 10, // Unsigned 32-bit integer + EP_PARAMETER_TYPE_INT64 = 11, // Signed 64-bit integer + EP_PARAMETER_TYPE_UINT64 = 12, // Unsigned 64-bit integer + EP_PARAMETER_TYPE_SINGLE = 13, // IEEE 32-bit float + EP_PARAMETER_TYPE_DOUBLE = 14, // IEEE 64-bit double + EP_PARAMETER_TYPE_DECIMAL = 15, // Decimal + EP_PARAMETER_TYPE_DATE_TIME = 16, // DateTime + EP_PARAMETER_TYPE_GUID = 17, // Guid + EP_PARAMETER_TYPE_STRING = 18, // Unicode character string + EP_PARAMETER_TYPE_ARRAY = 19 // Indicates the type is an arbitrary sized array +} EventPipeParameterType; + +typedef enum { + EP_METADATA_TAG_OPCODE = 1, + EP_METADATA_TAG_PARAMETER_PAYLOAD = 2 +} EventPipeMetadataTag; + +typedef enum { + EP_SAMPLE_PROFILER_SAMPLE_TYPE_ERROR = 0, + EP_SAMPLE_PROFILER_SAMPLE_TYPE_EXTERNAL = 1, + EP_SAMPLE_PROFILER_SAMPLE_TYPE_MANAGED = 2 +} EventPipeSampleProfilerSampleType; + +typedef enum { + // Default format used in .Net Core 2.0-3.0 Preview 6 + // TBD - it may remain the default format .Net Core 3.0 when + // used with private EventPipe managed API via reflection. + // This format had limited official exposure in documented + // end-user RTM scenarios, but it is supported by PerfView, + // TraceEvent, and was used by AI profiler. + EP_SERIALIZATION_FORMAT_NETPERF_V3, + // Default format we plan to use in .Net Core 3 Preview7+ + // for most if not all scenarios. + EP_SERIALIZATION_FORMAT_NETTRACE_V4, + EP_SERIALIZATION_FORMAT_COUNT +} EventPipeSerializationFormat; + +typedef enum { + EP_SESSION_TYPE_FILE, + EP_SESSION_TYPE_LISTENER, + EP_SESSION_TYPE_IPCSTREAM, + EP_SESSION_TYPE_SYNCHRONOUS +} EventPipeSessionType ; + +typedef enum { + EP_STATE_NOT_INITIALIZED, + EP_STATE_INITIALIZED, + EP_STATE_SHUTTING_DOWN +} EventPipeState; + +typedef enum { + EP_THREAD_TYPE_SERVER, + EP_THREAD_TYPE_SESSION, + EP_THREAD_TYPE_SAMPLING +} EventPipeThreadType; + +/* + * EventPipe Basic Types. + */ + +typedef intptr_t EventPipeWaitHandle; +typedef uint64_t EventPipeSessionID; +typedef unsigned short ep_char16_t; +typedef int64_t ep_timestamp_t; +typedef int64_t ep_system_timestamp_t; + +/* + * EventPipe Callbacks. + */ + +// Define the event pipe callback to match the ETW callback signature. +typedef void (*EventPipeCallback)( + const uint8_t *source_id, + unsigned long is_enabled, + uint8_t level, + uint64_t match_any_keywords, + uint64_t match_all_keywords, + EventFilterDescriptor *filter_data, + void *callback_data); + +typedef void (*EventPipeCallbackDataFree)( + EventPipeCallback callback, + void *callback_data); + +typedef void (*EventPipeSessionSynchronousCallback)( + EventPipeProvider *provider, + uint32_t event_id, + uint32_t event_version, + uint32_t metadata_blob_len, + const uint8_t *metadata_blob, + uint32_t event_data_len, + const uint8_t *event_data, + const uint8_t *activity_id, + const uint8_t *related_activity_id, + /*ep_rt_thread_handle_t*/ void *event_thread, + uint32_t stack_frames_len, + uintptr_t *stack_frames); + +typedef bool (*EventPipeIpcStreamFactorySuspendedPortsCallback)(void); + +#endif /* ENABLE_PERFTRACING */ +#endif /* __EVENTPIPE_TYPES_FORWARD_H__ */ diff --git a/src/native/eventpipe/ep-types.h b/src/native/eventpipe/ep-types.h index 0c91757fcfb..22ad3a749bf 100644 --- a/src/native/eventpipe/ep-types.h +++ b/src/native/eventpipe/ep-types.h @@ -10,207 +10,11 @@ #endif #include "ep-getter-setter.h" -/* - * EventPipe Structs. - */ - -typedef struct _EventData EventData; -typedef struct _EventFilterDescriptor EventFilterDescriptor; -typedef struct _EventPipeBuffer EventPipeBuffer; -typedef struct _EventPipeBufferList EventPipeBufferList; -typedef struct _EventPipeBufferManager EventPipeBufferManager; -typedef struct _EventPipeBlock EventPipeBlock; -typedef struct _EventPipeBlockVtable EventPipeBlockVtable; -typedef struct _EventPipeConfiguration EventPipeConfiguration; -typedef struct _EventPipeEvent EventPipeEvent; -typedef struct _EventPipeEventBlockBase EventPipeEventBlockBase; -typedef struct _EventPipeEventBlock EventPipeEventBlock; -typedef struct _EventPipeEventHeader EventPipeEventHeader; -typedef struct _EventPipeEventInstance EventPipeEventInstance; -typedef struct _EventPipeEventMetadataEvent EventPipeEventMetadataEvent; -typedef struct _EventPipeEventPayload EventPipeEventPayload; -typedef struct _EventPipeEventSource EventPipeEventSource; -typedef struct _EventPipeFile EventPipeFile; -typedef struct _EventPipeJsonFile EventPipeJsonFile; -typedef struct _EventPipeMetadataBlock EventPipeMetadataBlock; -typedef struct _EventPipeParameterDesc EventPipeParameterDesc; -typedef struct _EventPipeProvider EventPipeProvider; -typedef struct _EventPipeProviderCallbackData EventPipeProviderCallbackData; -typedef struct _EventPipeProviderCallbackDataQueue EventPipeProviderCallbackDataQueue; -typedef struct _EventPipeProviderConfiguration EventPipeProviderConfiguration; -typedef struct _EventPipeSession EventPipeSession; -typedef struct _EventPipeSessionProvider EventPipeSessionProvider; -typedef struct _EventPipeSessionProviderList EventPipeSessionProviderList; -typedef struct _EventPipeSequencePoint EventPipeSequencePoint; -typedef struct _EventPipeSequencePointBlock EventPipeSequencePointBlock; -typedef struct _EventPipeStackBlock EventPipeStackBlock; -typedef struct _EventPipeStackContents EventPipeStackContents; -typedef struct _EventPipeSystemTime EventPipeSystemTime; -typedef struct _EventPipeThread EventPipeThread; -typedef struct _EventPipeThreadHolder EventPipeThreadHolder; -typedef struct _EventPipeThreadSessionState EventPipeThreadSessionState; -typedef struct _FastSerializableObject FastSerializableObject; -typedef struct _FastSerializableObjectVtable FastSerializableObjectVtable; -typedef struct _FastSerializer FastSerializer; -typedef struct _FileStream FileStream; -typedef struct _FileStreamWriter FileStreamWriter; -typedef struct _IpcStreamWriter IpcStreamWriter; -typedef struct _StackHashEntry StackHashEntry; -typedef struct _StackHashKey StackHashKey; -typedef struct _StreamWriter StreamWriter; -typedef struct _StreamWriterVtable StreamWriterVtable; - -#define EP_MAX_NUMBER_OF_SESSIONS 64 - -#define EP_GUID_SIZE 16 - -#define EP_ACTIVITY_ID_SIZE EP_GUID_SIZE - -#define EP_MAX_STACK_DEPTH 100 - -/* - * EventPipe Enums. - */ - -typedef enum { - EP_BUFFER_STATE_WRITABLE = 0, - EP_BUFFER_STATE_READ_ONLY = 1 -} EventPipeBufferState; - -typedef enum { - EP_EVENT_LEVEL_LOGALWAYS, - EP_EVENT_LEVEL_CRITICAL, - EP_EVENT_LEVEL_ERROR, - EP_EVENT_LEVEL_WARNING, - EP_EVENT_LEVEL_INFORMATIONAL, - EP_EVENT_LEVEL_VERBOSE -} EventPipeEventLevel; - -typedef enum { - EP_FILE_FLUSH_FLAGS_EVENT_BLOCK = 1, - EP_FILE_FLUSH_FLAGS_METADATA_BLOCK = 2, - EP_FILE_FLUSH_FLAGS_STACK_BLOCK = 4, - EP_FILE_FLUSH_FLAGS_ALL_BLOCKS = EP_FILE_FLUSH_FLAGS_EVENT_BLOCK | EP_FILE_FLUSH_FLAGS_METADATA_BLOCK | EP_FILE_FLUSH_FLAGS_STACK_BLOCK -} EventPipeFileFlushFlags; - -// Represents the type of an event parameter. -// This enum is derived from the managed TypeCode type, though -// not all of these values are available in TypeCode. -// For example, Guid does not exist in TypeCode. -// Keep this in sync with COR_PRF_EVENTPIPE_PARAM_TYPE defined in -// corprof.idl -typedef enum { - EP_PARAMETER_TYPE_EMPTY = 0, // Null reference - EP_PARAMETER_TYPE_OBJECT = 1, // Instance that isn't a value - EP_PARAMETER_TYPE_DB_NULL = 2, // Database null value - EP_PARAMETER_TYPE_BOOLEAN = 3, // Boolean - EP_PARAMETER_TYPE_CHAR = 4, // Unicode character - EP_PARAMETER_TYPE_SBYTE = 5, // Signed 8-bit integer - EP_PARAMETER_TYPE_BYTE = 6, // Unsigned 8-bit integer - EP_PARAMETER_TYPE_INT16 = 7, // Signed 16-bit integer - EP_PARAMETER_TYPE_UINT16 = 8, // Unsigned 16-bit integer - EP_PARAMETER_TYPE_INT32 = 9, // Signed 32-bit integer - EP_PARAMETER_TYPE_UINT32 = 10, // Unsigned 32-bit integer - EP_PARAMETER_TYPE_INT64 = 11, // Signed 64-bit integer - EP_PARAMETER_TYPE_UINT64 = 12, // Unsigned 64-bit integer - EP_PARAMETER_TYPE_SINGLE = 13, // IEEE 32-bit float - EP_PARAMETER_TYPE_DOUBLE = 14, // IEEE 64-bit double - EP_PARAMETER_TYPE_DECIMAL = 15, // Decimal - EP_PARAMETER_TYPE_DATE_TIME = 16, // DateTime - EP_PARAMETER_TYPE_GUID = 17, // Guid - EP_PARAMETER_TYPE_STRING = 18, // Unicode character string - EP_PARAMETER_TYPE_ARRAY = 19 // Indicates the type is an arbitrary sized array -} EventPipeParameterType; - -typedef enum { - EP_METADATA_TAG_OPCODE = 1, - EP_METADATA_TAG_PARAMETER_PAYLOAD = 2 -} EventPipeMetadataTag; - -typedef enum { - EP_SAMPLE_PROFILER_SAMPLE_TYPE_ERROR = 0, - EP_SAMPLE_PROFILER_SAMPLE_TYPE_EXTERNAL = 1, - EP_SAMPLE_PROFILER_SAMPLE_TYPE_MANAGED = 2 -} EventPipeSampleProfilerSampleType; - -typedef enum { - // Default format used in .Net Core 2.0-3.0 Preview 6 - // TBD - it may remain the default format .Net Core 3.0 when - // used with private EventPipe managed API via reflection. - // This format had limited official exposure in documented - // end-user RTM scenarios, but it is supported by PerfView, - // TraceEvent, and was used by AI profiler. - EP_SERIALIZATION_FORMAT_NETPERF_V3, - // Default format we plan to use in .Net Core 3 Preview7+ - // for most if not all scenarios. - EP_SERIALIZATION_FORMAT_NETTRACE_V4, - EP_SERIALIZATION_FORMAT_COUNT -} EventPipeSerializationFormat; - -typedef enum { - EP_SESSION_TYPE_FILE, - EP_SESSION_TYPE_LISTENER, - EP_SESSION_TYPE_IPCSTREAM, - EP_SESSION_TYPE_SYNCHRONOUS -} EventPipeSessionType ; - -typedef enum { - EP_STATE_NOT_INITIALIZED, - EP_STATE_INITIALIZED, - EP_STATE_SHUTTING_DOWN -} EventPipeState; - -typedef enum { - EP_THREAD_TYPE_SERVER, - EP_THREAD_TYPE_SESSION, - EP_THREAD_TYPE_SAMPLING -} EventPipeThreadType; - -/* - * EventPipe Basic Types. - */ - -typedef intptr_t EventPipeWaitHandle; -typedef uint64_t EventPipeSessionID; -typedef unsigned short ep_char16_t; -typedef int64_t ep_timestamp_t; -typedef int64_t ep_system_timestamp_t; +#include "ep-types-forward.h" #include "ep-rt-types.h" /* - * EventPipe Callbacks. - */ - -// Define the event pipe callback to match the ETW callback signature. -typedef void (*EventPipeCallback)( - const uint8_t *source_id, - unsigned long is_enabled, - uint8_t level, - uint64_t match_any_keywords, - uint64_t match_all_keywords, - EventFilterDescriptor *filter_data, - void *callback_data); - -typedef void (*EventPipeCallbackDataFree)( - EventPipeCallback callback, - void *callback_data); - -typedef void (*EventPipeSessionSynchronousCallback)( - EventPipeProvider *provider, - uint32_t event_id, - uint32_t event_version, - uint32_t metadata_blob_len, - const uint8_t *metadata_blob, - uint32_t event_data_len, - const uint8_t *event_data, - const uint8_t *activity_id, - const uint8_t *related_activity_id, - ep_rt_thread_handle_t event_thread, - uint32_t stack_frames_len, - uintptr_t *stack_frames); - -/* * EventFilterDescriptor. */ diff --git a/src/native/eventpipe/ep.c b/src/native/eventpipe/ep.c index 5517c7d98fc..9552dd59eb1 100644 --- a/src/native/eventpipe/ep.c +++ b/src/native/eventpipe/ep.c @@ -20,6 +20,8 @@ static bool _ep_can_start_threads = false; static ep_rt_session_id_array_t _ep_deferred_enable_session_ids = { 0 }; static ep_rt_session_id_array_t _ep_deferred_disable_session_ids = { 0 }; +static EventPipeIpcStreamFactorySuspendedPortsCallback _ep_ipc_stream_factory_suspended_ports_callback = NULL; + /* * Forward declares of all static functions. */ @@ -842,8 +844,7 @@ static bool ipc_stream_factory_any_suspended_ports (void) { - extern bool ds_ipc_stream_factory_any_suspended_ports (void); - return ds_ipc_stream_factory_any_suspended_ports (); + return _ep_ipc_stream_factory_suspended_ports_callback ? _ep_ipc_stream_factory_suspended_ports_callback () : false; } #ifdef EP_CHECKED_BUILD @@ -1523,6 +1524,12 @@ ep_system_time_set ( system_time->milliseconds = milliseconds; } +void +ep_ipc_stream_factory_callback_set (EventPipeIpcStreamFactorySuspendedPortsCallback suspended_ports_callback) +{ + _ep_ipc_stream_factory_suspended_ports_callback = suspended_ports_callback; +} + #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ diff --git a/src/native/eventpipe/ep.h b/src/native/eventpipe/ep.h index cfb99aa9d65..fb2dafd2469 100644 --- a/src/native/eventpipe/ep.h +++ b/src/native/eventpipe/ep.h @@ -337,6 +337,13 @@ ep_system_time_get (EventPipeSystemTime *system_time) ep_rt_system_time_get (system_time); } +/* + * EventPipeIpcStreamFactoryCallback. + */ + +void +ep_ipc_stream_factory_callback_set (EventPipeIpcStreamFactorySuspendedPortsCallback suspended_ports_callback); + #else /* ENABLE_PERFTRACING */ static |