Add Python agent support
[lttng-tools.git] / include / lttng / event.h
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
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
101 /*
102 * Available loglevels for the Python domain. Those are an exact map from the
103 * Level class.
104 */
105 enum lttng_loglevel_python {
106 LTTNG_LOGLEVEL_PYTHON_CRITICAL = 50,
107 LTTNG_LOGLEVEL_PYTHON_ERROR = 40,
108 LTTNG_LOGLEVEL_PYTHON_WARNING = 30,
109 LTTNG_LOGLEVEL_PYTHON_INFO = 20,
110 LTTNG_LOGLEVEL_PYTHON_DEBUG = 10,
111 LTTNG_LOGLEVEL_PYTHON_NOTSET = 0,
112 };
113
114 /*
115 * LTTng consumer mode
116 */
117 enum lttng_event_output {
118 LTTNG_EVENT_SPLICE = 0,
119 LTTNG_EVENT_MMAP = 1,
120 };
121
122 /* Event context possible type */
123 enum lttng_event_context_type {
124 LTTNG_EVENT_CONTEXT_PID = 0,
125 LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1, /* Backward compat. */
126 LTTNG_EVENT_CONTEXT_PROCNAME = 2,
127 LTTNG_EVENT_CONTEXT_PRIO = 3,
128 LTTNG_EVENT_CONTEXT_NICE = 4,
129 LTTNG_EVENT_CONTEXT_VPID = 5,
130 LTTNG_EVENT_CONTEXT_TID = 6,
131 LTTNG_EVENT_CONTEXT_VTID = 7,
132 LTTNG_EVENT_CONTEXT_PPID = 8,
133 LTTNG_EVENT_CONTEXT_VPPID = 9,
134 LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10,
135 LTTNG_EVENT_CONTEXT_HOSTNAME = 11,
136 LTTNG_EVENT_CONTEXT_IP = 12,
137 LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER = 13,
138 LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER = 14,
139 };
140
141 enum lttng_event_field_type {
142 LTTNG_EVENT_FIELD_OTHER = 0,
143 LTTNG_EVENT_FIELD_INTEGER = 1,
144 LTTNG_EVENT_FIELD_ENUM = 2,
145 LTTNG_EVENT_FIELD_FLOAT = 3,
146 LTTNG_EVENT_FIELD_STRING = 4,
147 };
148
149 enum lttng_event_flag {
150 LTTNG_EVENT_FLAG_SYSCALL_32 = (1U << 0),
151 LTTNG_EVENT_FLAG_SYSCALL_64 = (1U << 1),
152 };
153
154 /*
155 * Perf counter attributes
156 *
157 * The structures should be initialized to zero before use.
158 */
159 #define LTTNG_PERF_EVENT_PADDING1 16
160 struct lttng_event_perf_counter_ctx {
161 uint32_t type;
162 uint64_t config;
163 char name[LTTNG_SYMBOL_NAME_LEN];
164
165 char padding[LTTNG_PERF_EVENT_PADDING1];
166 };
167
168 /*
169 * Event/channel context
170 *
171 * The structures should be initialized to zero before use.
172 */
173 #define LTTNG_EVENT_CONTEXT_PADDING1 16
174 #define LTTNG_EVENT_CONTEXT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
175 struct lttng_event_context {
176 enum lttng_event_context_type ctx;
177 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
178
179 union {
180 struct lttng_event_perf_counter_ctx perf_counter;
181 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
182 } u;
183 };
184
185 /*
186 * Event probe.
187 *
188 * Either addr is used or symbol_name and offset.
189 *
190 * The structures should be initialized to zero before use.
191 */
192 #define LTTNG_EVENT_PROBE_PADDING1 16
193 struct lttng_event_probe_attr {
194 uint64_t addr;
195
196 uint64_t offset;
197 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
198
199 char padding[LTTNG_EVENT_PROBE_PADDING1];
200 };
201
202 /*
203 * Function tracer
204 *
205 * The structures should be initialized to zero before use.
206 */
207 #define LTTNG_EVENT_FUNCTION_PADDING1 16
208 struct lttng_event_function_attr {
209 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
210
211 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
212 };
213
214 /*
215 * Generic lttng event
216 *
217 * The structures should be initialized to zero before use.
218 */
219 #define LTTNG_EVENT_PADDING1 10
220 #define LTTNG_EVENT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
221 struct lttng_event {
222 enum lttng_event_type type;
223 char name[LTTNG_SYMBOL_NAME_LEN];
224
225 enum lttng_loglevel_type loglevel_type;
226 int loglevel;
227
228 int32_t enabled; /* Does not apply: -1 */
229 pid_t pid;
230 unsigned char filter; /* filter enabled ? */
231 unsigned char exclusion; /* exclusions added ? */
232
233 /* Event flag, from 2.6 and above. */
234 enum lttng_event_flag flags;
235
236 char padding[LTTNG_EVENT_PADDING1];
237
238 /* Per event type configuration */
239 union {
240 struct lttng_event_probe_attr probe;
241 struct lttng_event_function_attr ftrace;
242
243 char padding[LTTNG_EVENT_PADDING2];
244 } attr;
245 };
246
247 #define LTTNG_EVENT_FIELD_PADDING LTTNG_SYMBOL_NAME_LEN + 32
248 struct lttng_event_field {
249 char field_name[LTTNG_SYMBOL_NAME_LEN];
250 enum lttng_event_field_type type;
251 char padding[LTTNG_EVENT_FIELD_PADDING];
252 struct lttng_event event;
253 int nowrite;
254 };
255
256 /*
257 * List the event(s) of a session channel.
258 *
259 * Both handle and channel_name CAN NOT be NULL.
260 *
261 * Return the size (number of entries) of the "lttng_event" array. Caller must
262 * free events. On error a negative LTTng error code is returned.
263 */
264 extern int lttng_list_events(struct lttng_handle *handle,
265 const char *channel_name, struct lttng_event **events);
266
267 /*
268 * List the available tracepoints of a specific lttng domain.
269 *
270 * The handle CAN NOT be NULL.
271 *
272 * Return the size (number of entries) of the "lttng_event" array. Caller must
273 * free events. On error a negative LTTng error code is returned.
274 */
275 extern int lttng_list_tracepoints(struct lttng_handle *handle,
276 struct lttng_event **events);
277
278 /*
279 * List the available tracepoints fields of a specific lttng domain.
280 *
281 * The handle CAN NOT be NULL.
282 *
283 * Return the size (number of entries) of the "lttng_event_field" array.
284 * Caller must free fields. On error a negative LTTng error code is
285 * returned.
286 */
287 extern int lttng_list_tracepoint_fields(struct lttng_handle *handle,
288 struct lttng_event_field **fields);
289
290 /*
291 * List the available kernel syscall.
292 *
293 * Return the size (number of entries) of the allocated "lttng_event" array.
294 * All events in will be of type syscall. Caller must free events. On error a
295 * negative LTTng error code is returned.
296 */
297 extern int lttng_list_syscalls(struct lttng_event **events);
298
299 /*
300 * Add context to event(s) for a specific channel (or for all).
301 *
302 * If the channel_name is NULL and they are no channel for the domain, the
303 * default channel is created (channel0). The context is then added on ALL
304 * channels since no name was specified.
305 *
306 * The event_name is ignored since adding a context to an event is not possible
307 * for now.
308 *
309 * Return 0 on success else a negative LTTng error code.
310 */
311 extern int lttng_add_context(struct lttng_handle *handle,
312 struct lttng_event_context *ctx, const char *event_name,
313 const char *channel_name);
314
315 /*
316 * Create or enable an event (or events) for a channel.
317 *
318 * If the event you are trying to enable does not exist, it will be created,
319 * else it is enabled. If channel_name is NULL, the default channel is used
320 * (channel0).
321 *
322 * The handle and ev params can not be NULL.
323 *
324 * Return 0 on success else a negative LTTng error code.
325 */
326 extern int lttng_enable_event(struct lttng_handle *handle,
327 struct lttng_event *ev, const char *channel_name);
328
329 /*
330 * Create or enable an event with a specific filter.
331 *
332 * If the event you are trying to enable does not exist, it will be created,
333 * else it is enabled.
334 * If ev is NULL, all events are enabled with that filter.
335 * If channel_name is NULL, the default channel is used (channel0) and created
336 * if not found.
337 * If filter_expression is NULL, an event without associated filter is
338 * created.
339 *
340 * Return 0 on success else a negative LTTng error code.
341 */
342 extern int lttng_enable_event_with_filter(struct lttng_handle *handle,
343 struct lttng_event *event, const char *channel_name,
344 const char *filter_expression);
345
346 /*
347 * Create or enable an event with a filter and/or exclusions.
348 *
349 * If the event you are trying to enable does not exist, it will be created,
350 * else it is enabled.
351 * If ev is NULL, all events are enabled with the filter and exclusion options.
352 * If channel_name is NULL, the default channel is used (channel0) and created
353 * if not found.
354 * If filter_expression is NULL, an event without associated filter is
355 * created.
356 * If exclusion count is zero, the event will be created without exclusions.
357 *
358 * Return 0 on success else a negative LTTng error code.
359 */
360 extern int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
361 struct lttng_event *event, const char *channel_name,
362 const char *filter_expression,
363 int exclusion_count, char **exclusion_names);
364
365 /*
366 * Disable event(s) of a channel and domain.
367 *
368 * If name is NULL, all events are disabled.
369 * If channel_name is NULL, the default channel is used (channel0).
370 *
371 * Return 0 on success else a negative LTTng error code.
372 */
373 extern int lttng_disable_event(struct lttng_handle *handle,
374 const char *name, const char *channel_name);
375
376 /*
377 * Disable event(s) of a channel and domain.
378 *
379 * Takes a struct lttng_event as parameter.
380 * If channel_name is NULL, the default channel is used (channel0).
381 *
382 * Currently, @filter_expression must be NULL. (disabling specific
383 * filter expressions not implemented)
384 * Currently, only LTTNG_EVENT_ALL and LTTNG_EVENT_SYSCALL event types
385 * are implemented for field @ev.
386 *
387 * Return 0 on success else a negative LTTng error code.
388 */
389 int lttng_disable_event_ext(struct lttng_handle *handle,
390 struct lttng_event *ev, const char *channel_name,
391 const char *filter_expression);
392
393 #ifdef __cplusplus
394 }
395 #endif
396
397 #endif /* LTTNG_EVENT_H */
This page took 0.037256 seconds and 5 git commands to generate.