Commit | Line | Data |
---|---|---|
2d1318e4 JG |
1 | /* |
2 | * event-internal.h | |
3 | * | |
4 | * Linux Trace Toolkit Control Library | |
5 | * | |
ab5be9fa | 6 | * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
2d1318e4 | 7 | * |
ab5be9fa | 8 | * SPDX-License-Identifier: LGPL-2.1-only |
2d1318e4 | 9 | * |
2d1318e4 JG |
10 | */ |
11 | ||
12 | #ifndef LTTNG_EVENT_INTERNAL_H | |
13 | #define LTTNG_EVENT_INTERNAL_H | |
14 | ||
76fcf151 JG |
15 | #include <common/macros.h> |
16 | #include <lttng/event.h> | |
17 | ||
166fc586 JR |
18 | struct lttng_event_exclusion; |
19 | struct lttng_filter_bytecode; | |
2d1318e4 | 20 | struct lttng_userspace_probe_location; |
166fc586 JR |
21 | struct lttng_dynamic_buffer; |
22 | struct lttng_buffer_view; | |
23 | ||
24 | struct lttng_event_comm { | |
25 | int8_t event_type; | |
26 | int8_t loglevel_type; | |
27 | int32_t loglevel; | |
28 | int8_t enabled; | |
29 | int32_t pid; | |
30 | uint32_t flags; | |
31 | ||
32 | /* Payload. */ | |
33 | /* Includes terminator `\0`. */ | |
34 | uint32_t name_len; | |
35 | uint32_t exclusion_count; | |
36 | /* Includes terminator `\0`. */ | |
37 | uint32_t filter_expression_len; | |
38 | uint32_t bytecode_len; | |
39 | ||
40 | /* Type specific payload. */ | |
41 | uint32_t userspace_probe_location_len; | |
42 | uint32_t lttng_event_probe_attr_len; | |
43 | uint32_t lttng_event_function_attr_len; | |
44 | ||
45 | /* | |
46 | * Contain: | |
47 | * - name [name_len], | |
48 | * - exclusions if any | |
49 | * - char filter_expression[filter_expression_len], | |
50 | * - unsigned char filter_bytecode[bytecode_len], | |
51 | * - userspace probe location [userspace_probe_location_len], | |
52 | * - probe or ftrace based on event type. | |
53 | */ | |
54 | ||
55 | char payload[]; | |
56 | } LTTNG_PACKED; | |
57 | ||
58 | struct lttng_event_exclusion_comm { | |
59 | /* Includes terminator `\0`. */ | |
60 | uint32_t len; | |
61 | char payload []; | |
62 | } LTTNG_PACKED; | |
63 | ||
64 | struct lttng_event_probe_attr_comm { | |
65 | uint64_t addr; | |
66 | uint64_t offset; | |
67 | /* Includes terminator `\0`. */ | |
68 | uint32_t symbol_name_len; | |
69 | ||
70 | char payload[]; | |
71 | } LTTNG_PACKED; | |
72 | ||
73 | struct lttng_event_function_attr_comm { | |
74 | /* Includes terminator `\0`. */ | |
75 | uint32_t symbol_name_len; | |
76 | ||
77 | char payload[]; | |
78 | } LTTNG_PACKED; | |
2d1318e4 | 79 | |
b583ad83 JR |
80 | struct lttng_event_context_comm { |
81 | uint32_t type; | |
82 | /* | |
83 | * Depending on the type. | |
84 | * For: | |
85 | * - LTTNG_EVENT_CONTEXT_APP_CONTEXT. | |
86 | * | |
87 | * -> struct lttng_event_context_app_comm | |
88 | * | |
89 | * For | |
90 | * - LTTNG_EVENT_CONTEXT_PERF_COUNTER, | |
91 | * - LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER, | |
92 | * - LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER. | |
93 | * | |
94 | * -> struct lttng_event_context_perf_counter_comm | |
95 | * | |
96 | * Other type -> no payload. | |
97 | */ | |
98 | char payload[]; | |
99 | } LTTNG_PACKED; | |
100 | ||
101 | struct lttng_event_context_perf_counter_comm { | |
102 | uint32_t type; | |
103 | uint64_t config; | |
104 | /* Includes terminator `\0`. */ | |
105 | uint32_t name_len; | |
106 | /* | |
107 | * char name [name_len] | |
108 | */ | |
109 | char payload[]; | |
110 | } LTTNG_PACKED; | |
111 | ||
112 | struct lttng_event_context_app_comm { | |
113 | /* Includes terminator `\0`. */ | |
114 | uint32_t provider_name_len; | |
115 | /* Includes terminator `\0`. */ | |
116 | uint32_t ctx_name_len; | |
117 | /* | |
118 | * provider name [provider_name_len] | |
119 | * ctx name [ctx_name_len] | |
120 | */ | |
121 | char payload[]; | |
122 | } LTTNG_PACKED; | |
123 | ||
c2afda67 JR |
124 | struct lttng_event_field_comm { |
125 | uint8_t type; | |
126 | uint8_t nowrite; | |
127 | /* Includes terminator `\0`. */ | |
128 | uint32_t name_len; | |
129 | uint32_t event_len; | |
130 | ||
131 | /* | |
132 | * - name [name_len] | |
133 | * - lttng_event object | |
134 | */ | |
135 | char payload[]; | |
136 | } LTTNG_PACKED; | |
137 | ||
2d1318e4 JG |
138 | struct lttng_event_extended { |
139 | /* | |
140 | * exclusions and filter_expression are only set when the lttng_event | |
141 | * was created/allocated by a list operation. These two elements must | |
142 | * not be free'd as they are part of the same contiguous buffer that | |
143 | * contains all events returned by the listing. | |
144 | */ | |
145 | char *filter_expression; | |
146 | struct { | |
147 | unsigned int count; | |
148 | /* Array of strings of fixed LTTNG_SYMBOL_NAME_LEN length. */ | |
149 | char *strings; | |
150 | } exclusions; | |
151 | struct lttng_userspace_probe_location *probe_location; | |
152 | }; | |
153 | ||
76fcf151 JG |
154 | LTTNG_HIDDEN |
155 | struct lttng_event *lttng_event_copy(const struct lttng_event *event); | |
156 | ||
166fc586 JR |
157 | LTTNG_HIDDEN |
158 | ssize_t lttng_event_create_from_buffer(const struct lttng_buffer_view *view, | |
159 | struct lttng_event **event, | |
160 | struct lttng_event_exclusion **exclusion, | |
161 | char **filter_expression, | |
162 | struct lttng_filter_bytecode **bytecode, | |
163 | int sock); | |
164 | ||
165 | LTTNG_HIDDEN | |
166 | int lttng_event_serialize(const struct lttng_event *event, | |
167 | unsigned int exclusion_count, | |
168 | char **exclusion_list, | |
169 | char *filter_expression, | |
170 | size_t bytecode_len, | |
171 | void *bytecode, | |
172 | struct lttng_dynamic_buffer *buf, | |
173 | int *fd_to_send); | |
174 | ||
b583ad83 JR |
175 | LTTNG_HIDDEN |
176 | ssize_t lttng_event_context_create_from_buffer( | |
177 | const struct lttng_buffer_view *view, | |
178 | struct lttng_event_context **event_ctx); | |
179 | ||
180 | LTTNG_HIDDEN | |
181 | int lttng_event_context_serialize(struct lttng_event_context *context, | |
182 | struct lttng_dynamic_buffer *buf); | |
183 | ||
184 | LTTNG_HIDDEN | |
185 | void lttng_event_context_destroy(struct lttng_event_context *context); | |
186 | ||
c2afda67 JR |
187 | LTTNG_HIDDEN |
188 | ssize_t lttng_event_field_create_from_buffer( | |
189 | const struct lttng_buffer_view *view, | |
190 | struct lttng_event_field **field); | |
191 | ||
192 | LTTNG_HIDDEN | |
193 | int lttng_event_field_serialize(const struct lttng_event_field *field, | |
194 | struct lttng_dynamic_buffer *buffer); | |
195 | ||
166fc586 JR |
196 | LTTNG_HIDDEN |
197 | enum lttng_error_code lttng_events_create_and_flatten_from_buffer( | |
198 | const struct lttng_buffer_view *view, | |
199 | unsigned int count, | |
200 | struct lttng_event **events); | |
201 | ||
c2afda67 JR |
202 | LTTNG_HIDDEN |
203 | enum lttng_error_code lttng_event_fields_create_and_flatten_from_buffer( | |
204 | const struct lttng_buffer_view *view, | |
205 | unsigned int count, | |
206 | struct lttng_event_field **fields); | |
207 | ||
2d1318e4 | 208 | #endif /* LTTNG_EVENT_INTERNAL_H */ |