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
{
54 LTTNG_DOMAIN_KERNEL
= 1,
56 LTTNG_DOMAIN_UST_EXEC_NAME
= 3,
57 LTTNG_DOMAIN_UST_PID
= 4,
58 LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN
= 5,
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,
93 enum lttng_calibrate_type
{
94 LTTNG_CALIBRATE_FUNCTION
= 0,
98 enum lttng_domain_type type
;
101 char exec_name
[NAME_MAX
];
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
;
146 /* Per event type configuration */
148 struct lttng_event_probe_attr probe
;
149 struct lttng_event_function_attr ftrace
;
154 * Tracer channel attributes. For both kernel and user-space.
156 struct lttng_channel_attr
{
157 int overwrite
; /* 1: overwrite, 0: discard */
158 uint64_t subbuf_size
; /* bytes */
159 uint64_t num_subbuf
; /* power of 2 */
160 unsigned int switch_timer_interval
; /* usec */
161 unsigned int read_timer_interval
; /* usec */
162 enum lttng_event_output output
; /* splice, mmap */
166 * Channel information structure. For both kernel and user-space.
168 struct lttng_channel
{
171 struct lttng_channel_attr attr
;
174 struct lttng_calibrate
{
175 enum lttng_calibrate_type type
;
179 * Basic session information.
181 * This is an 'output data' meaning that it only comes *from* the session
182 * daemon *to* the lttng client. It's basically a 'human' representation of
183 * tracing entities (here a session).
185 struct lttng_session
{
187 /* The path where traces are written */
192 * Public LTTng control API
194 * For functions having a lttng domain type as parameter, if a bad value is
195 * given, NO default is applied and an error is returned.
197 * On success, all functions of the API return 0 or the size of the allocated
200 * On error, a negative value is returned being a specific lttng-tools error
201 * code which can be humanly interpreted with lttng_get_readable_code(err).
205 * Session daemon control
209 * Create tracing session using a name and a path where trace will be written.
211 extern int lttng_create_session(const char *name
, const char *path
);
214 * Destroy tracing session.
216 * The session will not be useable anymore, tracing will stopped for all
217 * registered trace and tracing buffers will be flushed.
219 extern int lttng_destroy_session(const char *name
);
222 * List all tracing sessions.
224 * Return the size of the "lttng_session" array. Caller must free(3).
226 extern int lttng_list_sessions(struct lttng_session
**sessions
);
229 * List registered domain(s) of a session.
231 * Return the size of the "lttng_domain" array. Caller must free(3).
233 extern int lttng_list_domains(const char *session_name
,
234 struct lttng_domain
**domains
);
237 * List channel(s) of a session.
239 * Return the size of the "lttng_channel" array. Caller must free(3).
241 extern int lttng_list_channels(struct lttng_domain
*domain
,
242 const char *session_name
, struct lttng_channel
**channels
);
245 * List event(s) of a session channel.
247 * Return the size of the "lttng_event" array. Caller must free(3).
249 extern int lttng_list_events(struct lttng_domain
*domain
,
250 const char *session_name
, const char *channel_name
,
251 struct lttng_event
**events
);
254 * List available tracepoints of domain.
256 * Return the size of the "lttng_event" array. Caller must free(3).
258 extern int lttng_list_tracepoints(struct lttng_domain
*domain
,
259 struct lttng_event
**events
);
262 * Check if a session daemon is alive.
264 extern int lttng_session_daemon_alive(void);
267 * Set tracing group for the *current* flow of execution.
269 extern int lttng_set_tracing_group(const char *name
);
272 * Set the session name of the *current* flow of execution.
274 * This is a VERY important things to do before doing any tracing actions. If
275 * it's not done, you'll get an error saying that the session is not found.
276 * It avoids the use of a session name on every API call.
278 extern void lttng_set_session_name(const char *name
);
281 * Return a human readable error message of a lttng-tools error code.
283 * Parameter MUST be a negative value or else you'll get a generic message.
285 extern const char *lttng_get_readable_code(int code
);
288 * Start tracing for *all* registered trace (kernel and user-space).
290 extern int lttng_start_tracing(const char *session_name
);
293 * Stop tracing for *all* registered trace (kernel and user-space).
295 extern int lttng_stop_tracing(const char *session_name
);
298 * Add context to event for a specific channel.
300 * If event_name is NULL, the context is applied to all event of the channel.
301 * If channel_name is NULL, a lookup of the event's channel is done.
302 * If both are NULL, the context is applied on all events of all channels.
305 extern int lttng_add_context(struct lttng_domain
*domain
,
306 struct lttng_event_context
*ctx
, const char *event_name
,
307 const char *channel_name
);
310 * Create or enable a kernel event.
312 * If the event you are trying to enable does not exist, it will be created,
313 * else it is enabled.
315 * If channel_name is NULL, the default channel is used (channel0).
317 extern int lttng_enable_event(struct lttng_domain
*domain
, struct lttng_event
*ev
,
318 const char *channel_name
);
321 * Create or enable a kernel channel.
323 * If name is NULL, the default channel is enabled (channel0).
325 extern int lttng_enable_channel(struct lttng_domain
*domain
,
326 struct lttng_channel
*chan
);
329 * Disable kernel event.
331 * If channel_name is NULL, the default channel is used (channel0).
333 extern int lttng_disable_event(struct lttng_domain
*domain
, const char *name
,
334 const char *channel_name
);
337 * Disable kernel channel.
339 * If channel_name is NULL, the default channel is disabled (channel0).
341 extern int lttng_disable_channel(struct lttng_domain
*domain
,
345 * Calibrate LTTng overhead.
347 extern int lttng_calibrate(struct lttng_domain
*domain
,
348 struct lttng_calibrate
*calibrate
);
350 #endif /* _LTTNG_H */