Commit | Line | Data |
---|---|---|
1239a312 DG |
1 | /* |
2 | * Copyright (C) 2014 - David Goulet <dgoulet@efficios.com> | |
2001793c | 3 | * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com> |
1239a312 DG |
4 | * |
5 | * This library is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License, version 2.1 only, | |
7 | * as published by the Free Software Foundation. | |
8 | * | |
9 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | |
12 | * for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU Lesser General Public License | |
15 | * along with this library; if not, write to the Free Software Foundation, | |
16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | ||
19 | #ifndef LTTNG_EVENT_H | |
20 | #define LTTNG_EVENT_H | |
21 | ||
22 | #ifdef __cplusplus | |
23 | extern "C" { | |
24 | #endif | |
25 | ||
26 | #include <lttng/handle.h> | |
27 | ||
28 | /* | |
29 | * Instrumentation type of tracing event. | |
30 | */ | |
31 | enum lttng_event_type { | |
32 | LTTNG_EVENT_ALL = -1, | |
33 | LTTNG_EVENT_TRACEPOINT = 0, | |
34 | LTTNG_EVENT_PROBE = 1, | |
35 | LTTNG_EVENT_FUNCTION = 2, | |
36 | LTTNG_EVENT_FUNCTION_ENTRY = 3, | |
37 | LTTNG_EVENT_NOOP = 4, | |
38 | LTTNG_EVENT_SYSCALL = 5, | |
39 | }; | |
40 | ||
41 | /* | |
42 | * Loglevel information. | |
43 | */ | |
44 | enum lttng_loglevel_type { | |
45 | LTTNG_EVENT_LOGLEVEL_ALL = 0, | |
46 | LTTNG_EVENT_LOGLEVEL_RANGE = 1, | |
47 | LTTNG_EVENT_LOGLEVEL_SINGLE = 2, | |
48 | }; | |
49 | ||
50 | /* | |
51 | * Available loglevels. | |
52 | */ | |
53 | enum lttng_loglevel { | |
54 | LTTNG_LOGLEVEL_EMERG = 0, | |
55 | LTTNG_LOGLEVEL_ALERT = 1, | |
56 | LTTNG_LOGLEVEL_CRIT = 2, | |
57 | LTTNG_LOGLEVEL_ERR = 3, | |
58 | LTTNG_LOGLEVEL_WARNING = 4, | |
59 | LTTNG_LOGLEVEL_NOTICE = 5, | |
60 | LTTNG_LOGLEVEL_INFO = 6, | |
61 | LTTNG_LOGLEVEL_DEBUG_SYSTEM = 7, | |
62 | LTTNG_LOGLEVEL_DEBUG_PROGRAM = 8, | |
63 | LTTNG_LOGLEVEL_DEBUG_PROCESS = 9, | |
64 | LTTNG_LOGLEVEL_DEBUG_MODULE = 10, | |
65 | LTTNG_LOGLEVEL_DEBUG_UNIT = 11, | |
66 | LTTNG_LOGLEVEL_DEBUG_FUNCTION = 12, | |
67 | LTTNG_LOGLEVEL_DEBUG_LINE = 13, | |
68 | LTTNG_LOGLEVEL_DEBUG = 14, | |
69 | }; | |
70 | ||
71 | /* | |
72 | * Available loglevels for the JUL domain. Those are an exact map from the | |
73 | * class java.util.logging.Level. | |
74 | */ | |
75 | enum lttng_loglevel_jul { | |
76 | LTTNG_LOGLEVEL_JUL_OFF = INT32_MAX, | |
77 | LTTNG_LOGLEVEL_JUL_SEVERE = 1000, | |
78 | LTTNG_LOGLEVEL_JUL_WARNING = 900, | |
79 | LTTNG_LOGLEVEL_JUL_INFO = 800, | |
80 | LTTNG_LOGLEVEL_JUL_CONFIG = 700, | |
81 | LTTNG_LOGLEVEL_JUL_FINE = 500, | |
82 | LTTNG_LOGLEVEL_JUL_FINER = 400, | |
83 | LTTNG_LOGLEVEL_JUL_FINEST = 300, | |
84 | LTTNG_LOGLEVEL_JUL_ALL = INT32_MIN, | |
85 | }; | |
86 | ||
5cdb6027 DG |
87 | /* |
88 | * Available loglevels for the LOG4j domain. Those are an exact map from the | |
89 | * class org.apache.log4j.Level. | |
90 | */ | |
91 | enum lttng_loglevel_log4j { | |
92 | LTTNG_LOGLEVEL_LOG4J_OFF = INT32_MAX, | |
93 | LTTNG_LOGLEVEL_LOG4J_FATAL = 50000, | |
94 | LTTNG_LOGLEVEL_LOG4J_ERROR = 40000, | |
95 | LTTNG_LOGLEVEL_LOG4J_WARN = 30000, | |
96 | LTTNG_LOGLEVEL_LOG4J_INFO = 20000, | |
97 | LTTNG_LOGLEVEL_LOG4J_DEBUG = 10000, | |
98 | LTTNG_LOGLEVEL_LOG4J_TRACE = 5000, | |
99 | LTTNG_LOGLEVEL_LOG4J_ALL = INT32_MIN, | |
100 | }; | |
101 | ||
0e115563 DG |
102 | /* |
103 | * Available loglevels for the Python domain. Those are an exact map from the | |
104 | * Level class. | |
105 | */ | |
106 | enum lttng_loglevel_python { | |
107 | LTTNG_LOGLEVEL_PYTHON_CRITICAL = 50, | |
108 | LTTNG_LOGLEVEL_PYTHON_ERROR = 40, | |
109 | LTTNG_LOGLEVEL_PYTHON_WARNING = 30, | |
110 | LTTNG_LOGLEVEL_PYTHON_INFO = 20, | |
111 | LTTNG_LOGLEVEL_PYTHON_DEBUG = 10, | |
112 | LTTNG_LOGLEVEL_PYTHON_NOTSET = 0, | |
113 | }; | |
114 | ||
1239a312 DG |
115 | /* |
116 | * LTTng consumer mode | |
117 | */ | |
118 | enum lttng_event_output { | |
119 | LTTNG_EVENT_SPLICE = 0, | |
120 | LTTNG_EVENT_MMAP = 1, | |
121 | }; | |
122 | ||
123 | /* Event context possible type */ | |
124 | enum lttng_event_context_type { | |
2001793c JG |
125 | LTTNG_EVENT_CONTEXT_PID = 0, |
126 | LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1, /* Backward compat. */ | |
127 | LTTNG_EVENT_CONTEXT_PROCNAME = 2, | |
128 | LTTNG_EVENT_CONTEXT_PRIO = 3, | |
129 | LTTNG_EVENT_CONTEXT_NICE = 4, | |
130 | LTTNG_EVENT_CONTEXT_VPID = 5, | |
131 | LTTNG_EVENT_CONTEXT_TID = 6, | |
132 | LTTNG_EVENT_CONTEXT_VTID = 7, | |
133 | LTTNG_EVENT_CONTEXT_PPID = 8, | |
134 | LTTNG_EVENT_CONTEXT_VPPID = 9, | |
135 | LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10, | |
136 | LTTNG_EVENT_CONTEXT_HOSTNAME = 11, | |
137 | LTTNG_EVENT_CONTEXT_IP = 12, | |
138 | LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER = 13, | |
1239a312 | 139 | LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER = 14, |
2001793c | 140 | LTTNG_EVENT_CONTEXT_APP_CONTEXT = 15, |
1ae5e83e JD |
141 | LTTNG_EVENT_CONTEXT_INTERRUPTIBLE = 16, |
142 | LTTNG_EVENT_CONTEXT_PREEMPTIBLE = 17, | |
143 | LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE = 18, | |
144 | LTTNG_EVENT_CONTEXT_MIGRATABLE = 19, | |
373148e9 FG |
145 | LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL = 20, |
146 | LTTNG_EVENT_CONTEXT_CALLSTACK_USER = 21, /* Supported on x86_32 and x86_64 only. */ | |
1239a312 DG |
147 | }; |
148 | ||
149 | enum lttng_event_field_type { | |
150 | LTTNG_EVENT_FIELD_OTHER = 0, | |
151 | LTTNG_EVENT_FIELD_INTEGER = 1, | |
152 | LTTNG_EVENT_FIELD_ENUM = 2, | |
153 | LTTNG_EVENT_FIELD_FLOAT = 3, | |
154 | LTTNG_EVENT_FIELD_STRING = 4, | |
155 | }; | |
156 | ||
834978fd DG |
157 | enum lttng_event_flag { |
158 | LTTNG_EVENT_FLAG_SYSCALL_32 = (1U << 0), | |
159 | LTTNG_EVENT_FLAG_SYSCALL_64 = (1U << 1), | |
160 | }; | |
161 | ||
1239a312 DG |
162 | /* |
163 | * Perf counter attributes | |
164 | * | |
165 | * The structures should be initialized to zero before use. | |
166 | */ | |
167 | #define LTTNG_PERF_EVENT_PADDING1 16 | |
168 | struct lttng_event_perf_counter_ctx { | |
169 | uint32_t type; | |
170 | uint64_t config; | |
171 | char name[LTTNG_SYMBOL_NAME_LEN]; | |
172 | ||
173 | char padding[LTTNG_PERF_EVENT_PADDING1]; | |
174 | }; | |
175 | ||
176 | /* | |
177 | * Event/channel context | |
178 | * | |
179 | * The structures should be initialized to zero before use. | |
180 | */ | |
181 | #define LTTNG_EVENT_CONTEXT_PADDING1 16 | |
182 | #define LTTNG_EVENT_CONTEXT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32 | |
183 | struct lttng_event_context { | |
184 | enum lttng_event_context_type ctx; | |
185 | char padding[LTTNG_EVENT_CONTEXT_PADDING1]; | |
186 | ||
187 | union { | |
188 | struct lttng_event_perf_counter_ctx perf_counter; | |
2001793c JG |
189 | struct { |
190 | char *provider_name; | |
191 | char *ctx_name; | |
192 | } app_ctx; | |
1239a312 DG |
193 | char padding[LTTNG_EVENT_CONTEXT_PADDING2]; |
194 | } u; | |
195 | }; | |
196 | ||
197 | /* | |
198 | * Event probe. | |
199 | * | |
200 | * Either addr is used or symbol_name and offset. | |
201 | * | |
202 | * The structures should be initialized to zero before use. | |
203 | */ | |
204 | #define LTTNG_EVENT_PROBE_PADDING1 16 | |
205 | struct lttng_event_probe_attr { | |
206 | uint64_t addr; | |
207 | ||
208 | uint64_t offset; | |
209 | char symbol_name[LTTNG_SYMBOL_NAME_LEN]; | |
210 | ||
211 | char padding[LTTNG_EVENT_PROBE_PADDING1]; | |
212 | }; | |
213 | ||
214 | /* | |
215 | * Function tracer | |
216 | * | |
217 | * The structures should be initialized to zero before use. | |
218 | */ | |
219 | #define LTTNG_EVENT_FUNCTION_PADDING1 16 | |
220 | struct lttng_event_function_attr { | |
221 | char symbol_name[LTTNG_SYMBOL_NAME_LEN]; | |
222 | ||
223 | char padding[LTTNG_EVENT_FUNCTION_PADDING1]; | |
224 | }; | |
225 | ||
226 | /* | |
227 | * Generic lttng event | |
228 | * | |
229 | * The structures should be initialized to zero before use. | |
230 | */ | |
fe9ecacb | 231 | #define LTTNG_EVENT_PADDING1 12 |
1239a312 DG |
232 | #define LTTNG_EVENT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32 |
233 | struct lttng_event { | |
fe9ecacb | 234 | /* Offset 0 */ |
1239a312 | 235 | enum lttng_event_type type; |
fe9ecacb PP |
236 | |
237 | /* Offset 4 */ | |
1239a312 DG |
238 | char name[LTTNG_SYMBOL_NAME_LEN]; |
239 | ||
fe9ecacb | 240 | /* Offset 260 */ |
1239a312 | 241 | enum lttng_loglevel_type loglevel_type; |
fe9ecacb PP |
242 | |
243 | /* Offset 264 */ | |
1239a312 DG |
244 | int loglevel; |
245 | ||
fe9ecacb | 246 | /* Offset 268 */ |
1239a312 | 247 | int32_t enabled; /* Does not apply: -1 */ |
fe9ecacb PP |
248 | |
249 | /* Offset 272 */ | |
1239a312 | 250 | pid_t pid; |
fe9ecacb PP |
251 | |
252 | /* Offset 276 */ | |
1239a312 | 253 | unsigned char filter; /* filter enabled ? */ |
fe9ecacb PP |
254 | |
255 | /* Offset 277 */ | |
1239a312 DG |
256 | unsigned char exclusion; /* exclusions added ? */ |
257 | ||
fe9ecacb PP |
258 | /* Offset 278 */ |
259 | char padding2[2]; | |
260 | ||
261 | /* Offset 280 */ | |
834978fd DG |
262 | /* Event flag, from 2.6 and above. */ |
263 | enum lttng_event_flag flags; | |
264 | ||
fe9ecacb | 265 | /* Offset 284 */ |
b4e3ceb9 PP |
266 | char padding[4]; |
267 | ||
268 | /* Offset 288 */ | |
269 | union { | |
4829ae55 | 270 | uint64_t padding; |
b4e3ceb9 PP |
271 | void *ptr; |
272 | } extended; | |
1239a312 | 273 | |
fe9ecacb | 274 | /* Offset 296 */ |
1239a312 DG |
275 | /* Per event type configuration */ |
276 | union { | |
277 | struct lttng_event_probe_attr probe; | |
278 | struct lttng_event_function_attr ftrace; | |
279 | ||
280 | char padding[LTTNG_EVENT_PADDING2]; | |
281 | } attr; | |
282 | }; | |
283 | ||
284 | #define LTTNG_EVENT_FIELD_PADDING LTTNG_SYMBOL_NAME_LEN + 32 | |
285 | struct lttng_event_field { | |
286 | char field_name[LTTNG_SYMBOL_NAME_LEN]; | |
287 | enum lttng_event_field_type type; | |
288 | char padding[LTTNG_EVENT_FIELD_PADDING]; | |
289 | struct lttng_event event; | |
290 | int nowrite; | |
291 | }; | |
292 | ||
293 | /* | |
294 | * List the event(s) of a session channel. | |
295 | * | |
296 | * Both handle and channel_name CAN NOT be NULL. | |
297 | * | |
298 | * Return the size (number of entries) of the "lttng_event" array. Caller must | |
299 | * free events. On error a negative LTTng error code is returned. | |
300 | */ | |
301 | extern int lttng_list_events(struct lttng_handle *handle, | |
302 | const char *channel_name, struct lttng_event **events); | |
303 | ||
d31d3e8c | 304 | /* |
134e72ed | 305 | * Get the filter expression of a specific LTTng event. |
d31d3e8c | 306 | * |
134e72ed JG |
307 | * If the call is successful, then the filter expression's address is put |
308 | * in *filter_expression. If the event has no filter expression, | |
309 | * *filter_expression is set to NULL. The caller does NOT own | |
310 | * *filter_expression. | |
d31d3e8c PP |
311 | * |
312 | * Returns 0 on success, or a negative LTTng error code on error. | |
313 | */ | |
134e72ed | 314 | extern int lttng_event_get_filter_expression(struct lttng_event *event, |
d31d3e8c PP |
315 | const char **filter_string); |
316 | ||
f086e50e PP |
317 | /* |
318 | * Get the number of exclusion names of a specific LTTng event. | |
319 | * | |
320 | * Returns the number of exclusion names on success, or a negative | |
321 | * LTTng error code on error. | |
322 | */ | |
323 | extern int lttng_event_get_exclusion_name_count(struct lttng_event *event); | |
324 | ||
325 | /* | |
326 | * Get an LTTng event's exclusion name at a given index. | |
327 | * | |
328 | * If the call is successful, then the exclusion name string's address | |
329 | * is put in *exclusion_name. The caller does NOT own *exclusion_name. | |
330 | * | |
331 | * Returns 0 on success, or a negative LTTng error code on error. | |
332 | */ | |
333 | extern int lttng_event_get_exclusion_name(struct lttng_event *event, | |
334 | size_t index, const char **exclusion_name); | |
335 | ||
1239a312 DG |
336 | /* |
337 | * List the available tracepoints of a specific lttng domain. | |
338 | * | |
339 | * The handle CAN NOT be NULL. | |
340 | * | |
341 | * Return the size (number of entries) of the "lttng_event" array. Caller must | |
342 | * free events. On error a negative LTTng error code is returned. | |
343 | */ | |
344 | extern int lttng_list_tracepoints(struct lttng_handle *handle, | |
345 | struct lttng_event **events); | |
346 | ||
347 | /* | |
348 | * List the available tracepoints fields of a specific lttng domain. | |
349 | * | |
350 | * The handle CAN NOT be NULL. | |
351 | * | |
352 | * Return the size (number of entries) of the "lttng_event_field" array. | |
353 | * Caller must free fields. On error a negative LTTng error code is | |
354 | * returned. | |
355 | */ | |
356 | extern int lttng_list_tracepoint_fields(struct lttng_handle *handle, | |
357 | struct lttng_event_field **fields); | |
358 | ||
834978fd DG |
359 | /* |
360 | * List the available kernel syscall. | |
361 | * | |
362 | * Return the size (number of entries) of the allocated "lttng_event" array. | |
363 | * All events in will be of type syscall. Caller must free events. On error a | |
364 | * negative LTTng error code is returned. | |
365 | */ | |
366 | extern int lttng_list_syscalls(struct lttng_event **events); | |
367 | ||
1239a312 DG |
368 | /* |
369 | * Add context to event(s) for a specific channel (or for all). | |
370 | * | |
371 | * If the channel_name is NULL and they are no channel for the domain, the | |
372 | * default channel is created (channel0). The context is then added on ALL | |
373 | * channels since no name was specified. | |
374 | * | |
375 | * The event_name is ignored since adding a context to an event is not possible | |
376 | * for now. | |
377 | * | |
378 | * Return 0 on success else a negative LTTng error code. | |
379 | */ | |
380 | extern int lttng_add_context(struct lttng_handle *handle, | |
381 | struct lttng_event_context *ctx, const char *event_name, | |
382 | const char *channel_name); | |
383 | ||
384 | /* | |
385 | * Create or enable an event (or events) for a channel. | |
386 | * | |
387 | * If the event you are trying to enable does not exist, it will be created, | |
388 | * else it is enabled. If channel_name is NULL, the default channel is used | |
389 | * (channel0). | |
390 | * | |
391 | * The handle and ev params can not be NULL. | |
392 | * | |
393 | * Return 0 on success else a negative LTTng error code. | |
394 | */ | |
395 | extern int lttng_enable_event(struct lttng_handle *handle, | |
396 | struct lttng_event *ev, const char *channel_name); | |
397 | ||
398 | /* | |
399 | * Create or enable an event with a specific filter. | |
400 | * | |
401 | * If the event you are trying to enable does not exist, it will be created, | |
402 | * else it is enabled. | |
403 | * If ev is NULL, all events are enabled with that filter. | |
404 | * If channel_name is NULL, the default channel is used (channel0) and created | |
405 | * if not found. | |
406 | * If filter_expression is NULL, an event without associated filter is | |
407 | * created. | |
408 | * | |
409 | * Return 0 on success else a negative LTTng error code. | |
410 | */ | |
411 | extern int lttng_enable_event_with_filter(struct lttng_handle *handle, | |
412 | struct lttng_event *event, const char *channel_name, | |
413 | const char *filter_expression); | |
414 | ||
415 | /* | |
416 | * Create or enable an event with a filter and/or exclusions. | |
417 | * | |
418 | * If the event you are trying to enable does not exist, it will be created, | |
419 | * else it is enabled. | |
420 | * If ev is NULL, all events are enabled with the filter and exclusion options. | |
421 | * If channel_name is NULL, the default channel is used (channel0) and created | |
422 | * if not found. | |
423 | * If filter_expression is NULL, an event without associated filter is | |
424 | * created. | |
425 | * If exclusion count is zero, the event will be created without exclusions. | |
426 | * | |
427 | * Return 0 on success else a negative LTTng error code. | |
428 | */ | |
429 | extern int lttng_enable_event_with_exclusions(struct lttng_handle *handle, | |
430 | struct lttng_event *event, const char *channel_name, | |
431 | const char *filter_expression, | |
432 | int exclusion_count, char **exclusion_names); | |
433 | ||
434 | /* | |
435 | * Disable event(s) of a channel and domain. | |
436 | * | |
437 | * If name is NULL, all events are disabled. | |
438 | * If channel_name is NULL, the default channel is used (channel0). | |
439 | * | |
440 | * Return 0 on success else a negative LTTng error code. | |
441 | */ | |
442 | extern int lttng_disable_event(struct lttng_handle *handle, | |
443 | const char *name, const char *channel_name); | |
444 | ||
6e911cad MD |
445 | /* |
446 | * Disable event(s) of a channel and domain. | |
447 | * | |
448 | * Takes a struct lttng_event as parameter. | |
449 | * If channel_name is NULL, the default channel is used (channel0). | |
450 | * | |
451 | * Currently, @filter_expression must be NULL. (disabling specific | |
452 | * filter expressions not implemented) | |
453 | * Currently, only LTTNG_EVENT_ALL and LTTNG_EVENT_SYSCALL event types | |
454 | * are implemented for field @ev. | |
455 | * | |
456 | * Return 0 on success else a negative LTTng error code. | |
457 | */ | |
458 | int lttng_disable_event_ext(struct lttng_handle *handle, | |
459 | struct lttng_event *ev, const char *channel_name, | |
460 | const char *filter_expression); | |
461 | ||
1239a312 DG |
462 | #ifdef __cplusplus |
463 | } | |
464 | #endif | |
465 | ||
466 | #endif /* LTTNG_EVENT_H */ |