Skip to content

[Linux][EventPipe][UserEvents] Add user events eventpipe support #115265

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 32 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ff7cbad
[DiagnosticServer] Refactor and Cleanup
mdh1418 Apr 3, 2025
d9a59c1
[EventPipe] Add User_events structs
mdh1418 Jun 2, 2025
1eecfdc
[EventPipe] Add User_events eventpipe session
mdh1418 Jun 2, 2025
52bd1a1
[DiagnosticServer] Revamp Provider Config deserialization
mdh1418 Jun 2, 2025
26284e2
[DiagnosticServer] Deprecate old deserializer
mdh1418 May 31, 2025
3ea4e82
[DiagnosticServer] Add CollectTracing5 command parser
mdh1418 Apr 16, 2025
97b12d1
[DiagnosticServer] Deserialize file_descriptor from IPC Stream
mdh1418 May 2, 2025
d20e584
[EventPipe] Use Event_filter to set EventPipeEvent enabled mask
mdh1418 May 2, 2025
e81e10c
[UserEvents] Register and unregister tracepoints
mdh1418 Jun 2, 2025
d6648a2
[UserEvents] Write events to tracepoints
mdh1418 May 3, 2025
e20b176
Fixup CI build failures
mdh1418 Jun 2, 2025
64632d3
Cleanup missed CI build failures
mdh1418 Jun 5, 2025
2d9b4d9
Address feedback
mdh1418 Jun 5, 2025
a16e198
Address Feedback const EventPipeProviderConfiguration
mdh1418 Jun 6, 2025
7baa695
Address feedback Add string deserializer helper
mdh1418 Jun 7, 2025
20ecd2e
Revert provider_configs to vector of structs
mdh1418 Jun 7, 2025
c12c002
Dynamically allocate tracepoint format
mdh1418 Jun 7, 2025
6e8ea95
Fix CI Build failures
mdh1418 Jun 8, 2025
a06f091
Split ProviderConfiguration structs
mdh1418 Jun 9, 2025
677b7d9
Reuse EventPipeSessionTypes
mdh1418 Jun 10, 2025
db7a3f5
Constrain tracepoint_config modification to session provider
mdh1418 Jun 10, 2025
bcbc867
Fixup compilation error
mdh1418 Jun 10, 2025
e607a07
Move metadata into extensions portion
mdh1418 Jun 10, 2025
53cde48
Free default tracepoint format
mdh1418 Jun 11, 2025
faff9ea
Address feedback
mdh1418 Jun 11, 2025
a7a8f83
Address feedback
mdh1418 Jun 12, 2025
08e5f2e
Consistently use addresses of struct fields
mdh1418 Jun 13, 2025
1f22763
Fix typo
mdh1418 Jun 13, 2025
6e01b62
Address feedback
mdh1418 Jun 17, 2025
54ec518
Address feedback
mdh1418 Jun 17, 2025
93f7f0a
Address Feedback
mdh1418 Jun 17, 2025
e25e9f0
Fix Sign mismatch build error
mdh1418 Jun 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/coreclr/nativeaot/Runtime/eventpipeinternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ EXTERN_C uint64_t QCALLTYPE EventPipeInternal_Enable(

if (configProviders) {
for (uint32_t i = 0; i < numProviders; ++i) {
ep_char8_t *providerName = ep_rt_utf16_to_utf8_string (reinterpret_cast<const ep_char16_t *>(nativeProviders[i].pProviderName));
ep_char8_t *filterData = ep_rt_utf16_to_utf8_string (reinterpret_cast<const ep_char16_t *>(nativeProviders[i].pFilterData));
ep_provider_config_init (
&configProviders[i],
ep_rt_utf16_to_utf8_string (reinterpret_cast<const ep_char16_t *>(nativeProviders[i].pProviderName)),
providerName,
nativeProviders[i].keywords,
static_cast<EventPipeEventLevel>(nativeProviders[i].loggingLevel),
ep_rt_utf16_to_utf8_string (reinterpret_cast<const ep_char16_t *>(nativeProviders[i].pFilterData)));
filterData);
ep_rt_utf8_string_free (providerName);
ep_rt_utf8_string_free (filterData);
}
}

Expand All @@ -95,10 +99,8 @@ EXTERN_C uint64_t QCALLTYPE EventPipeInternal_Enable(
ep_start_streaming(result);

if (configProviders) {
for (uint32_t i = 0; i < numProviders; ++i) {
ep_rt_utf8_string_free ((ep_char8_t *)ep_provider_config_get_provider_name (&configProviders[i]));
ep_rt_utf8_string_free ((ep_char8_t *)ep_provider_config_get_filter_data (&configProviders[i]));
}
for (uint32_t i = 0; i < numProviders; ++i)
ep_provider_config_fini (&configProviders[i]);
free(configProviders);
}

Expand Down
18 changes: 11 additions & 7 deletions src/coreclr/vm/eventpipeadapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ class EventPipeProviderConfigurationAdapter final
m_providerConfigsLen = providerConfigsLen;
if (m_providerConfigs) {
for (uint32_t i = 0; i < providerConfigsLen; ++i) {
ep_char8_t *providerName = ep_rt_utf16_to_utf8_string (reinterpret_cast<const ep_char16_t *>(providerConfigs[i].providerName));
ep_char8_t *filterData = ep_rt_utf16_to_utf8_string (reinterpret_cast<const ep_char16_t *>(providerConfigs[i].filterData));
ep_provider_config_init (
&m_providerConfigs[i],
ep_rt_utf16_to_utf8_string (reinterpret_cast<const ep_char16_t *>(providerConfigs[i].providerName)),
providerName,
providerConfigs[i].keywords,
static_cast<EventPipeEventLevel>(providerConfigs[i].loggingLevel),
ep_rt_utf16_to_utf8_string (reinterpret_cast<const ep_char16_t *>(providerConfigs[i].filterData)));
filterData);
ep_rt_utf8_string_free (providerName);
ep_rt_utf8_string_free (filterData);
}
}
}
Expand All @@ -54,10 +58,8 @@ class EventPipeProviderConfigurationAdapter final
{
STATIC_CONTRACT_NOTHROW;
if (m_providerConfigs) {
for (uint32_t i = 0; i < m_providerConfigsLen; ++i) {
ep_rt_utf8_string_free ((ep_char8_t *)ep_provider_config_get_provider_name (&m_providerConfigs[i]));
ep_rt_utf8_string_free ((ep_char8_t *)ep_provider_config_get_filter_data (&m_providerConfigs[i]));
}
for (uint32_t i = 0; i < m_providerConfigsLen; ++i)
ep_provider_config_fini(&m_providerConfigs[i]);
delete [] m_providerConfigs;
}
}
Expand Down Expand Up @@ -385,7 +387,9 @@ class EventPipeAdapter final
ep_provider_config_get_provider_name (&config[0]),
ep_provider_config_get_keywords (&config[0]),
(EventPipeEventLevel)ep_provider_config_get_logging_level (&config[0]),
ep_provider_config_get_filter_data (&config[0]));
ep_provider_config_get_filter_data (&config[0]),
NULL,
NULL);
}

static HRESULT GetProviderName(const EventPipeProvider *provider, ULONG numNameChars, ULONG *numNameCharsOut, LPWSTR name)
Expand Down
14 changes: 7 additions & 7 deletions src/mono/mono/component/event_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,22 @@ event_pipe_enable (
IpcStream *stream,
EventPipeSessionSynchronousCallback sync_callback)
{
ERROR_DECL (error);
EventPipeSessionID session_id = 0;

EventPipeProviderConfiguration *config_providers = g_new0 (EventPipeProviderConfiguration, providers_len);

if (config_providers) {
for (guint32 i = 0; i < providers_len; ++i) {
ep_char8_t *provider_name = ep_rt_utf16_to_utf8_string ((const ep_char16_t *)(providers[i].provider_name));
ep_char8_t *filter_data = ep_rt_utf16_to_utf8_string ((const ep_char16_t *)(providers[i].filter_data));
ep_provider_config_init (
&config_providers[i],
providers[i].provider_name ? mono_utf16_to_utf8 (providers[i].provider_name, g_utf16_len (providers[i].provider_name), error) : NULL,
provider_name,
providers [i].keywords,
(EventPipeEventLevel)providers [i].logging_level,
providers[i].filter_data ? mono_utf16_to_utf8 (providers[i].filter_data, g_utf16_len (providers[i].filter_data), error) : NULL);
filter_data);
ep_rt_utf8_string_free (provider_name);
ep_rt_utf8_string_free (filter_data);
}
}

Expand All @@ -180,11 +183,8 @@ event_pipe_enable (
NULL);

if (config_providers) {
for (guint32 i = 0; i < providers_len; ++i) {
for (guint32 i = 0; i < providers_len; ++i)
ep_provider_config_fini (&config_providers[i]);
g_free ((ep_char8_t *)ep_provider_config_get_provider_name (&config_providers[i]));
g_free ((ep_char8_t *)ep_provider_config_get_filter_data (&config_providers[i]));
}
}

return session_id;
Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/eventpipe/test/ep-buffer-manager-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ buffer_manager_init (
current_provider_config,
1,
NULL,
NULL);
NULL,
0);
EP_LOCK_EXIT (section1)

ep_raise_error_if_nok (*session != NULL);
Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/eventpipe/test/ep-buffer-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ load_buffer_with_events_init (
current_provider_config,
1,
NULL,
NULL);
NULL,
0);
EP_LOCK_EXIT (section1)

ep_raise_error_if_nok (*session != NULL);
Expand Down
11 changes: 7 additions & 4 deletions src/mono/mono/eventpipe/test/ep-session-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ test_create_delete_session (void)
current_provider_config,
1,
NULL,
NULL);
NULL,
0);
EP_LOCK_EXIT (section1)

ep_raise_error_if_nok (test_session != NULL);
Expand Down Expand Up @@ -93,7 +94,8 @@ test_add_session_providers (void)
current_provider_config,
1,
NULL,
NULL);
NULL,
0);

ep_raise_error_if_nok_holding_lock (test_session != NULL, section1);

Expand All @@ -111,7 +113,7 @@ test_add_session_providers (void)

test_location = 3;

test_session_provider = ep_session_provider_alloc (TEST_PROVIDER_NAME, 1, EP_EVENT_LEVEL_LOGALWAYS, "");
test_session_provider = ep_session_provider_alloc (TEST_PROVIDER_NAME, 1, EP_EVENT_LEVEL_LOGALWAYS, "", NULL, NULL);
ep_raise_error_if_nok (test_session_provider != NULL);

test_location = 4;
Expand Down Expand Up @@ -176,7 +178,8 @@ test_session_special_get_set (void)
current_provider_config,
1,
NULL,
NULL);
NULL,
0);
EP_LOCK_EXIT (section1)

ep_raise_error_if_nok (test_session != NULL);
Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/eventpipe/test/ep-thread-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ test_thread_session_state (void)
provider_config,
1,
NULL,
NULL);
NULL,
0);
EP_LOCK_EXIT (section1)

if (!session) {
Expand Down
1 change: 1 addition & 0 deletions src/native/containers/dn-umap-t.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ DN_UMAP_T (ptr, void *, int16, int16_t)
DN_UMAP_T (ptr, void *, uint16, uint16_t)
DN_UMAP_T (ptr, void *, int32, int32_t)
DN_UMAP_T (ptr, void *, uint32, uint32_t)
DN_UMAP_T (uint32, uint32_t, ptr, void *)

#endif /* __DN_UMAP_T_H__ */
3 changes: 3 additions & 0 deletions src/native/containers/dn-vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ dn_vector_custom_free (
dn_vector_t *vector,
dn_vector_dispose_func_t dispose_func)
{
if (DN_UNLIKELY(!vector))
return;

dn_vector_custom_dispose (vector, dispose_func);
dn_allocator_free (vector->_internal._allocator, vector);
}
Expand Down
26 changes: 26 additions & 0 deletions src/native/eventpipe/configure.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include(CheckSymbolExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)

check_include_file(
sys/socket.h
Expand All @@ -17,6 +18,31 @@ if (CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID)
set(FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT 1)
endif()

check_include_file(
linux/user_events.h
HAVE_LINUX_USER_EVENTS_H
)

check_include_file(
sys/ioctl.h
HAVE_SYS_IOCTL_H
)

check_include_file(
unistd.h
HAVE_UNISTD_H
)

check_include_file(
"sys/uio.h"
HAVE_SYS_UIO_H
)

check_include_file(
errno.h
HAVE_ERRNO_H
)

if (NOT DEFINED EP_GENERATED_HEADER_PATH)
message(FATAL_ERROR "Required configuration EP_GENERATED_HEADER_PATH not set.")
endif (NOT DEFINED EP_GENERATED_HEADER_PATH)
Expand Down
Loading
Loading