Implement ustctl_tracepoint_list/list_get
[lttng-ust.git] / liblttng-ust-ctl / ustctl.c
1 /*
2 * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; only version 2
8 * of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 #include <string.h>
21 #include <lttng/ust-ctl.h>
22 #include <lttng/ust-abi.h>
23 #include <lttng/usterr-signal-safe.h>
24 #include <lttng/ust-comm.h>
25 #include <lttng/ust-events.h>
26 #include <sys/mman.h>
27
28 #include "../libringbuffer/backend.h"
29 #include "../libringbuffer/frontend.h"
30
31 volatile enum ust_loglevel ust_loglevel;
32
33 static
34 void init_object(struct lttng_ust_object_data *data)
35 {
36 data->handle = -1;
37 data->shm_fd = -1;
38 data->wait_fd = -1;
39 data->memory_map_size = 0;
40 }
41
42 void ustctl_release_object(int sock, struct lttng_ust_object_data *data)
43 {
44 struct ustcomm_ust_msg lum;
45 struct ustcomm_ust_reply lur;
46 int ret;
47
48 if (data->shm_fd >= 0)
49 close(data->shm_fd);
50 if (data->wait_fd >= 0)
51 close(data->wait_fd);
52 memset(&lum, 0, sizeof(lum));
53 lum.handle = data->handle;
54 lum.cmd = LTTNG_UST_RELEASE;
55 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
56 assert(!ret);
57 free(data);
58 }
59
60 /*
61 * Send registration done packet to the application.
62 */
63 int ustctl_register_done(int sock)
64 {
65 struct ustcomm_ust_msg lum;
66 struct ustcomm_ust_reply lur;
67 int ret;
68
69 DBG("Sending register done command to %d", sock);
70 memset(&lum, 0, sizeof(lum));
71 lum.handle = LTTNG_UST_ROOT_HANDLE;
72 lum.cmd = LTTNG_UST_REGISTER_DONE;
73 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
74 if (ret)
75 return ret;
76 if (lur.ret_code != USTCOMM_OK) {
77 DBG("Return code: %s", ustcomm_get_readable_code(lur.ret_code));
78 goto error;
79 }
80 return 0;
81
82 error:
83 return -1;
84 }
85
86 /*
87 * returns session handle.
88 */
89 int ustctl_create_session(int sock)
90 {
91 struct ustcomm_ust_msg lum;
92 struct ustcomm_ust_reply lur;
93 int ret, session_handle;
94
95 /* Create session */
96 memset(&lum, 0, sizeof(lum));
97 lum.handle = LTTNG_UST_ROOT_HANDLE;
98 lum.cmd = LTTNG_UST_SESSION;
99 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
100 if (ret)
101 return ret;
102 session_handle = lur.ret_val;
103 DBG("received session handle %u", session_handle);
104 return session_handle;
105 }
106
107 /* open the metadata global channel */
108 int ustctl_open_metadata(int sock, int session_handle,
109 struct lttng_ust_channel_attr *chops,
110 struct lttng_ust_object_data **_metadata_data)
111 {
112 struct ustcomm_ust_msg lum;
113 struct ustcomm_ust_reply lur;
114 struct lttng_ust_object_data *metadata_data;
115 int ret;
116
117 metadata_data = malloc(sizeof(*metadata_data));
118 if (!metadata_data)
119 return -ENOMEM;
120 init_object(metadata_data);
121 /* Create metadata channel */
122 memset(&lum, 0, sizeof(lum));
123 lum.handle = session_handle;
124 lum.cmd = LTTNG_UST_METADATA;
125 lum.u.channel.overwrite = chops->overwrite;
126 lum.u.channel.subbuf_size = chops->subbuf_size;
127 lum.u.channel.num_subbuf = chops->num_subbuf;
128 lum.u.channel.switch_timer_interval = chops->switch_timer_interval;
129 lum.u.channel.read_timer_interval = chops->read_timer_interval;
130 lum.u.channel.output = chops->output;
131 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
132 if (ret) {
133 free(metadata_data);
134 return ret;
135 }
136 if (lur.ret_code != USTCOMM_OK) {
137 free(metadata_data);
138 return lur.ret_code;
139 }
140 metadata_data->handle = lur.ret_val;
141 DBG("received metadata handle %u", metadata_data->handle);
142 metadata_data->memory_map_size = lur.u.channel.memory_map_size;
143 /* get shm fd */
144 ret = ustcomm_recv_fd(sock);
145 if (ret < 0)
146 goto error;
147 metadata_data->shm_fd = ret;
148 /* get wait fd */
149 ret = ustcomm_recv_fd(sock);
150 if (ret < 0)
151 goto error;
152 metadata_data->wait_fd = ret;
153 *_metadata_data = metadata_data;
154 return 0;
155
156 error:
157 ustctl_release_object(sock, metadata_data);
158 return -EINVAL;
159 }
160
161 int ustctl_create_channel(int sock, int session_handle,
162 struct lttng_ust_channel_attr *chops,
163 struct lttng_ust_object_data **_channel_data)
164 {
165 struct ustcomm_ust_msg lum;
166 struct ustcomm_ust_reply lur;
167 struct lttng_ust_object_data *channel_data;
168 int ret;
169
170 channel_data = malloc(sizeof(*channel_data));
171 if (!channel_data)
172 return -ENOMEM;
173 init_object(channel_data);
174 /* Create metadata channel */
175 memset(&lum, 0, sizeof(lum));
176 lum.handle = session_handle;
177 lum.cmd = LTTNG_UST_CHANNEL;
178 lum.u.channel.overwrite = chops->overwrite;
179 lum.u.channel.subbuf_size = chops->subbuf_size;
180 lum.u.channel.num_subbuf = chops->num_subbuf;
181 lum.u.channel.switch_timer_interval = chops->switch_timer_interval;
182 lum.u.channel.read_timer_interval = chops->read_timer_interval;
183 lum.u.channel.output = chops->output;
184 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
185 if (ret) {
186 free(channel_data);
187 return ret;
188 }
189 if (lur.ret_code != USTCOMM_OK) {
190 free(channel_data);
191 return lur.ret_code;
192 }
193 channel_data->handle = lur.ret_val;
194 DBG("received channel handle %u", channel_data->handle);
195 channel_data->memory_map_size = lur.u.channel.memory_map_size;
196 /* get shm fd */
197 ret = ustcomm_recv_fd(sock);
198 if (ret < 0)
199 goto error;
200 channel_data->shm_fd = ret;
201 /* get wait fd */
202 ret = ustcomm_recv_fd(sock);
203 if (ret < 0)
204 goto error;
205 channel_data->wait_fd = ret;
206 *_channel_data = channel_data;
207 return 0;
208
209 error:
210 ustctl_release_object(sock, channel_data);
211 return -EINVAL;
212 }
213
214 /*
215 * Return -ENOENT if no more stream is available for creation.
216 * Return 0 on success.
217 * Return negative error value on error.
218 */
219 int ustctl_create_stream(int sock, struct lttng_ust_object_data *channel_data,
220 struct lttng_ust_object_data **_stream_data)
221 {
222 struct ustcomm_ust_msg lum;
223 struct ustcomm_ust_reply lur;
224 struct lttng_ust_object_data *stream_data;
225 int ret, fd;
226
227 stream_data = malloc(sizeof(*stream_data));
228 if (!stream_data)
229 return -ENOMEM;
230 init_object(stream_data);
231 memset(&lum, 0, sizeof(lum));
232 lum.handle = channel_data->handle;
233 lum.cmd = LTTNG_UST_STREAM;
234 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
235 if (ret) {
236 free(stream_data);
237 return ret;
238 }
239 if (lur.ret_code != USTCOMM_OK) {
240 free(stream_data);
241 return lur.ret_code;
242 }
243
244 stream_data->handle = lur.ret_val;
245 DBG("received stream handle %u", stream_data->handle);
246 stream_data->memory_map_size = lur.u.stream.memory_map_size;
247 /* get shm fd */
248 fd = ustcomm_recv_fd(sock);
249 if (fd < 0)
250 goto error;
251 stream_data->shm_fd = fd;
252 /* get wait fd */
253 fd = ustcomm_recv_fd(sock);
254 if (fd < 0)
255 goto error;
256 stream_data->wait_fd = fd;
257 *_stream_data = stream_data;
258 return ret;
259
260 error:
261 ustctl_release_object(sock, stream_data);
262 return -EINVAL;
263 }
264
265 int ustctl_create_event(int sock, struct lttng_ust_event *ev,
266 struct lttng_ust_object_data *channel_data,
267 struct lttng_ust_object_data **_event_data)
268 {
269 struct ustcomm_ust_msg lum;
270 struct ustcomm_ust_reply lur;
271 struct lttng_ust_object_data *event_data;
272 int ret;
273
274 event_data = malloc(sizeof(*event_data));
275 if (!event_data)
276 return -ENOMEM;
277 init_object(event_data);
278 memset(&lum, 0, sizeof(lum));
279 lum.handle = channel_data->handle;
280 lum.cmd = LTTNG_UST_EVENT;
281 strncpy(lum.u.event.name, ev->name,
282 LTTNG_UST_SYM_NAME_LEN);
283 lum.u.event.instrumentation = ev->instrumentation;
284 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
285 if (ret) {
286 free(event_data);
287 return ret;
288 }
289 event_data->handle = lur.ret_val;
290 DBG("received event handle %u", event_data->handle);
291 *_event_data = event_data;
292 return 0;
293 }
294
295 int ustctl_add_context(int sock, struct lttng_ust_context *ctx,
296 struct lttng_ust_object_data *obj_data,
297 struct lttng_ust_object_data **_context_data)
298 {
299 struct ustcomm_ust_msg lum;
300 struct ustcomm_ust_reply lur;
301 struct lttng_ust_object_data *context_data;
302 int ret;
303
304 context_data = malloc(sizeof(*context_data));
305 if (!context_data)
306 return -ENOMEM;
307 init_object(context_data);
308 memset(&lum, 0, sizeof(lum));
309 lum.handle = obj_data->handle;
310 lum.cmd = LTTNG_UST_CONTEXT;
311 lum.u.context.ctx = ctx->ctx;
312 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
313 if (ret) {
314 free(context_data);
315 return ret;
316 }
317 context_data->handle = lur.ret_val;
318 DBG("received context handle %u", context_data->handle);
319 *_context_data = context_data;
320 return ret;
321 }
322
323 /* Enable event, channel and session ioctl */
324 int ustctl_enable(int sock, struct lttng_ust_object_data *object)
325 {
326 struct ustcomm_ust_msg lum;
327 struct ustcomm_ust_reply lur;
328 int ret;
329
330 memset(&lum, 0, sizeof(lum));
331 lum.handle = object->handle;
332 lum.cmd = LTTNG_UST_ENABLE;
333 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
334 if (ret)
335 return ret;
336 DBG("enabled handle %u", object->handle);
337 return 0;
338 }
339
340 /* Disable event, channel and session ioctl */
341 int ustctl_disable(int sock, struct lttng_ust_object_data *object)
342 {
343 struct ustcomm_ust_msg lum;
344 struct ustcomm_ust_reply lur;
345 int ret;
346
347 memset(&lum, 0, sizeof(lum));
348 lum.handle = object->handle;
349 lum.cmd = LTTNG_UST_DISABLE;
350 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
351 if (ret)
352 return ret;
353 DBG("disable handle %u", object->handle);
354 return 0;
355 }
356
357 int ustctl_start_session(int sock, int handle)
358 {
359 struct lttng_ust_object_data obj;
360
361 obj.handle = handle;
362 return ustctl_enable(sock, &obj);
363 }
364
365 int ustctl_stop_session(int sock, int handle)
366 {
367 struct lttng_ust_object_data obj;
368
369 obj.handle = handle;
370 return ustctl_disable(sock, &obj);
371 }
372
373 int ustctl_tracepoint_list(int sock)
374 {
375 struct ustcomm_ust_msg lum;
376 struct ustcomm_ust_reply lur;
377 int ret, tp_list_handle;
378
379 memset(&lum, 0, sizeof(lum));
380 lum.handle = LTTNG_UST_ROOT_HANDLE;
381 lum.cmd = LTTNG_UST_TRACEPOINT_LIST;
382 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
383 if (ret)
384 return ret;
385 tp_list_handle = lur.ret_val;
386 DBG("received tracepoint list handle %u", tp_list_handle);
387 return tp_list_handle;
388 }
389
390 int ustctl_tracepoint_list_get(int sock, int tp_list_handle,
391 char iter[LTTNG_UST_SYM_NAME_LEN])
392 {
393 struct ustcomm_ust_msg lum;
394 struct ustcomm_ust_reply lur;
395 int ret;
396
397 memset(&lum, 0, sizeof(lum));
398 lum.handle = tp_list_handle;
399 lum.cmd = LTTNG_UST_TRACEPOINT_LIST_GET;
400 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
401 if (ret)
402 return ret;
403 DBG("received tracepoint list entry %s", lur.u.tracepoint_list_entry);
404 memcpy(iter, lur.u.tracepoint_list_entry, LTTNG_UST_SYM_NAME_LEN);
405 return 0;
406 }
407
408 int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v)
409 {
410 struct ustcomm_ust_msg lum;
411 struct ustcomm_ust_reply lur;
412 int ret;
413
414 memset(&lum, 0, sizeof(lum));
415 lum.handle = LTTNG_UST_ROOT_HANDLE;
416 lum.cmd = LTTNG_UST_TRACER_VERSION;
417 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
418 if (ret)
419 return ret;
420 memcpy(v, &lur.u.version, sizeof(*v));
421 DBG("received tracer version");
422 return 0;
423 }
424
425 int ustctl_wait_quiescent(int sock)
426 {
427 struct ustcomm_ust_msg lum;
428 struct ustcomm_ust_reply lur;
429 int ret;
430
431 memset(&lum, 0, sizeof(lum));
432 lum.handle = LTTNG_UST_ROOT_HANDLE;
433 lum.cmd = LTTNG_UST_WAIT_QUIESCENT;
434 ret = ustcomm_send_app_cmd(sock, &lum, &lur);
435 if (ret)
436 return ret;
437 DBG("waited for quiescent state");
438 return 0;
439 }
440
441 int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate)
442 {
443 return -ENOSYS;
444 }
445
446 /* Buffer operations */
447
448 /* Map channel shm into process memory */
449 struct lttng_ust_shm_handle *ustctl_map_channel(struct lttng_ust_object_data *chan_data)
450 {
451 struct lttng_ust_shm_handle *handle;
452 struct channel *chan;
453 size_t chan_size;
454 struct lttng_ust_lib_ring_buffer_config *config;
455 int ret;
456
457 handle = channel_handle_create(chan_data->shm_fd,
458 chan_data->wait_fd,
459 chan_data->memory_map_size);
460 if (!handle) {
461 ERR("create handle error");
462 return NULL;
463 }
464 /*
465 * Set to -1 because the lttng_ust_shm_handle destruction will take care
466 * of closing shm_fd and wait_fd.
467 */
468 chan_data->shm_fd = -1;
469 chan_data->wait_fd = -1;
470
471 /*
472 * TODO: add consistency checks to be resilient if the
473 * application try to feed us with incoherent channel structure
474 * values.
475 */
476 chan = shmp(handle, handle->chan);
477 /* chan is object 0. This is hardcoded. */
478 chan_size = handle->table->objects[0].allocated_len;
479 handle->shadow_chan = malloc(chan_size);
480 if (!handle->shadow_chan) {
481 channel_destroy(chan, handle, 1);
482 return NULL;
483 }
484 memcpy(handle->shadow_chan, chan, chan_size);
485 /*
486 * The callback pointers in the producer are invalid in the
487 * consumer. We need to look them up here.
488 */
489 config = &handle->shadow_chan->backend.config;
490 switch (config->client_type) {
491 case LTTNG_CLIENT_METADATA:
492 memcpy(&config->cb, lttng_client_callbacks_metadata,
493 sizeof(config->cb));
494 break;
495 case LTTNG_CLIENT_DISCARD:
496 memcpy(&config->cb, lttng_client_callbacks_discard,
497 sizeof(config->cb));
498 break;
499 case LTTNG_CLIENT_OVERWRITE:
500 memcpy(&config->cb, lttng_client_callbacks_overwrite,
501 sizeof(config->cb));
502 break;
503 default:
504 ERR("Unknown client type %d", config->client_type);
505 channel_destroy(chan, handle, 1);
506 return NULL;
507 }
508 /* Replace the object table pointer. */
509 ret = munmap(handle->table->objects[0].memory_map,
510 handle->table->objects[0].memory_map_size);
511 if (ret) {
512 perror("munmap");
513 assert(0);
514 }
515 handle->table->objects[0].memory_map = (char *) handle->shadow_chan;
516 handle->table->objects[0].is_shadow = 1;
517 return handle;
518 }
519
520 /* Add stream to channel shm and map its shm into process memory */
521 int ustctl_add_stream(struct lttng_ust_shm_handle *handle,
522 struct lttng_ust_object_data *stream_data)
523 {
524 int ret;
525
526 if (!stream_data->handle)
527 return -ENOENT;
528 /* map stream */
529 ret = channel_handle_add_stream(handle,
530 stream_data->shm_fd,
531 stream_data->wait_fd,
532 stream_data->memory_map_size);
533 if (ret) {
534 ERR("add stream error\n");
535 return ret;
536 }
537 /*
538 * Set to -1 because the lttng_ust_shm_handle destruction will take care
539 * of closing shm_fd and wait_fd.
540 */
541 stream_data->shm_fd = -1;
542 stream_data->wait_fd = -1;
543 return 0;
544 }
545
546 void ustctl_unmap_channel(struct lttng_ust_shm_handle *handle)
547 {
548 struct channel *chan;
549
550 chan = shmp(handle, handle->chan);
551 channel_destroy(chan, handle, 1);
552 }
553
554 struct lttng_ust_lib_ring_buffer *ustctl_open_stream_read(struct lttng_ust_shm_handle *handle,
555 int cpu)
556 {
557 struct channel *chan = handle->shadow_chan;
558 int shm_fd, wait_fd;
559 uint64_t memory_map_size;
560 struct lttng_ust_lib_ring_buffer *buf;
561 int ret;
562
563 buf = channel_get_ring_buffer(&chan->backend.config,
564 chan, cpu, handle, &shm_fd, &wait_fd, &memory_map_size);
565 if (!buf)
566 return NULL;
567 ret = lib_ring_buffer_open_read(buf, handle, 1);
568 if (ret)
569 return NULL;
570 return buf;
571 }
572
573 void ustctl_close_stream_read(struct lttng_ust_shm_handle *handle,
574 struct lttng_ust_lib_ring_buffer *buf)
575 {
576 lib_ring_buffer_release_read(buf, handle, 1);
577 }
578
579 /* For mmap mode, readable without "get" operation */
580
581 void *ustctl_get_mmap_base(struct lttng_ust_shm_handle *handle,
582 struct lttng_ust_lib_ring_buffer *buf)
583 {
584 return shmp(handle, buf->backend.memory_map);
585 }
586
587 /* returns the length to mmap. */
588 int ustctl_get_mmap_len(struct lttng_ust_shm_handle *handle,
589 struct lttng_ust_lib_ring_buffer *buf,
590 unsigned long *len)
591 {
592 unsigned long mmap_buf_len;
593 struct channel *chan = handle->shadow_chan;
594
595 if (chan->backend.config.output != RING_BUFFER_MMAP)
596 return -EINVAL;
597 mmap_buf_len = chan->backend.buf_size;
598 if (chan->backend.extra_reader_sb)
599 mmap_buf_len += chan->backend.subbuf_size;
600 if (mmap_buf_len > INT_MAX)
601 return -EFBIG;
602 *len = mmap_buf_len;
603 return 0;
604 }
605
606 /* returns the maximum size for sub-buffers. */
607 int ustctl_get_max_subbuf_size(struct lttng_ust_shm_handle *handle,
608 struct lttng_ust_lib_ring_buffer *buf,
609 unsigned long *len)
610 {
611 struct channel *chan = handle->shadow_chan;
612
613 *len = chan->backend.subbuf_size;
614 return 0;
615 }
616
617 /*
618 * For mmap mode, operate on the current packet (between get/put or
619 * get_next/put_next).
620 */
621
622 /* returns the offset of the subbuffer belonging to the mmap reader. */
623 int ustctl_get_mmap_read_offset(struct lttng_ust_shm_handle *handle,
624 struct lttng_ust_lib_ring_buffer *buf, unsigned long *off)
625 {
626 struct channel *chan = handle->shadow_chan;
627 unsigned long sb_bindex;
628
629 if (chan->backend.config.output != RING_BUFFER_MMAP)
630 return -EINVAL;
631 sb_bindex = subbuffer_id_get_index(&chan->backend.config,
632 buf->backend.buf_rsb.id);
633 *off = shmp(handle, shmp_index(handle, buf->backend.array, sb_bindex)->shmp)->mmap_offset;
634 return 0;
635 }
636
637 /* returns the size of the current sub-buffer, without padding (for mmap). */
638 int ustctl_get_subbuf_size(struct lttng_ust_shm_handle *handle,
639 struct lttng_ust_lib_ring_buffer *buf, unsigned long *len)
640 {
641 struct channel *chan = handle->shadow_chan;
642
643 *len = lib_ring_buffer_get_read_data_size(&chan->backend.config, buf,
644 handle);
645 return 0;
646 }
647
648 /* returns the size of the current sub-buffer, without padding (for mmap). */
649 int ustctl_get_padded_subbuf_size(struct lttng_ust_shm_handle *handle,
650 struct lttng_ust_lib_ring_buffer *buf, unsigned long *len)
651 {
652 struct channel *chan = handle->shadow_chan;
653
654 *len = lib_ring_buffer_get_read_data_size(&chan->backend.config, buf,
655 handle);
656 *len = PAGE_ALIGN(*len);
657 return 0;
658 }
659
660 /* Get exclusive read access to the next sub-buffer that can be read. */
661 int ustctl_get_next_subbuf(struct lttng_ust_shm_handle *handle,
662 struct lttng_ust_lib_ring_buffer *buf)
663 {
664 return lib_ring_buffer_get_next_subbuf(buf, handle);
665 }
666
667
668 /* Release exclusive sub-buffer access, move consumer forward. */
669 int ustctl_put_next_subbuf(struct lttng_ust_shm_handle *handle,
670 struct lttng_ust_lib_ring_buffer *buf)
671 {
672 lib_ring_buffer_put_next_subbuf(buf, handle);
673 return 0;
674 }
675
676 /* snapshot */
677
678 /* Get a snapshot of the current ring buffer producer and consumer positions */
679 int ustctl_snapshot(struct lttng_ust_shm_handle *handle,
680 struct lttng_ust_lib_ring_buffer *buf)
681 {
682 return lib_ring_buffer_snapshot(buf, &buf->cons_snapshot,
683 &buf->prod_snapshot, handle);
684 }
685
686 /* Get the consumer position (iteration start) */
687 int ustctl_snapshot_get_consumed(struct lttng_ust_shm_handle *handle,
688 struct lttng_ust_lib_ring_buffer *buf, unsigned long *pos)
689 {
690 *pos = buf->cons_snapshot;
691 return 0;
692 }
693
694 /* Get the producer position (iteration end) */
695 int ustctl_snapshot_get_produced(struct lttng_ust_shm_handle *handle,
696 struct lttng_ust_lib_ring_buffer *buf, unsigned long *pos)
697 {
698 *pos = buf->prod_snapshot;
699 return 0;
700 }
701
702 /* Get exclusive read access to the specified sub-buffer position */
703 int ustctl_get_subbuf(struct lttng_ust_shm_handle *handle,
704 struct lttng_ust_lib_ring_buffer *buf, unsigned long *pos)
705 {
706 return lib_ring_buffer_get_subbuf(buf, *pos, handle);
707 }
708
709 /* Release exclusive sub-buffer access */
710 int ustctl_put_subbuf(struct lttng_ust_shm_handle *handle,
711 struct lttng_ust_lib_ring_buffer *buf)
712 {
713 lib_ring_buffer_put_subbuf(buf, handle);
714 return 0;
715 }
716
717 void ustctl_flush_buffer(struct lttng_ust_shm_handle *handle,
718 struct lttng_ust_lib_ring_buffer *buf,
719 int producer_active)
720 {
721 lib_ring_buffer_switch_slow(buf,
722 producer_active ? SWITCH_ACTIVE : SWITCH_FLUSH,
723 handle);
724 }
This page took 0.043878 seconds and 5 git commands to generate.