Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WIP][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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

mdh1418
Copy link
Member

@mdh1418 mdh1418 commented May 3, 2025

WIP Runtime support for dotnet/diagnostics#5454

Organized commits to be somewhat piece by piece

TODO

  • Serialize actual event data
  • Add unit tests

Did manual End-to-end testing

mdh1418 added 9 commits May 2, 2025 21:58
Visual reorder of Diagnostics enum structs
Fix a couple naming typos
Spaces to tabs consistency
CollectTracing5 from dotnet/diagnostics ipc-protocol.md introduces new
fields serialized into an EventPipe Provider Configuration that are used
to enable a user_events based eventpipe session.

Add the fields to the ProviderConfiguration struct
Starting in CollectTracing5 fields are not serialized for scenarios
where they are not needed. Add opt-in deserialization for more fine
grained control over deserialization logic.
Add a new EventPipe Command to enable a user_events based
EventPipe Session based on CollectTracing5 IPC protocol in
dotnet/diagnostics
@Copilot Copilot AI review requested due to automatic review settings May 3, 2025 02:46
@mdh1418 mdh1418 marked this pull request as draft May 3, 2025 02:47
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces Linux user events support for EventPipe by adding a new session type (EP_SESSION_TYPE_USEREVENTS) and integrating tracepoint registration and event filtering for user events.

  • Added new overloads and structures (e.g. EventPipeTracepoint, EventPipeEventFilter, ProviderTracepointConfiguration) to support user events.
  • Updated session allocation, option validation, and event writing to incorporate handling of user events.
  • Fixed minor naming issues and adjusted IPC protocol definitions for consistency.

Reviewed Changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/native/eventpipe/ep.c Adds new overloads for provider config initialization and adjusts option checks for USEREVENTS.
src/native/eventpipe/ep-types.h Introduces new structures and getters for tracepoint and event filtering support.
src/native/eventpipe/ep-types-forward.h Adds new session type EP_SESSION_TYPE_USEREVENTS.
src/native/eventpipe/ep-session.h & .c Adds user events-related fields and functions (tracepoint registration, event writing).
src/native/eventpipe/ep-session-provider.h & .c Updates provider allocation and filtering to include event filtering and tracepoint configuration.
src/native/eventpipe/ep-provider.c Updates provider enable mask computation to factor in event filtering via event id.
src/native/eventpipe/ds-types.h Cleans up duplicate definitions for command IDs.
src/native/eventpipe/ds-server.c, ds-protocol.* Fixes naming inconsistencies and updates IPC protocol references.
src/native/eventpipe/ds-ipc* files Adds and updates support functions for receiving file descriptors over IPC.
Files not reviewed (2)
  • src/native/eventpipe/configure.cmake: Language not supported
  • src/native/eventpipe/ep-shared-config.h.in: Language not supported

Comment on lines +677 to +678
// return false;
return true;
Copy link
Preview

Copilot AI May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ep_tracepoint_write, the function returns true on a writev failure, which may hide errors. Consider returning false to indicate the failure.

Suggested change
// return false;
return true;
return false;

Copilot uses AI. Check for mistakes.

@@ -74,13 +74,13 @@ ipc_message_try_parse_string_utf16_t_byte_array (
uint8_t *
ds_ipc_advertise_cookie_v1_get (void)
{
return _ds_ipc_advertise_cooike_v1;
return _ds_ipc_advertise_cookie_v1;
Copy link
Preview

Copilot AI May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected misspelling of '_ds_ipc_advertise_cooike_v1' to '_ds_ipc_advertise_cookie_v1'.

Copilot uses AI. Check for mistakes.

Comment on lines 177 to +187

struct EventPipeTracepoint {
uint32_t *write_index;
uint32_t *enabled;
};

struct EventPipeEventFilter {
bool allow;
dn_vector_t *event_ids;
};

Copy link
Preview

Copilot AI May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding documentation comments for the new structures (EventPipeTracepoint, EventPipeEventFilter, ProviderTracepointSet, ProviderTracepointConfiguration) to improve maintainability.

Suggested change
struct EventPipeTracepoint {
uint32_t *write_index;
uint32_t *enabled;
};
struct EventPipeEventFilter {
bool allow;
dn_vector_t *event_ids;
};
/**
* @struct EventPipeTracepoint
* @brief Represents a tracepoint in the EventPipe system.
*
* This structure is used to manage tracepoints, which are specific
* locations in the code where events can be emitted.
*
* @var write_index Pointer to the write index for the tracepoint.
* @var enabled Pointer to a flag indicating whether the tracepoint is enabled.
*/
struct EventPipeTracepoint {
uint32_t *write_index;
uint32_t *enabled;
};
/**
* @struct EventPipeEventFilter
* @brief Represents a filter for EventPipe events.
*
* This structure is used to filter events based on their IDs.
*
* @var allow Boolean flag indicating whether the filter allows events.
* @var event_ids Vector of event IDs that the filter applies to.
*/
struct EventPipeEventFilter {
bool allow;
dn_vector_t *event_ids;
};
/**
* @struct ProviderTracepointSet
* @brief Represents a set of tracepoints for a provider.
*
* This structure is used to associate a provider with its tracepoints
* and the corresponding event IDs.
*
* @var tracepoint_name Name of the tracepoint.
* @var event_ids Vector of event IDs associated with the tracepoint.
*/

Copilot uses AI. Check for mistakes.

@mdh1418
Copy link
Member Author

mdh1418 commented May 3, 2025

@noahfalk @beaubelgrave @brianrob This is still a WIP, but has everything from deserializing the IPC messages, to registering the tracepoints, and writes dummy data to the tracepoint.

CC: @lateralusX FYI, adding some eventpipe changes

@mdh1418
Copy link
Member Author

mdh1418 commented May 6, 2025

CC: @agocke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant