Add set session command to lttng cli
[lttng-tools.git] / include / lttng / lttng.h
CommitLineData
826d496d 1/*
b7384347
DG
2 * lttng.h
3 *
4 * Linux Trace Toolkit Control Library Header File
5 *
826d496d 6 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
fac6795d
DG
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program 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
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
fac6795d
DG
21 */
22
b7384347
DG
23#ifndef _LTTNG_H
24#define _LTTNG_H
fac6795d 25
f3ed775e
DG
26#include <asm/types.h>
27#include <stdint.h>
57167058
DG
28#include <limits.h>
29
b7384347
DG
30/* Default unix group name for tracing. */
31#define LTTNG_DEFAULT_TRACING_GROUP "tracing"
fac6795d 32
b7384347 33/* Environment variable to set session daemon binary path. */
5b8719f5
DG
34#define LTTNG_SESSIOND_PATH_ENV "LTTNG_SESSIOND_PATH"
35
b7384347 36/*
f3ed775e 37 * Event symbol length.
1657e9bb 38 */
f3ed775e
DG
39#define LTTNG_SYMBOL_NAME_LEN 128
40
41enum lttng_event_type {
42 LTTNG_EVENT_TRACEPOINTS,
43 LTTNG_EVENT_KPROBES,
44 LTTNG_EVENT_FUNCTION,
1657e9bb
DG
45};
46
d65106b1
DG
47/* Kernel context possible type */
48enum lttng_kernel_context_type {
49 LTTNG_KERNEL_CONTEXT_PID = 0,
50 LTTNG_KERNEL_CONTEXT_PERF_COUNTER = 1,
51 LTTNG_KERNEL_CONTEXT_COMM = 2,
52 LTTNG_KERNEL_CONTEXT_PRIO = 3,
53 LTTNG_KERNEL_CONTEXT_NICE = 4,
54 LTTNG_KERNEL_CONTEXT_VPID = 5,
55 LTTNG_KERNEL_CONTEXT_TID = 6,
56 LTTNG_KERNEL_CONTEXT_VTID = 7,
57 LTTNG_KERNEL_CONTEXT_PPID = 8,
58 LTTNG_KERNEL_CONTEXT_VPPID = 9,
59};
60
61/* Perf counter attributes */
62struct lttng_kernel_perf_counter_ctx {
63 uint32_t type;
64 uint64_t config;
65 char name[LTTNG_SYMBOL_NAME_LEN];
66};
67
68/* Event/Channel context */
69struct lttng_kernel_context {
70 enum lttng_kernel_context_type ctx;
71 union {
72 struct lttng_kernel_perf_counter_ctx perf_counter;
73 } u;
74};
75
b9f1dd69
JD
76/*
77 * LTTng consumer mode
78 */
79enum lttng_kernel_output {
80 LTTNG_KERNEL_SPLICE = 0,
81 LTTNG_KERNEL_MMAP = 1,
82};
83
b7384347 84/*
f3ed775e 85 * Either addr is used or symbol_name and offset.
57167058 86 */
f3ed775e
DG
87struct lttng_event_kprobe_attr {
88 uint64_t addr;
89
90 uint64_t offset;
91 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
57167058
DG
92};
93
b7384347 94/*
f3ed775e
DG
95 * Function tracer
96 */
97struct lttng_event_function_attr {
98 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
99};
100
101/*
102 * Generic lttng event
103 */
104struct lttng_event {
105 char name[LTTNG_SYMBOL_NAME_LEN];
106 enum lttng_event_type type;
107 /* Per event type configuration */
108 union {
109 struct lttng_event_kprobe_attr kprobe;
110 struct lttng_event_function_attr ftrace;
111 } attr;
112};
113
114/* Tracer channel attributes */
115struct lttng_channel_attr {
8ce37aa5
DG
116 int overwrite; /* 1: overwrite, 0: discard */
117 uint64_t subbuf_size; /* bytes */
118 uint64_t num_subbuf; /* power of 2 */
119 unsigned int switch_timer_interval; /* usec */
120 unsigned int read_timer_interval; /* usec */
121 enum lttng_kernel_output output; /* splice, mmap */
f3ed775e
DG
122};
123
124/*
125 * Basic session information.
1657e9bb 126 */
b7384347 127struct lttng_session {
1657e9bb 128 char name[NAME_MAX];
f3ed775e
DG
129 char path[PATH_MAX];
130};
131
132/* Channel information structure */
133struct lttng_channel {
134 char name[NAME_MAX];
135 struct lttng_channel_attr attr;
1657e9bb
DG
136};
137
b7384347
DG
138/*
139 * Session daemon control
140 */
b7384347 141extern int lttng_connect_sessiond(void);
f3ed775e
DG
142
143extern int lttng_create_session(char *name, char *path);
144
145extern int lttng_destroy_session(char *name);
146
87378cf5 147extern int lttng_disconnect_sessiond(void);
f3ed775e 148
b7384347 149/* Return an allocated array of lttng_session */
ca95a216 150extern int lttng_list_sessions(struct lttng_session **sessions);
f3ed775e 151
947308c4 152extern int lttng_session_daemon_alive(void);
f3ed775e 153
b7384347
DG
154/* Set tracing group for the current execution */
155extern int lttng_set_tracing_group(const char *name);
f3ed775e
DG
156
157extern void lttng_set_session_name(char *name);
158
b7384347
DG
159extern const char *lttng_get_readable_code(int code);
160
f3ed775e
DG
161extern int lttng_start_tracing(char *session_name);
162
163extern int lttng_stop_tracing(char *session_name);
164
165//extern int lttng_ust_list_traceable_apps(pid_t **pids);
166
b7384347 167/*
f3ed775e 168 * LTTng Kernel tracer control
b7384347 169 */
d65106b1
DG
170extern int lttng_kernel_add_context(struct lttng_kernel_context *ctx,
171 char *event_name, char *channel_name);
172
f3ed775e
DG
173extern int lttng_kernel_create_channel(struct lttng_channel *chan);
174
175extern int lttng_kernel_enable_event(struct lttng_event *ev, char *channel_name);
176
177extern int lttng_kernel_enable_channel(char *name);
178
179extern int lttng_kernel_disable_event(char *name, char *channel_name);
180
181extern int lttng_kernel_disable_channel(char *name);
182
183extern int lttng_kernel_list_events(char **event_list);
fac6795d 184
1df4dedd 185/*
f3ed775e 186 * LTTng User-space tracer control
1df4dedd 187 */
1df4dedd 188
b7384347 189#endif /* _LTTNG_H */
This page took 0.0453 seconds and 4 git commands to generate.