List session event loglevel for the JUL domain
[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 * LTTng consumer mode
88 */
89 enum lttng_event_output {
90 LTTNG_EVENT_SPLICE = 0,
91 LTTNG_EVENT_MMAP = 1,
92 };
93
94 /* Event context possible type */
95 enum lttng_event_context_type {
96 LTTNG_EVENT_CONTEXT_PID = 0,
97 LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1, /* Backward compat. */
98 LTTNG_EVENT_CONTEXT_PROCNAME = 2,
99 LTTNG_EVENT_CONTEXT_PRIO = 3,
100 LTTNG_EVENT_CONTEXT_NICE = 4,
101 LTTNG_EVENT_CONTEXT_VPID = 5,
102 LTTNG_EVENT_CONTEXT_TID = 6,
103 LTTNG_EVENT_CONTEXT_VTID = 7,
104 LTTNG_EVENT_CONTEXT_PPID = 8,
105 LTTNG_EVENT_CONTEXT_VPPID = 9,
106 LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10,
107 LTTNG_EVENT_CONTEXT_HOSTNAME = 11,
108 LTTNG_EVENT_CONTEXT_IP = 12,
109 LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER = 13,
110 LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER = 14,
111 };
112
113 enum lttng_event_field_type {
114 LTTNG_EVENT_FIELD_OTHER = 0,
115 LTTNG_EVENT_FIELD_INTEGER = 1,
116 LTTNG_EVENT_FIELD_ENUM = 2,
117 LTTNG_EVENT_FIELD_FLOAT = 3,
118 LTTNG_EVENT_FIELD_STRING = 4,
119 };
120
121 /*
122 * Perf counter attributes
123 *
124 * The structures should be initialized to zero before use.
125 */
126 #define LTTNG_PERF_EVENT_PADDING1 16
127 struct lttng_event_perf_counter_ctx {
128 uint32_t type;
129 uint64_t config;
130 char name[LTTNG_SYMBOL_NAME_LEN];
131
132 char padding[LTTNG_PERF_EVENT_PADDING1];
133 };
134
135 /*
136 * Event/channel context
137 *
138 * The structures should be initialized to zero before use.
139 */
140 #define LTTNG_EVENT_CONTEXT_PADDING1 16
141 #define LTTNG_EVENT_CONTEXT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
142 struct lttng_event_context {
143 enum lttng_event_context_type ctx;
144 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
145
146 union {
147 struct lttng_event_perf_counter_ctx perf_counter;
148 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
149 } u;
150 };
151
152 /*
153 * Event probe.
154 *
155 * Either addr is used or symbol_name and offset.
156 *
157 * The structures should be initialized to zero before use.
158 */
159 #define LTTNG_EVENT_PROBE_PADDING1 16
160 struct lttng_event_probe_attr {
161 uint64_t addr;
162
163 uint64_t offset;
164 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
165
166 char padding[LTTNG_EVENT_PROBE_PADDING1];
167 };
168
169 /*
170 * Function tracer
171 *
172 * The structures should be initialized to zero before use.
173 */
174 #define LTTNG_EVENT_FUNCTION_PADDING1 16
175 struct lttng_event_function_attr {
176 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
177
178 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
179 };
180
181 /*
182 * Generic lttng event
183 *
184 * The structures should be initialized to zero before use.
185 */
186 #define LTTNG_EVENT_PADDING1 14
187 #define LTTNG_EVENT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
188 struct lttng_event {
189 enum lttng_event_type type;
190 char name[LTTNG_SYMBOL_NAME_LEN];
191
192 enum lttng_loglevel_type loglevel_type;
193 int loglevel;
194
195 int32_t enabled; /* Does not apply: -1 */
196 pid_t pid;
197 unsigned char filter; /* filter enabled ? */
198 unsigned char exclusion; /* exclusions added ? */
199
200 char padding[LTTNG_EVENT_PADDING1];
201
202 /* Per event type configuration */
203 union {
204 struct lttng_event_probe_attr probe;
205 struct lttng_event_function_attr ftrace;
206
207 char padding[LTTNG_EVENT_PADDING2];
208 } attr;
209 };
210
211 #define LTTNG_EVENT_FIELD_PADDING LTTNG_SYMBOL_NAME_LEN + 32
212 struct lttng_event_field {
213 char field_name[LTTNG_SYMBOL_NAME_LEN];
214 enum lttng_event_field_type type;
215 char padding[LTTNG_EVENT_FIELD_PADDING];
216 struct lttng_event event;
217 int nowrite;
218 };
219
220 /*
221 * List the event(s) of a session channel.
222 *
223 * Both handle and channel_name CAN NOT be NULL.
224 *
225 * Return the size (number of entries) of the "lttng_event" array. Caller must
226 * free events. On error a negative LTTng error code is returned.
227 */
228 extern int lttng_list_events(struct lttng_handle *handle,
229 const char *channel_name, struct lttng_event **events);
230
231 /*
232 * List the available tracepoints of a specific lttng domain.
233 *
234 * The handle CAN NOT be NULL.
235 *
236 * Return the size (number of entries) of the "lttng_event" array. Caller must
237 * free events. On error a negative LTTng error code is returned.
238 */
239 extern int lttng_list_tracepoints(struct lttng_handle *handle,
240 struct lttng_event **events);
241
242 /*
243 * List the available tracepoints fields of a specific lttng domain.
244 *
245 * The handle CAN NOT be NULL.
246 *
247 * Return the size (number of entries) of the "lttng_event_field" array.
248 * Caller must free fields. On error a negative LTTng error code is
249 * returned.
250 */
251 extern int lttng_list_tracepoint_fields(struct lttng_handle *handle,
252 struct lttng_event_field **fields);
253
254 /*
255 * Add context to event(s) for a specific channel (or for all).
256 *
257 * If the channel_name is NULL and they are no channel for the domain, the
258 * default channel is created (channel0). The context is then added on ALL
259 * channels since no name was specified.
260 *
261 * The event_name is ignored since adding a context to an event is not possible
262 * for now.
263 *
264 * Return 0 on success else a negative LTTng error code.
265 */
266 extern int lttng_add_context(struct lttng_handle *handle,
267 struct lttng_event_context *ctx, const char *event_name,
268 const char *channel_name);
269
270 /*
271 * Create or enable an event (or events) for a channel.
272 *
273 * If the event you are trying to enable does not exist, it will be created,
274 * else it is enabled. If channel_name is NULL, the default channel is used
275 * (channel0).
276 *
277 * The handle and ev params can not be NULL.
278 *
279 * Return 0 on success else a negative LTTng error code.
280 */
281 extern int lttng_enable_event(struct lttng_handle *handle,
282 struct lttng_event *ev, const char *channel_name);
283
284 /*
285 * Create or enable an event with a specific filter.
286 *
287 * If the event you are trying to enable does not exist, it will be created,
288 * else it is enabled.
289 * If ev is NULL, all events are enabled with that filter.
290 * If channel_name is NULL, the default channel is used (channel0) and created
291 * if not found.
292 * If filter_expression is NULL, an event without associated filter is
293 * created.
294 *
295 * Return 0 on success else a negative LTTng error code.
296 */
297 extern int lttng_enable_event_with_filter(struct lttng_handle *handle,
298 struct lttng_event *event, const char *channel_name,
299 const char *filter_expression);
300
301 /*
302 * Create or enable an event with a filter and/or exclusions.
303 *
304 * If the event you are trying to enable does not exist, it will be created,
305 * else it is enabled.
306 * If ev is NULL, all events are enabled with the filter and exclusion options.
307 * If channel_name is NULL, the default channel is used (channel0) and created
308 * if not found.
309 * If filter_expression is NULL, an event without associated filter is
310 * created.
311 * If exclusion count is zero, the event will be created without exclusions.
312 *
313 * Return 0 on success else a negative LTTng error code.
314 */
315 extern int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
316 struct lttng_event *event, const char *channel_name,
317 const char *filter_expression,
318 int exclusion_count, char **exclusion_names);
319
320 /*
321 * Disable event(s) of a channel and domain.
322 *
323 * If name is NULL, all events are disabled.
324 * If channel_name is NULL, the default channel is used (channel0).
325 *
326 * Return 0 on success else a negative LTTng error code.
327 */
328 extern int lttng_disable_event(struct lttng_handle *handle,
329 const char *name, const char *channel_name);
330
331 #ifdef __cplusplus
332 }
333 #endif
334
335 #endif /* LTTNG_EVENT_H */
This page took 0.036203 seconds and 4 git commands to generate.