4 * Linux Trace Toolkit Control Library Header File
6 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; only
11 * version 2.1 of the License.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <asm/types.h>
27 #include <sys/types.h>
31 /* Default unix group name for tracing. */
32 #define LTTNG_DEFAULT_TRACING_GROUP "tracing"
34 /* Environment variable to set session daemon binary path. */
35 #define LTTNG_SESSIOND_PATH_ENV "LTTNG_SESSIOND_PATH"
37 /* Default trace output directory name */
38 #define LTTNG_DEFAULT_TRACE_DIR_NAME "lttng-traces"
41 * Event symbol length. Copied from LTTng kernel ABI.
43 #define LTTNG_SYMBOL_NAME_LEN 128
46 * Every lttng_event_* structure both apply to kernel event and user-space
51 * Domain type are the different possible tracers.
53 enum lttng_domain_type
{
56 LTTNG_DOMAIN_UST_EXEC_NAME
,
58 LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN
,
62 * Instrumentation type of tracing event.
64 enum lttng_event_type
{
65 LTTNG_EVENT_TRACEPOINT
,
68 LTTNG_EVENT_FUNCTION_ENTRY
,
74 enum lttng_event_output
{
75 LTTNG_EVENT_SPLICE
= 0,
79 /* Event context possible type */
80 enum lttng_event_context_type
{
81 LTTNG_EVENT_CONTEXT_PID
= 0,
82 LTTNG_EVENT_CONTEXT_PERF_COUNTER
= 1,
83 LTTNG_EVENT_CONTEXT_COMM
= 2,
84 LTTNG_EVENT_CONTEXT_PRIO
= 3,
85 LTTNG_EVENT_CONTEXT_NICE
= 4,
86 LTTNG_EVENT_CONTEXT_VPID
= 5,
87 LTTNG_EVENT_CONTEXT_TID
= 6,
88 LTTNG_EVENT_CONTEXT_VTID
= 7,
89 LTTNG_EVENT_CONTEXT_PPID
= 8,
90 LTTNG_EVENT_CONTEXT_VPPID
= 9,
94 enum lttng_domain_type type
;
97 char exec_name
[NAME_MAX
];
101 /* Perf counter attributes */
102 struct lttng_event_perf_counter_ctx
{
105 char name
[LTTNG_SYMBOL_NAME_LEN
];
108 /* Event/Channel context */
109 struct lttng_event_context
{
110 enum lttng_event_context_type ctx
;
112 struct lttng_event_perf_counter_ctx perf_counter
;
119 * Either addr is used or symbol_name and offset.
121 struct lttng_event_probe_attr
{
125 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
131 struct lttng_event_function_attr
{
132 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
136 * Generic lttng event
139 char name
[LTTNG_SYMBOL_NAME_LEN
];
140 enum lttng_event_type type
;
142 /* Per event type configuration */
144 struct lttng_event_probe_attr probe
;
145 struct lttng_event_function_attr ftrace
;
150 * Tracer channel attributes. For both kernel and user-space.
152 struct lttng_channel_attr
{
153 int overwrite
; /* 1: overwrite, 0: discard */
154 uint64_t subbuf_size
; /* bytes */
155 uint64_t num_subbuf
; /* power of 2 */
156 unsigned int switch_timer_interval
; /* usec */
157 unsigned int read_timer_interval
; /* usec */
158 enum lttng_event_output output
; /* splice, mmap */
162 * Channel information structure. For both kernel and user-space.
164 struct lttng_channel
{
167 struct lttng_channel_attr attr
;
171 * Basic session information.
173 * This is an 'output data' meaning that it only comes *from* the session
174 * daemon *to* the lttng client. It's basically a 'human' representation of
175 * tracing entities (here a session).
177 struct lttng_session
{
179 /* The path where traces are written */
184 * Public LTTng control API
186 * For functions having a lttng domain type as parameter, if a bad value is
187 * given, NO default is applied and an error is returned.
189 * On success, all functions of the API return 0 or the size of the allocated
192 * On error, a negative value is returned being a specific lttng-tools error
193 * code which can be humanly interpreted with lttng_get_readable_code(err).
197 * Session daemon control
201 * Create tracing session using a name and a path where trace will be written.
203 extern int lttng_create_session(const char *name
, const char *path
);
206 * Destroy tracing session.
208 * The session will not be useable anymore, tracing will stopped for all
209 * registered trace and tracing buffers will be flushed.
211 extern int lttng_destroy_session(const char *name
);
214 * List all tracing sessions.
216 * Return the size of the "lttng_session" array. Caller must free(3).
218 extern int lttng_list_sessions(struct lttng_session
**sessions
);
221 * List registered domain(s) of the session.
223 * Return the size of the "lttng_domain" array. Caller must free(3).
225 extern int lttng_list_domains(const char *session_name
,
226 struct lttng_domain
**domains
);
229 * List channel(s) of a session.
231 * Return the size of the "lttng_channel" array. Caller must free(3).
233 extern int lttng_list_channels(struct lttng_domain
*domain
,
234 const char *session_name
, struct lttng_channel
**channels
);
237 * List event(s) of a session channel.
239 * Return the size of the "lttng_event" array. Caller must free(3).
241 extern int lttng_list_events(struct lttng_domain
*domain
,
242 const char *session_name
, const char *channel_name
,
243 struct lttng_event
**events
);
246 * List available kernel tracing events
248 * Return the size of the "lttng_event" array. Caller must free(3).
250 extern int lttng_list_kernel_events(struct lttng_event
**events
);
253 * Check if a session daemon is alive.
255 extern int lttng_session_daemon_alive(void);
258 * Set tracing group for the *current* flow of execution.
260 extern int lttng_set_tracing_group(const char *name
);
263 * Set the session name of the *current* flow of execution.
265 * This is a VERY important things to do before doing any tracing actions. If
266 * it's not done, you'll get an error saying that the session is not found.
267 * It avoids the use of a session name on every API call.
269 extern void lttng_set_session_name(const char *name
);
272 * Return a human readable error message of a lttng-tools error code.
274 * Parameter MUST be a negative value or else you'll get a generic message.
276 extern const char *lttng_get_readable_code(int code
);
279 * Start tracing for *all* registered trace (kernel and user-space).
281 extern int lttng_start_tracing(const char *session_name
);
284 * Stop tracing for *all* registered trace (kernel and user-space).
286 extern int lttng_stop_tracing(const char *session_name
);
289 * Add context to event for a specific channel.
291 * If event_name is NULL, the context is applied to all event of the channel.
292 * If channel_name is NULL, a lookup of the event's channel is done.
293 * If both are NULL, the context is applied on all events of all channels.
296 extern int lttng_add_context(struct lttng_domain
*domain
,
297 struct lttng_event_context
*ctx
, const char *event_name
,
298 const char *channel_name
);
301 * Create or enable a kernel event.
303 * If the event you are trying to enable does not exist, it will be created,
304 * else it is enabled.
306 * If channel_name is NULL, the default channel is used (channel0).
308 extern int lttng_enable_event(struct lttng_domain
*domain
, struct lttng_event
*ev
,
309 const char *channel_name
);
312 * Create or enable a kernel channel.
314 * If name is NULL, the default channel is enabled (channel0).
316 extern int lttng_enable_channel(struct lttng_domain
*domain
,
317 struct lttng_channel
*chan
);
320 * Disable kernel event.
322 * If channel_name is NULL, the default channel is used (channel0).
324 extern int lttng_disable_event(struct lttng_domain
*domain
, const char *name
,
325 const char *channel_name
);
328 * Disable kernel channel.
330 * If channel_name is NULL, the default channel is disabled (channel0).
332 extern int lttng_disable_channel(struct lttng_domain
*domain
,
336 * List kernel events.
338 * Return the size of the allocated event list. Caller must free(3) the data.
340 //extern int lttng_list_events(struct lttng_domain *domain, char **event_list);
342 #endif /* _LTTNG_H */