4 * Linux Trace Toolkit Control Library Header File
6 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
8 * LGPL-compatible code should include this header with :
10 * #define _LGPL_SOURCE
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; only
16 * version 2.1 of the License.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <asm/types.h>
32 #include <sys/types.h>
36 /* Default unix group name for tracing. */
37 #define LTTNG_DEFAULT_TRACING_GROUP "tracing"
39 /* Environment variable to set session daemon binary path. */
40 #define LTTNG_SESSIOND_PATH_ENV "LTTNG_SESSIOND_PATH"
42 /* Default trace output directory name */
43 #define LTTNG_DEFAULT_TRACE_DIR_NAME "lttng-traces"
46 * Event symbol length. Copied from LTTng kernel ABI.
48 #define LTTNG_SYMBOL_NAME_LEN 128
51 * Every lttng_event_* structure both apply to kernel event and user-space
56 * Domain type are the different possible tracers.
58 enum lttng_domain_type
{
61 LTTNG_DOMAIN_UST_EXEC_NAME
,
63 LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN
,
67 enum lttng_domain_type type
;
70 char exec_name
[NAME_MAX
];
75 * Instrumentation type of tracing event.
77 enum lttng_event_type
{
78 LTTNG_EVENT_TRACEPOINT
,
86 enum lttng_event_output
{
87 LTTNG_EVENT_SPLICE
= 0,
91 /* Event context possible type */
92 enum lttng_event_context_type
{
93 LTTNG_EVENT_CONTEXT_PID
= 0,
94 LTTNG_EVENT_CONTEXT_PERF_COUNTER
= 1,
95 LTTNG_EVENT_CONTEXT_COMM
= 2,
96 LTTNG_EVENT_CONTEXT_PRIO
= 3,
97 LTTNG_EVENT_CONTEXT_NICE
= 4,
98 LTTNG_EVENT_CONTEXT_VPID
= 5,
99 LTTNG_EVENT_CONTEXT_TID
= 6,
100 LTTNG_EVENT_CONTEXT_VTID
= 7,
101 LTTNG_EVENT_CONTEXT_PPID
= 8,
102 LTTNG_EVENT_CONTEXT_VPPID
= 9,
105 /* Perf counter attributes */
106 struct lttng_event_perf_counter_ctx
{
109 char name
[LTTNG_SYMBOL_NAME_LEN
];
112 /* Event/Channel context */
113 struct lttng_event_context
{
114 enum lttng_event_context_type ctx
;
116 struct lttng_event_perf_counter_ctx perf_counter
;
123 * Either addr is used or symbol_name and offset.
125 struct lttng_event_probe_attr
{
129 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
135 struct lttng_event_function_attr
{
136 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
140 * Generic lttng event
143 char name
[LTTNG_SYMBOL_NAME_LEN
];
144 enum lttng_event_type type
;
145 /* Per event type configuration */
147 struct lttng_event_probe_attr probe
;
148 struct lttng_event_function_attr ftrace
;
153 * Tracer channel attributes. For both kernel and user-space.
155 struct lttng_channel_attr
{
156 int overwrite
; /* 1: overwrite, 0: discard */
157 uint64_t subbuf_size
; /* bytes */
158 uint64_t num_subbuf
; /* power of 2 */
159 unsigned int switch_timer_interval
; /* usec */
160 unsigned int read_timer_interval
; /* usec */
161 enum lttng_event_output output
; /* splice, mmap */
165 * Channel information structure. For both kernel and user-space.
167 struct lttng_channel
{
169 struct lttng_channel_attr attr
;
173 * Basic session information.
175 * This is an 'output data' meaning that it only comes *from* the session
176 * daemon *to* the lttng client. It's basically a 'human' representation of
177 * tracing entities (here a session).
179 struct lttng_session
{
181 /* The path where traces are written */
186 * Public LTTng control API
188 * For functions having a lttng domain type as parameter, if a bad value is
189 * given, NO default is applied and an error is returned.
191 * On success, all functions of the API return 0 or the size of the allocated
194 * On error, a negative value is returned being a specific lttng-tools error
195 * code which can be humanly interpreted with lttng_get_readable_code(err).
199 * Session daemon control
203 * Create tracing session using a name and a path where trace will be written.
205 extern int lttng_create_session(const char *name
, const char *path
);
208 * Destroy tracing session.
210 * The session will not be useable anymore, tracing will stopped for all
211 * registered trace and tracing buffers will be flushed.
213 extern int lttng_destroy_session(const char *name
);
216 * List tracing sessions.
218 * Return the size of the "lttng_session" array. Caller must free(3) the
221 extern int lttng_list_sessions(struct lttng_session
**sessions
);
224 * Check if a session daemon is alive.
226 extern int lttng_session_daemon_alive(void);
229 * Set tracing group for the *current* flow of execution.
231 extern int lttng_set_tracing_group(const char *name
);
234 * Set the session name of the *current* flow of execution.
236 * This is a VERY important things to do before doing any tracing actions. If
237 * it's not done, you'll get an error saying that the session is not found.
238 * It avoids the use of a session name on every API call.
240 extern void lttng_set_session_name(const char *name
);
243 * Return a human readable error message of a lttng-tools error code.
245 * Parameter MUST be a negative value or else you'll get a generic message.
247 extern const char *lttng_get_readable_code(int code
);
250 * Start tracing for *all* registered trace (kernel and user-space).
252 extern int lttng_start_tracing(const char *session_name
);
255 * Stop tracing for *all* registered trace (kernel and user-space).
257 extern int lttng_stop_tracing(const char *session_name
);
260 * Add context to event for a specific channel.
262 * If event_name is NULL, the context is applied to all event of the channel.
263 * If channel_name is NULL, a lookup of the event's channel is done.
264 * If both are NULL, the context is applied on all events of all channels.
267 extern int lttng_add_context(struct lttng_domain
*domain
,
268 struct lttng_event_context
*ctx
, const char *event_name
,
269 const char *channel_name
);
272 * Create or enable a kernel event.
274 * If the event you are trying to enable does not exist, it will be created,
275 * else it is enabled.
277 * If channel_name is NULL, the default channel is used (channel0).
279 extern int lttng_enable_event(struct lttng_domain
*domain
, struct lttng_event
*ev
,
280 const char *channel_name
);
283 * Create or enable a kernel channel.
285 * If name is NULL, the default channel is enabled (channel0).
287 extern int lttng_enable_channel(struct lttng_domain
*domain
,
288 struct lttng_channel
*chan
);
291 * Disable kernel event.
293 * If channel_name is NULL, the default channel is used (channel0).
295 extern int lttng_disable_event(struct lttng_domain
*domain
, const char *name
,
296 const char *channel_name
);
299 * Disable kernel channel.
301 * If channel_name is NULL, the default channel is disabled (channel0).
303 extern int lttng_disable_channel(struct lttng_domain
*domain
,
307 * List kernel events.
309 * Return the size of the allocated event list. Caller must free(3) the data.
311 extern int lttng_list_events(struct lttng_domain
*domain
, char **event_list
);
313 #endif /* _LTTNG_H */