Typo: occured -> occurred
[lttng-tools.git] / include / lttng / session.h
CommitLineData
1239a312
DG
1/*
2 * Copyright (C) 2014 - David Goulet <dgoulet@efficios.com>
3e3665b8 3 * Copyright (C) 2019 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
1239a312
DG
4 *
5 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License, version 2.1 only,
7 * as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef LTTNG_SESSION_H
20#define LTTNG_SESSION_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
b178f53e 26struct lttng_session_descriptor;
3e3665b8 27struct lttng_destruction_handle;
b178f53e 28
1239a312
DG
29/*
30 * Basic session information.
31 *
32 * The "enabled" field is only used when listing the sessions which indicate if
33 * it's started or not.
34 *
35 * The structures should be initialized to zero before use.
36 */
e9af56b3 37#define LTTNG_SESSION_PADDING1 8
1239a312 38struct lttng_session {
36d2e35d 39 char name[LTTNG_NAME_MAX];
beede00c
JG
40 /*
41 * Human-readable representation of the trace's destination.
42 * In the case of a local tracing session, a path is provided:
43 * /path/to/the/output
44 *
45 * In the case of a remote (network) tracing session, the string has
46 * the following format:
47 * net://hostname/path:ctrl_port [data: data_port]
48 */
1239a312
DG
49 char path[PATH_MAX];
50 uint32_t enabled; /* enabled/started: 1, disabled/stopped: 0 */
51 uint32_t snapshot_mode;
52 unsigned int live_timer_interval; /* usec */
53
e9af56b3
JG
54 /*
55 * End of public attributes.
56 * The remaining fields are used to deal with ABI management concerns.
57 */
58
59 /*
60 * 32-bit architectures are already naturally aligned on 4 bytes after
61 * 'live_timer_interval'. However, the offset does not result in a
62 * natural alignment on 64-bit architectures. Adding 4 bytes of
63 * padding here results in an aligned offset after 'alignement_padding'
64 * for both bitnesses.
65 *
66 * This was added since not all compilers appear to align unions in the
67 * same way. Some (e.g. MSVC) do not seem to impose an alignement
68 * constraint while others (e.g. gcc, clang, icc) seem to align it to
69 * ensure 'ptr' is naturally aligned.
70 */
71 char alignment_padding[4];
b178f53e 72 union {
e9af56b3
JG
73 /*
74 * Ensure the 'extended' union has the same size for both
75 * 32-bit and 64-bit builds.
76 */
b178f53e
JG
77 char padding[LTTNG_SESSION_PADDING1];
78 void *ptr;
79 } extended;
1239a312
DG
80};
81
b178f53e
JG
82/*
83 * Create a session on the session daemon from a session descriptor.
84 *
85 * See the session descriptor API description in session-descriptor.h
86 *
87 * Note that unspecified session descriptor parameters, such as a session's
88 * name, are updated in the session descriptor if the creation of the session
89 * succeeds. This allows users to query the session's auto-generated name
90 * after its creation. Note that other attributes can be queried using the
91 * session listing API.
92 *
93 * Returns LTTNG_OK on success. See lttng-error.h for the meaning of the other
94 * return codes.
95 */
96extern enum lttng_error_code lttng_create_session_ext(
97 struct lttng_session_descriptor *session_descriptor);
98
1239a312
DG
99/*
100 * Create a tracing session using a name and an optional URL.
101 *
102 * If _url_ is NULL, no consumer is created for the session. The name can't be
103 * NULL here.
104 *
105 * Return 0 on success else a negative LTTng error code.
106 */
107extern int lttng_create_session(const char *name, const char *url);
108
109/*
110 * Create a tracing session that will exclusively be used for snapshot meaning
111 * the session will be in no output mode and every channel enabled for that
112 * session will be set in overwrite mode and in mmap output since splice is not
113 * supported.
114 *
115 * Name can't be NULL. If an url is given, it will be used to create a default
116 * snapshot output using it as a destination. If NULL, no output will be
117 * defined and an add-output call will be needed.
118 *
119 * Return 0 on success else a negative LTTng error code.
120 */
121extern int lttng_create_session_snapshot(const char *name,
122 const char *snapshot_url);
123
124/*
125 * Create a session exclusively used for live reading.
126 *
127 * In this mode, the switch-timer parameter is forced for each UST channel, a
128 * live-switch-timer is enabled for kernel channels, manually setting
129 * switch-timer is forbidden. Synchronization beacons are sent to the relayd,
130 * indexes are sent and metadata is checked for each packet.
131 *
132 * Name can't be NULL. If no URL is given, the default is to send the data to
1aacaae2 133 * net://127.0.0.1. The timer_interval is in usec.
1239a312
DG
134 *
135 * Return 0 on success else a negative LTTng error code.
136 */
137extern int lttng_create_session_live(const char *name, const char *url,
138 unsigned int timer_interval);
139
140/*
141 * Destroy a tracing session.
142 *
143 * The session will not be usable, tracing will be stopped thus buffers will be
144 * flushed.
145 *
e20ee7c2
JD
146 * This call will wait for data availability for each domain of the session,
147 * which can take an arbitrary amount of time. However, when returning the
148 * tracing data is guaranteed to be ready to be read and analyzed.
149 *
150 * lttng_destroy_session_no_wait() may be used if such a guarantee is not
151 * needed.
152 *
1239a312
DG
153 * The name can't be NULL here.
154 *
780d4bb8 155 * Return 0 on success else a negative LTTng error code.
1239a312
DG
156 */
157extern int lttng_destroy_session(const char *name);
158
3e3665b8
JG
159/*
160 * Destroy a tracing session.
161 *
162 * Performs the same function as lttng_destroy_session(), but provides
163 * an lttng_destruction_handle which can be used to wait for the completion
164 * of the session's destruction. The lttng_destroy_handle can also be used
165 * obtain the status and archive location of any implicit session
83ed9e90 166 * rotation that may have occurred during the session's destruction.
3e3665b8
JG
167 *
168 * Returns LTTNG_OK on success. The returned handle is owned by the caller
169 * and must be free'd using lttng_destruction_handle_destroy().
170 */
171extern enum lttng_error_code lttng_destroy_session_ext(const char *session_name,
172 struct lttng_destruction_handle **handle);
173
e20ee7c2
JD
174/*
175 * Behaves exactly like lttng_destroy_session but does not wait for data
176 * availability.
177 */
178extern int lttng_destroy_session_no_wait(const char *name);
179
1239a312
DG
180/*
181 * List all the tracing sessions.
182 *
b178f53e
JG
183 * Return the number of entries of the "lttng_session" array. The caller
184 * must free the returned sessions array directly using free().
185 *
186 * On error, a negative LTTng error code is returned.
1239a312
DG
187 */
188extern int lttng_list_sessions(struct lttng_session **sessions);
189
b178f53e
JG
190/*
191 * Get the creation time of an lttng_session object on the session daemon.
192 *
193 * This function must only be used with lttng_session objects returned
194 * by lttng_list_sessions() or lttng_session_create().
195 *
196 * The creation time returned is a UNIX timestamp; the number of seconds since
197 * Epoch (1970-01-01 00:00:00 +0000 (UTC)).
198 *
199 * Returns LTTNG_OK on success. See lttng-error.h for the meaning of the other
200 * return codes.
201 */
202extern enum lttng_error_code lttng_session_get_creation_time(
203 const struct lttng_session *session, uint64_t *creation_time);
204
d7ba1388
MD
205/*
206 * Set the shared memory path for a session.
207 *
208 * Sets the (optional) file system path where shared memory buffers will
209 * be created for the session. This is useful for buffer extraction on
210 * crash, when used with filesystems like pramfs.
211 *
212 * Return 0 on success else a negative LTTng error code.
213 */
214extern int lttng_set_session_shm_path(const char *session_name,
215 const char *shm_path);
216
ccf10263
MD
217/*
218 * Add PID to session tracker.
219 *
220 * A pid argument >= 0 adds the PID to the session tracker.
221 * A pid argument of -1 means "track all PIDs".
222 *
223 * Return 0 on success else a negative LTTng error code.
224 */
225extern int lttng_track_pid(struct lttng_handle *handle, int pid);
226
227/*
228 * Remove PID from session tracker.
229 *
230 * A pid argument >= 0 removes the PID from the session tracker.
231 * A pid argument of -1 means "untrack all PIDs".
232 *
233 * Return 0 on success else a negative LTTng error code.
234 */
235extern int lttng_untrack_pid(struct lttng_handle *handle, int pid);
236
a5dfbb9d
MD
237/*
238 * List PIDs in the tracker.
239 *
36dc4128
JG
240 * enabled is set to whether the PID tracker is enabled.
241 * pids is set to an allocated array of PIDs currently tracked. On
242 * success, pids must be freed by the caller.
243 * nr_pids is set to the number of entries contained by the pids array.
a5dfbb9d
MD
244 *
245 * Returns 0 on success, else a negative LTTng error code.
246 */
247extern int lttng_list_tracker_pids(struct lttng_handle *handle,
248 int *enabled, int32_t **pids, size_t *nr_pids);
249
1239a312
DG
250#ifdef __cplusplus
251}
252#endif
253
254#endif /* LTTNG_SESSION_H */
This page took 0.062821 seconds and 4 git commands to generate.