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