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 enum lttng_domain_type type
;
65 char exec_name
[NAME_MAX
];
70 * Instrumentation type of tracing event.
72 enum lttng_event_type
{
73 LTTNG_EVENT_TRACEPOINT
,
81 enum lttng_event_output
{
82 LTTNG_EVENT_SPLICE
= 0,
86 /* Event context possible type */
87 enum lttng_event_context_type
{
88 LTTNG_EVENT_CONTEXT_PID
= 0,
89 LTTNG_EVENT_CONTEXT_PERF_COUNTER
= 1,
90 LTTNG_EVENT_CONTEXT_COMM
= 2,
91 LTTNG_EVENT_CONTEXT_PRIO
= 3,
92 LTTNG_EVENT_CONTEXT_NICE
= 4,
93 LTTNG_EVENT_CONTEXT_VPID
= 5,
94 LTTNG_EVENT_CONTEXT_TID
= 6,
95 LTTNG_EVENT_CONTEXT_VTID
= 7,
96 LTTNG_EVENT_CONTEXT_PPID
= 8,
97 LTTNG_EVENT_CONTEXT_VPPID
= 9,
100 /* Perf counter attributes */
101 struct lttng_event_perf_counter_ctx
{
104 char name
[LTTNG_SYMBOL_NAME_LEN
];
107 /* Event/Channel context */
108 struct lttng_event_context
{
109 enum lttng_event_context_type ctx
;
111 struct lttng_event_perf_counter_ctx perf_counter
;
118 * Either addr is used or symbol_name and offset.
120 struct lttng_event_probe_attr
{
124 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
130 struct lttng_event_function_attr
{
131 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
135 * Generic lttng event
138 char name
[LTTNG_SYMBOL_NAME_LEN
];
139 enum lttng_event_type type
;
140 /* Per event type configuration */
142 struct lttng_event_probe_attr probe
;
143 struct lttng_event_function_attr ftrace
;
148 * Tracer channel attributes. For both kernel and user-space.
150 struct lttng_channel_attr
{
151 int overwrite
; /* 1: overwrite, 0: discard */
152 uint64_t subbuf_size
; /* bytes */
153 uint64_t num_subbuf
; /* power of 2 */
154 unsigned int switch_timer_interval
; /* usec */
155 unsigned int read_timer_interval
; /* usec */
156 enum lttng_event_output output
; /* splice, mmap */
160 * Channel information structure. For both kernel and user-space.
162 struct lttng_channel
{
164 struct lttng_channel_attr attr
;
168 * Basic session information.
170 * This is an 'output data' meaning that it only comes *from* the session
171 * daemon *to* the lttng client. It's basically a 'human' representation of
172 * tracing entities (here a session).
174 struct lttng_session
{
176 /* The path where traces are written */
181 * Public LTTng control API
183 * For functions having a lttng domain type as parameter, if a bad value is
184 * given, NO default is applied and an error is returned.
186 * On success, all functions of the API return 0 or the size of the allocated
189 * On error, a negative value is returned being a specific lttng-tools error
190 * code which can be humanly interpreted with lttng_get_readable_code(err).
194 * Session daemon control
198 * Create tracing session using a name and a path where trace will be written.
200 extern int lttng_create_session(const char *name
, const char *path
);
203 * Destroy tracing session.
205 * The session will not be useable anymore, tracing will stopped for all
206 * registered trace and tracing buffers will be flushed.
208 extern int lttng_destroy_session(const char *name
);
211 * List tracing sessions.
213 * Return the size of the "lttng_session" array. Caller must free(3) the
216 extern int lttng_list_sessions(struct lttng_session
**sessions
);
219 * Check if a session daemon is alive.
221 extern int lttng_session_daemon_alive(void);
224 * Set tracing group for the *current* flow of execution.
226 extern int lttng_set_tracing_group(const char *name
);
229 * Set the session name of the *current* flow of execution.
231 * This is a VERY important things to do before doing any tracing actions. If
232 * it's not done, you'll get an error saying that the session is not found.
233 * It avoids the use of a session name on every API call.
235 extern void lttng_set_session_name(const char *name
);
238 * Return a human readable error message of a lttng-tools error code.
240 * Parameter MUST be a negative value or else you'll get a generic message.
242 extern const char *lttng_get_readable_code(int code
);
245 * Start tracing for *all* registered trace (kernel and user-space).
247 extern int lttng_start_tracing(const char *session_name
);
250 * Stop tracing for *all* registered trace (kernel and user-space).
252 extern int lttng_stop_tracing(const char *session_name
);
255 * Add context to event for a specific channel.
257 * If event_name is NULL, the context is applied to all event of the channel.
258 * If channel_name is NULL, a lookup of the event's channel is done.
259 * If both are NULL, the context is applied on all events of all channels.
262 extern int lttng_add_context(struct lttng_domain
*domain
,
263 struct lttng_event_context
*ctx
, const char *event_name
,
264 const char *channel_name
);
267 * Create or enable a kernel event.
269 * If the event you are trying to enable does not exist, it will be created,
270 * else it is enabled.
272 * If channel_name is NULL, the default channel is used (channel0).
274 extern int lttng_enable_event(struct lttng_domain
*domain
, struct lttng_event
*ev
,
275 const char *channel_name
);
278 * Create or enable a kernel channel.
280 * If name is NULL, the default channel is enabled (channel0).
282 extern int lttng_enable_channel(struct lttng_domain
*domain
,
283 struct lttng_channel
*chan
);
286 * Disable kernel event.
288 * If channel_name is NULL, the default channel is used (channel0).
290 extern int lttng_disable_event(struct lttng_domain
*domain
, const char *name
,
291 const char *channel_name
);
294 * Disable kernel channel.
296 * If channel_name is NULL, the default channel is disabled (channel0).
298 extern int lttng_disable_channel(struct lttng_domain
*domain
,
302 * List kernel events.
304 * Return the size of the allocated event list. Caller must free(3) the data.
306 extern int lttng_list_events(struct lttng_domain
*domain
, char **event_list
);
308 #endif /* _LTTNG_H */