Skip to content

Commit d9f9d3d

Browse files
authored
[EventPipe][UserEvents] Add copy of user_events structs (#116930)
* [EventPipe][UserEvents] Add copy of user_events structs * Use hex representation * Various compiler warnings __attribute__((__packed__)) isn't declared in src/native uint8_t __reserved as a field name will somehow be interpreted as unsigned char
1 parent ad13be0 commit d9f9d3d

File tree

2 files changed

+64
-7
lines changed

2 files changed

+64
-7
lines changed

src/native/eventpipe/ep-session-provider.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
#include "ep-session-provider.h"
88
#include "ep-rt.h"
99

10-
#if HAVE_LINUX_USER_EVENTS_H
11-
#include <linux/user_events.h> // DIAG_IOCSREG
12-
#endif // HAVE_LINUX_USER_EVENTS_H
13-
1410
#if HAVE_SYS_IOCTL_H
1511
#include <sys/ioctl.h> // session_register_tracepoint
1612
#endif // HAVE_SYS_IOCTL_H
@@ -149,7 +145,7 @@ session_provider_event_filter_alloc (const EventPipeProviderEventFilter *event_f
149145
* EventPipeSessionProviderTracepoint.
150146
*/
151147

152-
#if HAVE_LINUX_USER_EVENTS_H && HAVE_SYS_IOCTL_H
148+
#if HAVE_SYS_IOCTL_H
153149
static
154150
bool
155151
session_provider_tracepoint_register (
@@ -194,7 +190,7 @@ session_provider_tracepoint_unregister (
194190

195191
return true;
196192
}
197-
#else // HAVE_LINUX_USER_EVENTS_H && HAVE_SYS_IOCTL_H
193+
#else // HAVE_SYS_IOCTL_H
198194
static
199195
bool
200196
session_provider_tracepoint_register (
@@ -214,7 +210,7 @@ session_provider_tracepoint_unregister (
214210
// Not Supported
215211
return false;
216212
}
217-
#endif // HAVE_LINUX_USER_EVENTS_H && HAVE_SYS_IOCTL_H
213+
#endif // HAVE_SYS_IOCTL_H
218214

219215
/*
220216
* ep_session_provider_register_tracepoints

src/native/eventpipe/ep-session-provider.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,67 @@
1111
#endif
1212
#include "ep-getter-setter.h"
1313

14+
#if HAVE_LINUX_USER_EVENTS_H
15+
#include <linux/user_events.h> // DIAG_IOCSREG
16+
#else // HAVE_LINUX_USER_EVENTS_H
17+
/*
18+
* Describes an event registration and stores the results of the registration.
19+
* This structure is passed to the DIAG_IOCSREG ioctl, callers at a minimum
20+
* must set the size and name_args before invocation.
21+
*/
22+
struct user_reg {
23+
24+
/* Input: Size of the user_reg structure being used */
25+
uint32_t size;
26+
27+
/* Input: Bit in enable address to use */
28+
uint8_t enable_bit;
29+
30+
/* Input: Enable size in bytes at address */
31+
uint8_t enable_size;
32+
33+
/* Input: Flags to use, if any */
34+
uint16_t flags;
35+
36+
/* Input: Address to update when enabled */
37+
uint64_t enable_addr;
38+
39+
/* Input: Pointer to string with event name, description and flags */
40+
uint64_t name_args;
41+
42+
/* Output: Index of the event to use when writing data */
43+
uint32_t write_index;
44+
};
45+
46+
/*
47+
* Describes an event unregister, callers must set the size, address and bit.
48+
* This structure is passed to the DIAG_IOCSUNREG ioctl to disable bit updates.
49+
*/
50+
struct user_unreg {
51+
/* Input: Size of the user_unreg structure being used */
52+
uint32_t size;
53+
54+
/* Input: Bit to unregister */
55+
uint8_t disable_bit;
56+
57+
/* Input: Reserved, set to 0 */
58+
uint8_t _reserved;
59+
60+
/* Input: Reserved, set to 0 */
61+
uint16_t _reserved2;
62+
63+
/* Input: Address to unregister */
64+
uint64_t disable_addr;
65+
};
66+
67+
/* Request to register a user_event */
68+
#define DIAG_IOCSREG 0xC0082A00
69+
70+
/* Requests to unregister a user_event */
71+
#define DIAG_IOCSUNREG 0x40082A02
72+
73+
#endif // HAVE_LINUX_USER_EVENTS_H
74+
1475
/*
1576
* EventPipeSessionProviderTracepoint.
1677
*/

0 commit comments

Comments
 (0)