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