Health check: implement health check query in sessiond and consumerd
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
1 /*
2 * liblttngctl.c
3 *
4 * Linux Trace Toolkit Control Library
5 *
6 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
7 *
8 * This library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License, version 2.1 only,
10 * as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #define _GNU_SOURCE
23 #include <assert.h>
24 #include <grp.h>
25 #include <errno.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <unistd.h>
30
31 #include <common/common.h>
32 #include <common/defaults.h>
33 #include <common/sessiond-comm/sessiond-comm.h>
34 #include <common/uri.h>
35 #include <common/utils.h>
36 #include <lttng/lttng.h>
37 #include <lttng/health-internal.h>
38
39 #include "filter/filter-ast.h"
40 #include "filter/filter-parser.h"
41 #include "filter/filter-bytecode.h"
42 #include "filter/memstream.h"
43 #include "lttng-ctl-helper.h"
44
45 #ifdef DEBUG
46 static const int print_xml = 1;
47 #define dbg_printf(fmt, args...) \
48 printf("[debug liblttng-ctl] " fmt, ## args)
49 #else
50 static const int print_xml = 0;
51 #define dbg_printf(fmt, args...) \
52 do { \
53 /* do nothing but check printf format */ \
54 if (0) \
55 printf("[debug liblttnctl] " fmt, ## args); \
56 } while (0)
57 #endif
58
59
60 /* Socket to session daemon for communication */
61 static int sessiond_socket;
62 static char sessiond_sock_path[PATH_MAX];
63
64 /* Variables */
65 static char *tracing_group;
66 static int connected;
67
68 /* Global */
69
70 /*
71 * Those two variables are used by error.h to silent or control the verbosity of
72 * error message. They are global to the library so application linking with it
73 * are able to compile correctly and also control verbosity of the library.
74 */
75 int lttng_opt_quiet;
76 int lttng_opt_verbose;
77
78 /*
79 * Copy string from src to dst and enforce null terminated byte.
80 */
81 LTTNG_HIDDEN
82 void lttng_ctl_copy_string(char *dst, const char *src, size_t len)
83 {
84 if (src && dst) {
85 strncpy(dst, src, len);
86 /* Enforce the NULL terminated byte */
87 dst[len - 1] = '\0';
88 } else if (dst) {
89 dst[0] = '\0';
90 }
91 }
92
93 /*
94 * Copy domain to lttcomm_session_msg domain.
95 *
96 * If domain is unknown, default domain will be the kernel.
97 */
98 LTTNG_HIDDEN
99 void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst,
100 struct lttng_domain *src)
101 {
102 if (src && dst) {
103 switch (src->type) {
104 case LTTNG_DOMAIN_KERNEL:
105 case LTTNG_DOMAIN_UST:
106 memcpy(dst, src, sizeof(struct lttng_domain));
107 break;
108 default:
109 memset(dst, 0, sizeof(struct lttng_domain));
110 break;
111 }
112 }
113 }
114
115 /*
116 * Send lttcomm_session_msg to the session daemon.
117 *
118 * On success, returns the number of bytes sent (>=0)
119 * On error, returns -1
120 */
121 static int send_session_msg(struct lttcomm_session_msg *lsm)
122 {
123 int ret;
124
125 if (!connected) {
126 ret = -LTTNG_ERR_NO_SESSIOND;
127 goto end;
128 }
129
130 DBG("LSM cmd type : %d", lsm->cmd_type);
131
132 ret = lttcomm_send_creds_unix_sock(sessiond_socket, lsm,
133 sizeof(struct lttcomm_session_msg));
134 if (ret < 0) {
135 ret = -LTTNG_ERR_FATAL;
136 }
137
138 end:
139 return ret;
140 }
141
142 /*
143 * Send var len data to the session daemon.
144 *
145 * On success, returns the number of bytes sent (>=0)
146 * On error, returns -1
147 */
148 static int send_session_varlen(void *data, size_t len)
149 {
150 int ret;
151
152 if (!connected) {
153 ret = -LTTNG_ERR_NO_SESSIOND;
154 goto end;
155 }
156
157 if (!data || !len) {
158 ret = 0;
159 goto end;
160 }
161
162 ret = lttcomm_send_unix_sock(sessiond_socket, data, len);
163 if (ret < 0) {
164 ret = -LTTNG_ERR_FATAL;
165 }
166
167 end:
168 return ret;
169 }
170
171 /*
172 * Receive data from the sessiond socket.
173 *
174 * On success, returns the number of bytes received (>=0)
175 * On error, returns -1 (recvmsg() error) or -ENOTCONN
176 */
177 static int recv_data_sessiond(void *buf, size_t len)
178 {
179 int ret;
180
181 if (!connected) {
182 ret = -LTTNG_ERR_NO_SESSIOND;
183 goto end;
184 }
185
186 ret = lttcomm_recv_unix_sock(sessiond_socket, buf, len);
187 if (ret < 0) {
188 ret = -LTTNG_ERR_FATAL;
189 }
190
191 end:
192 return ret;
193 }
194
195 /*
196 * Check if we are in the specified group.
197 *
198 * If yes return 1, else return -1.
199 */
200 LTTNG_HIDDEN
201 int lttng_check_tracing_group(void)
202 {
203 struct group *grp_tracing; /* no free(). See getgrnam(3) */
204 gid_t *grp_list;
205 int grp_list_size, grp_id, i;
206 int ret = -1;
207 const char *grp_name = tracing_group;
208
209 /* Get GID of group 'tracing' */
210 grp_tracing = getgrnam(grp_name);
211 if (!grp_tracing) {
212 /* If grp_tracing is NULL, the group does not exist. */
213 goto end;
214 }
215
216 /* Get number of supplementary group IDs */
217 grp_list_size = getgroups(0, NULL);
218 if (grp_list_size < 0) {
219 perror("getgroups");
220 goto end;
221 }
222
223 /* Alloc group list of the right size */
224 grp_list = malloc(grp_list_size * sizeof(gid_t));
225 if (!grp_list) {
226 perror("malloc");
227 goto end;
228 }
229 grp_id = getgroups(grp_list_size, grp_list);
230 if (grp_id < 0) {
231 perror("getgroups");
232 goto free_list;
233 }
234
235 for (i = 0; i < grp_list_size; i++) {
236 if (grp_list[i] == grp_tracing->gr_gid) {
237 ret = 1;
238 break;
239 }
240 }
241
242 free_list:
243 free(grp_list);
244
245 end:
246 return ret;
247 }
248
249 /*
250 * Try connect to session daemon with sock_path.
251 *
252 * Return 0 on success, else -1
253 */
254 static int try_connect_sessiond(const char *sock_path)
255 {
256 int ret;
257
258 /* If socket exist, we check if the daemon listens for connect. */
259 ret = access(sock_path, F_OK);
260 if (ret < 0) {
261 /* Not alive */
262 goto error;
263 }
264
265 ret = lttcomm_connect_unix_sock(sock_path);
266 if (ret < 0) {
267 /* Not alive */
268 goto error;
269 }
270
271 ret = lttcomm_close_unix_sock(ret);
272 if (ret < 0) {
273 perror("lttcomm_close_unix_sock");
274 }
275
276 return 0;
277
278 error:
279 return -1;
280 }
281
282 /*
283 * Set sessiond socket path by putting it in the global sessiond_sock_path
284 * variable.
285 *
286 * Returns 0 on success, negative value on failure (the sessiond socket path
287 * is somehow too long or ENOMEM).
288 */
289 static int set_session_daemon_path(void)
290 {
291 int in_tgroup = 0; /* In tracing group */
292 uid_t uid;
293
294 uid = getuid();
295
296 if (uid != 0) {
297 /* Are we in the tracing group ? */
298 in_tgroup = lttng_check_tracing_group();
299 }
300
301 if ((uid == 0) || in_tgroup) {
302 lttng_ctl_copy_string(sessiond_sock_path,
303 DEFAULT_GLOBAL_CLIENT_UNIX_SOCK, sizeof(sessiond_sock_path));
304 }
305
306 if (uid != 0) {
307 int ret;
308
309 if (in_tgroup) {
310 /* Tracing group */
311 ret = try_connect_sessiond(sessiond_sock_path);
312 if (ret >= 0) {
313 goto end;
314 }
315 /* Global session daemon not available... */
316 }
317 /* ...or not in tracing group (and not root), default */
318
319 /*
320 * With GNU C < 2.1, snprintf returns -1 if the target buffer is too small;
321 * With GNU C >= 2.1, snprintf returns the required size (excluding closing null)
322 */
323 ret = snprintf(sessiond_sock_path, sizeof(sessiond_sock_path),
324 DEFAULT_HOME_CLIENT_UNIX_SOCK, utils_get_home_dir());
325 if ((ret < 0) || (ret >= sizeof(sessiond_sock_path))) {
326 goto error;
327 }
328 }
329 end:
330 return 0;
331
332 error:
333 return -1;
334 }
335
336 /*
337 * Connect to the LTTng session daemon.
338 *
339 * On success, return 0. On error, return -1.
340 */
341 static int connect_sessiond(void)
342 {
343 int ret;
344
345 /* Don't try to connect if already connected. */
346 if (connected) {
347 return 0;
348 }
349
350 ret = set_session_daemon_path();
351 if (ret < 0) {
352 goto error;
353 }
354
355 /* Connect to the sesssion daemon */
356 ret = lttcomm_connect_unix_sock(sessiond_sock_path);
357 if (ret < 0) {
358 goto error;
359 }
360
361 sessiond_socket = ret;
362 connected = 1;
363
364 return 0;
365
366 error:
367 return -1;
368 }
369
370 /*
371 * Clean disconnect from the session daemon.
372 * On success, return 0. On error, return -1.
373 */
374 static int disconnect_sessiond(void)
375 {
376 int ret = 0;
377
378 if (connected) {
379 ret = lttcomm_close_unix_sock(sessiond_socket);
380 sessiond_socket = 0;
381 connected = 0;
382 }
383
384 return ret;
385 }
386
387 /*
388 * Ask the session daemon a specific command and put the data into buf.
389 * Takes extra var. len. data as input to send to the session daemon.
390 *
391 * Return size of data (only payload, not header) or a negative error code.
392 */
393 LTTNG_HIDDEN
394 int lttng_ctl_ask_sessiond_varlen(struct lttcomm_session_msg *lsm,
395 void *vardata, size_t varlen, void **buf)
396 {
397 int ret;
398 size_t size;
399 void *data = NULL;
400 struct lttcomm_lttng_msg llm;
401
402 ret = connect_sessiond();
403 if (ret < 0) {
404 ret = -LTTNG_ERR_NO_SESSIOND;
405 goto end;
406 }
407
408 /* Send command to session daemon */
409 ret = send_session_msg(lsm);
410 if (ret < 0) {
411 /* Ret value is a valid lttng error code. */
412 goto end;
413 }
414 /* Send var len data */
415 ret = send_session_varlen(vardata, varlen);
416 if (ret < 0) {
417 /* Ret value is a valid lttng error code. */
418 goto end;
419 }
420
421 /* Get header from data transmission */
422 ret = recv_data_sessiond(&llm, sizeof(llm));
423 if (ret < 0) {
424 /* Ret value is a valid lttng error code. */
425 goto end;
426 }
427
428 /* Check error code if OK */
429 if (llm.ret_code != LTTNG_OK) {
430 ret = -llm.ret_code;
431 goto end;
432 }
433
434 size = llm.data_size;
435 if (size == 0) {
436 /* If client free with size 0 */
437 if (buf != NULL) {
438 *buf = NULL;
439 }
440 ret = 0;
441 goto end;
442 }
443
444 data = (void*) malloc(size);
445
446 /* Get payload data */
447 ret = recv_data_sessiond(data, size);
448 if (ret < 0) {
449 free(data);
450 goto end;
451 }
452
453 /*
454 * Extra protection not to dereference a NULL pointer. If buf is NULL at
455 * this point, an error is returned and data is freed.
456 */
457 if (buf == NULL) {
458 ret = -LTTNG_ERR_INVALID;
459 free(data);
460 goto end;
461 }
462
463 *buf = data;
464 ret = size;
465
466 end:
467 disconnect_sessiond();
468 return ret;
469 }
470
471 /*
472 * Create lttng handle and return pointer.
473 * The returned pointer will be NULL in case of malloc() error.
474 */
475 struct lttng_handle *lttng_create_handle(const char *session_name,
476 struct lttng_domain *domain)
477 {
478 struct lttng_handle *handle = NULL;
479
480 if (domain == NULL) {
481 goto end;
482 }
483
484 handle = malloc(sizeof(struct lttng_handle));
485 if (handle == NULL) {
486 PERROR("malloc handle");
487 goto end;
488 }
489
490 /* Copy session name */
491 lttng_ctl_copy_string(handle->session_name, session_name,
492 sizeof(handle->session_name));
493
494 /* Copy lttng domain */
495 lttng_ctl_copy_lttng_domain(&handle->domain, domain);
496
497 end:
498 return handle;
499 }
500
501 /*
502 * Destroy handle by free(3) the pointer.
503 */
504 void lttng_destroy_handle(struct lttng_handle *handle)
505 {
506 free(handle);
507 }
508
509 /*
510 * Register an outside consumer.
511 * Returns size of returned session payload data or a negative error code.
512 */
513 int lttng_register_consumer(struct lttng_handle *handle,
514 const char *socket_path)
515 {
516 struct lttcomm_session_msg lsm;
517
518 if (handle == NULL || socket_path == NULL) {
519 return -LTTNG_ERR_INVALID;
520 }
521
522 lsm.cmd_type = LTTNG_REGISTER_CONSUMER;
523 lttng_ctl_copy_string(lsm.session.name, handle->session_name,
524 sizeof(lsm.session.name));
525 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
526
527 lttng_ctl_copy_string(lsm.u.reg.path, socket_path, sizeof(lsm.u.reg.path));
528
529 return lttng_ctl_ask_sessiond(&lsm, NULL);
530 }
531
532 /*
533 * Start tracing for all traces of the session.
534 * Returns size of returned session payload data or a negative error code.
535 */
536 int lttng_start_tracing(const char *session_name)
537 {
538 struct lttcomm_session_msg lsm;
539
540 if (session_name == NULL) {
541 return -LTTNG_ERR_INVALID;
542 }
543
544 lsm.cmd_type = LTTNG_START_TRACE;
545
546 lttng_ctl_copy_string(lsm.session.name, session_name,
547 sizeof(lsm.session.name));
548
549 return lttng_ctl_ask_sessiond(&lsm, NULL);
550 }
551
552 /*
553 * Stop tracing for all traces of the session.
554 */
555 static int _lttng_stop_tracing(const char *session_name, int wait)
556 {
557 int ret, data_ret;
558 struct lttcomm_session_msg lsm;
559
560 if (session_name == NULL) {
561 return -LTTNG_ERR_INVALID;
562 }
563
564 lsm.cmd_type = LTTNG_STOP_TRACE;
565
566 lttng_ctl_copy_string(lsm.session.name, session_name,
567 sizeof(lsm.session.name));
568
569 ret = lttng_ctl_ask_sessiond(&lsm, NULL);
570 if (ret < 0 && ret != -LTTNG_ERR_TRACE_ALREADY_STOPPED) {
571 goto error;
572 }
573
574 if (!wait) {
575 goto end;
576 }
577
578 _MSG("Waiting for data availability");
579 fflush(stdout);
580
581 /* Check for data availability */
582 do {
583 data_ret = lttng_data_pending(session_name);
584 if (data_ret < 0) {
585 /* Return the data available call error. */
586 ret = data_ret;
587 goto error;
588 }
589
590 /*
591 * Data sleep time before retrying (in usec). Don't sleep if the call
592 * returned value indicates availability.
593 */
594 if (data_ret) {
595 usleep(DEFAULT_DATA_AVAILABILITY_WAIT_TIME);
596 _MSG(".");
597 fflush(stdout);
598 }
599 } while (data_ret != 0);
600
601 MSG("");
602
603 end:
604 error:
605 return ret;
606 }
607
608 /*
609 * Stop tracing and wait for data availability.
610 */
611 int lttng_stop_tracing(const char *session_name)
612 {
613 return _lttng_stop_tracing(session_name, 1);
614 }
615
616 /*
617 * Stop tracing but _don't_ wait for data availability.
618 */
619 int lttng_stop_tracing_no_wait(const char *session_name)
620 {
621 return _lttng_stop_tracing(session_name, 0);
622 }
623
624 /*
625 * Add context to a channel.
626 *
627 * If the given channel is NULL, add the contexts to all channels.
628 * The event_name param is ignored.
629 *
630 * Returns the size of the returned payload data or a negative error code.
631 */
632 int lttng_add_context(struct lttng_handle *handle,
633 struct lttng_event_context *ctx, const char *event_name,
634 const char *channel_name)
635 {
636 struct lttcomm_session_msg lsm;
637
638 /* Safety check. Both are mandatory */
639 if (handle == NULL || ctx == NULL) {
640 return -LTTNG_ERR_INVALID;
641 }
642
643 memset(&lsm, 0, sizeof(lsm));
644
645 lsm.cmd_type = LTTNG_ADD_CONTEXT;
646
647 /* If no channel name, send empty string. */
648 if (channel_name == NULL) {
649 lttng_ctl_copy_string(lsm.u.context.channel_name, "",
650 sizeof(lsm.u.context.channel_name));
651 } else {
652 lttng_ctl_copy_string(lsm.u.context.channel_name, channel_name,
653 sizeof(lsm.u.context.channel_name));
654 }
655
656 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
657
658 memcpy(&lsm.u.context.ctx, ctx, sizeof(struct lttng_event_context));
659
660 lttng_ctl_copy_string(lsm.session.name, handle->session_name,
661 sizeof(lsm.session.name));
662
663 return lttng_ctl_ask_sessiond(&lsm, NULL);
664 }
665
666 /*
667 * Enable event(s) for a channel.
668 * If no event name is specified, all events are enabled.
669 * If no channel name is specified, the default 'channel0' is used.
670 * Returns size of returned session payload data or a negative error code.
671 */
672 int lttng_enable_event(struct lttng_handle *handle,
673 struct lttng_event *ev, const char *channel_name)
674 {
675 struct lttcomm_session_msg lsm;
676
677 if (handle == NULL || ev == NULL) {
678 return -LTTNG_ERR_INVALID;
679 }
680
681 memset(&lsm, 0, sizeof(lsm));
682
683 /* If no channel name, send empty string. */
684 if (channel_name == NULL) {
685 lttng_ctl_copy_string(lsm.u.enable.channel_name, "",
686 sizeof(lsm.u.enable.channel_name));
687 } else {
688 lttng_ctl_copy_string(lsm.u.enable.channel_name, channel_name,
689 sizeof(lsm.u.enable.channel_name));
690 }
691
692 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
693
694 if (ev->name[0] != '\0') {
695 lsm.cmd_type = LTTNG_ENABLE_EVENT;
696 } else {
697 lsm.cmd_type = LTTNG_ENABLE_ALL_EVENT;
698 }
699 memcpy(&lsm.u.enable.event, ev, sizeof(lsm.u.enable.event));
700
701 lttng_ctl_copy_string(lsm.session.name, handle->session_name,
702 sizeof(lsm.session.name));
703
704 return lttng_ctl_ask_sessiond(&lsm, NULL);
705 }
706
707 /*
708 * Create or enable an event with a filter expression.
709 *
710 * Return negative error value on error.
711 * Return size of returned session payload data if OK.
712 */
713 int lttng_enable_event_with_filter(struct lttng_handle *handle,
714 struct lttng_event *event, const char *channel_name,
715 const char *filter_expression)
716 {
717 struct lttcomm_session_msg lsm;
718 struct filter_parser_ctx *ctx;
719 FILE *fmem;
720 int ret = 0;
721
722 if (!filter_expression) {
723 /*
724 * Fall back to normal event enabling if no filter
725 * specified.
726 */
727 return lttng_enable_event(handle, event, channel_name);
728 }
729
730 /*
731 * Empty filter string will always be rejected by the parser
732 * anyway, so treat this corner-case early to eliminate
733 * lttng_fmemopen error for 0-byte allocation.
734 */
735 if (handle == NULL || filter_expression[0] == '\0') {
736 return -LTTNG_ERR_INVALID;
737 }
738
739 /*
740 * casting const to non-const, as the underlying function will
741 * use it in read-only mode.
742 */
743 fmem = lttng_fmemopen((void *) filter_expression,
744 strlen(filter_expression), "r");
745 if (!fmem) {
746 fprintf(stderr, "Error opening memory as stream\n");
747 return -LTTNG_ERR_FILTER_NOMEM;
748 }
749 ctx = filter_parser_ctx_alloc(fmem);
750 if (!ctx) {
751 fprintf(stderr, "Error allocating parser\n");
752 ret = -LTTNG_ERR_FILTER_NOMEM;
753 goto alloc_error;
754 }
755 ret = filter_parser_ctx_append_ast(ctx);
756 if (ret) {
757 fprintf(stderr, "Parse error\n");
758 ret = -LTTNG_ERR_FILTER_INVAL;
759 goto parse_error;
760 }
761 ret = filter_visitor_set_parent(ctx);
762 if (ret) {
763 fprintf(stderr, "Set parent error\n");
764 ret = -LTTNG_ERR_FILTER_INVAL;
765 goto parse_error;
766 }
767 if (print_xml) {
768 ret = filter_visitor_print_xml(ctx, stdout, 0);
769 if (ret) {
770 fflush(stdout);
771 fprintf(stderr, "XML print error\n");
772 ret = -LTTNG_ERR_FILTER_INVAL;
773 goto parse_error;
774 }
775 }
776
777 dbg_printf("Generating IR... ");
778 fflush(stdout);
779 ret = filter_visitor_ir_generate(ctx);
780 if (ret) {
781 fprintf(stderr, "Generate IR error\n");
782 ret = -LTTNG_ERR_FILTER_INVAL;
783 goto parse_error;
784 }
785 dbg_printf("done\n");
786
787 dbg_printf("Validating IR... ");
788 fflush(stdout);
789 ret = filter_visitor_ir_check_binary_op_nesting(ctx);
790 if (ret) {
791 ret = -LTTNG_ERR_FILTER_INVAL;
792 goto parse_error;
793 }
794 dbg_printf("done\n");
795
796 dbg_printf("Generating bytecode... ");
797 fflush(stdout);
798 ret = filter_visitor_bytecode_generate(ctx);
799 if (ret) {
800 fprintf(stderr, "Generate bytecode error\n");
801 ret = -LTTNG_ERR_FILTER_INVAL;
802 goto parse_error;
803 }
804 dbg_printf("done\n");
805 dbg_printf("Size of bytecode generated: %u bytes.\n",
806 bytecode_get_len(&ctx->bytecode->b));
807
808 memset(&lsm, 0, sizeof(lsm));
809
810 lsm.cmd_type = LTTNG_ENABLE_EVENT_WITH_FILTER;
811
812 /* If no channel name, send empty string. */
813 if (channel_name == NULL) {
814 lttng_ctl_copy_string(lsm.u.enable.channel_name, "",
815 sizeof(lsm.u.enable.channel_name));
816 } else {
817 lttng_ctl_copy_string(lsm.u.enable.channel_name, channel_name,
818 sizeof(lsm.u.enable.channel_name));
819 }
820
821 /* Copy event name */
822 if (event) {
823 memcpy(&lsm.u.enable.event, event, sizeof(lsm.u.enable.event));
824 }
825
826 lsm.u.enable.bytecode_len = sizeof(ctx->bytecode->b)
827 + bytecode_get_len(&ctx->bytecode->b);
828
829 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
830
831 lttng_ctl_copy_string(lsm.session.name, handle->session_name,
832 sizeof(lsm.session.name));
833
834 ret = lttng_ctl_ask_sessiond_varlen(&lsm, &ctx->bytecode->b,
835 lsm.u.enable.bytecode_len, NULL);
836
837 filter_bytecode_free(ctx);
838 filter_ir_free(ctx);
839 filter_parser_ctx_free(ctx);
840 if (fclose(fmem) != 0) {
841 perror("fclose");
842 }
843 return ret;
844
845 parse_error:
846 filter_bytecode_free(ctx);
847 filter_ir_free(ctx);
848 filter_parser_ctx_free(ctx);
849 alloc_error:
850 if (fclose(fmem) != 0) {
851 perror("fclose");
852 }
853 return ret;
854 }
855
856 /*
857 * Disable event(s) of a channel and domain.
858 * If no event name is specified, all events are disabled.
859 * If no channel name is specified, the default 'channel0' is used.
860 * Returns size of returned session payload data or a negative error code.
861 */
862 int lttng_disable_event(struct lttng_handle *handle, const char *name,
863 const char *channel_name)
864 {
865 struct lttcomm_session_msg lsm;
866
867 if (handle == NULL) {
868 return -LTTNG_ERR_INVALID;
869 }
870
871 memset(&lsm, 0, sizeof(lsm));
872
873 /* If no channel name, send empty string. */
874 if (channel_name == NULL) {
875 lttng_ctl_copy_string(lsm.u.disable.channel_name, "",
876 sizeof(lsm.u.disable.channel_name));
877 } else {
878 lttng_ctl_copy_string(lsm.u.disable.channel_name, channel_name,
879 sizeof(lsm.u.disable.channel_name));
880 }
881
882 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
883
884 if (name != NULL) {
885 lttng_ctl_copy_string(lsm.u.disable.name, name,
886 sizeof(lsm.u.disable.name));
887 lsm.cmd_type = LTTNG_DISABLE_EVENT;
888 } else {
889 lsm.cmd_type = LTTNG_DISABLE_ALL_EVENT;
890 }
891
892 lttng_ctl_copy_string(lsm.session.name, handle->session_name,
893 sizeof(lsm.session.name));
894
895 return lttng_ctl_ask_sessiond(&lsm, NULL);
896 }
897
898 /*
899 * Enable channel per domain
900 * Returns size of returned session payload data or a negative error code.
901 */
902 int lttng_enable_channel(struct lttng_handle *handle,
903 struct lttng_channel *chan)
904 {
905 struct lttcomm_session_msg lsm;
906
907 /*
908 * NULL arguments are forbidden. No default values.
909 */
910 if (handle == NULL || chan == NULL) {
911 return -LTTNG_ERR_INVALID;
912 }
913
914 memset(&lsm, 0, sizeof(lsm));
915
916 memcpy(&lsm.u.channel.chan, chan, sizeof(lsm.u.channel.chan));
917
918 lsm.cmd_type = LTTNG_ENABLE_CHANNEL;
919
920 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
921
922 lttng_ctl_copy_string(lsm.session.name, handle->session_name,
923 sizeof(lsm.session.name));
924
925 return lttng_ctl_ask_sessiond(&lsm, NULL);
926 }
927
928 /*
929 * All tracing will be stopped for registered events of the channel.
930 * Returns size of returned session payload data or a negative error code.
931 */
932 int lttng_disable_channel(struct lttng_handle *handle, const char *name)
933 {
934 struct lttcomm_session_msg lsm;
935
936 /* Safety check. Both are mandatory */
937 if (handle == NULL || name == NULL) {
938 return -LTTNG_ERR_INVALID;
939 }
940
941 memset(&lsm, 0, sizeof(lsm));
942
943 lsm.cmd_type = LTTNG_DISABLE_CHANNEL;
944
945 lttng_ctl_copy_string(lsm.u.disable.channel_name, name,
946 sizeof(lsm.u.disable.channel_name));
947
948 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
949
950 lttng_ctl_copy_string(lsm.session.name, handle->session_name,
951 sizeof(lsm.session.name));
952
953 return lttng_ctl_ask_sessiond(&lsm, NULL);
954 }
955
956 /*
957 * Lists all available tracepoints of domain.
958 * Sets the contents of the events array.
959 * Returns the number of lttng_event entries in events;
960 * on error, returns a negative value.
961 */
962 int lttng_list_tracepoints(struct lttng_handle *handle,
963 struct lttng_event **events)
964 {
965 int ret;
966 struct lttcomm_session_msg lsm;
967
968 if (handle == NULL) {
969 return -LTTNG_ERR_INVALID;
970 }
971
972 lsm.cmd_type = LTTNG_LIST_TRACEPOINTS;
973 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
974
975 ret = lttng_ctl_ask_sessiond(&lsm, (void **) events);
976 if (ret < 0) {
977 return ret;
978 }
979
980 return ret / sizeof(struct lttng_event);
981 }
982
983 /*
984 * Lists all available tracepoint fields of domain.
985 * Sets the contents of the event field array.
986 * Returns the number of lttng_event_field entries in events;
987 * on error, returns a negative value.
988 */
989 int lttng_list_tracepoint_fields(struct lttng_handle *handle,
990 struct lttng_event_field **fields)
991 {
992 int ret;
993 struct lttcomm_session_msg lsm;
994
995 if (handle == NULL) {
996 return -LTTNG_ERR_INVALID;
997 }
998
999 lsm.cmd_type = LTTNG_LIST_TRACEPOINT_FIELDS;
1000 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
1001
1002 ret = lttng_ctl_ask_sessiond(&lsm, (void **) fields);
1003 if (ret < 0) {
1004 return ret;
1005 }
1006
1007 return ret / sizeof(struct lttng_event_field);
1008 }
1009
1010 /*
1011 * Returns a human readable string describing
1012 * the error code (a negative value).
1013 */
1014 const char *lttng_strerror(int code)
1015 {
1016 return error_get_str(code);
1017 }
1018
1019 /*
1020 * Create a brand new session using name and url for destination.
1021 *
1022 * Returns LTTNG_OK on success or a negative error code.
1023 */
1024 int lttng_create_session(const char *name, const char *url)
1025 {
1026 int ret;
1027 ssize_t size;
1028 struct lttcomm_session_msg lsm;
1029 struct lttng_uri *uris = NULL;
1030
1031 if (name == NULL) {
1032 return -LTTNG_ERR_INVALID;
1033 }
1034
1035 memset(&lsm, 0, sizeof(lsm));
1036
1037 lsm.cmd_type = LTTNG_CREATE_SESSION;
1038 lttng_ctl_copy_string(lsm.session.name, name, sizeof(lsm.session.name));
1039
1040 /* There should never be a data URL */
1041 size = uri_parse_str_urls(url, NULL, &uris);
1042 if (size < 0) {
1043 return -LTTNG_ERR_INVALID;
1044 }
1045
1046 lsm.u.uri.size = size;
1047
1048 ret = lttng_ctl_ask_sessiond_varlen(&lsm, uris,
1049 sizeof(struct lttng_uri) * size, NULL);
1050
1051 free(uris);
1052 return ret;
1053 }
1054
1055 /*
1056 * Destroy session using name.
1057 * Returns size of returned session payload data or a negative error code.
1058 */
1059 int lttng_destroy_session(const char *session_name)
1060 {
1061 struct lttcomm_session_msg lsm;
1062
1063 if (session_name == NULL) {
1064 return -LTTNG_ERR_INVALID;
1065 }
1066
1067 lsm.cmd_type = LTTNG_DESTROY_SESSION;
1068
1069 lttng_ctl_copy_string(lsm.session.name, session_name,
1070 sizeof(lsm.session.name));
1071
1072 return lttng_ctl_ask_sessiond(&lsm, NULL);
1073 }
1074
1075 /*
1076 * Ask the session daemon for all available sessions.
1077 * Sets the contents of the sessions array.
1078 * Returns the number of lttng_session entries in sessions;
1079 * on error, returns a negative value.
1080 */
1081 int lttng_list_sessions(struct lttng_session **sessions)
1082 {
1083 int ret;
1084 struct lttcomm_session_msg lsm;
1085
1086 lsm.cmd_type = LTTNG_LIST_SESSIONS;
1087 ret = lttng_ctl_ask_sessiond(&lsm, (void**) sessions);
1088 if (ret < 0) {
1089 return ret;
1090 }
1091
1092 return ret / sizeof(struct lttng_session);
1093 }
1094
1095 /*
1096 * Ask the session daemon for all available domains of a session.
1097 * Sets the contents of the domains array.
1098 * Returns the number of lttng_domain entries in domains;
1099 * on error, returns a negative value.
1100 */
1101 int lttng_list_domains(const char *session_name,
1102 struct lttng_domain **domains)
1103 {
1104 int ret;
1105 struct lttcomm_session_msg lsm;
1106
1107 if (session_name == NULL) {
1108 return -LTTNG_ERR_INVALID;
1109 }
1110
1111 lsm.cmd_type = LTTNG_LIST_DOMAINS;
1112
1113 lttng_ctl_copy_string(lsm.session.name, session_name,
1114 sizeof(lsm.session.name));
1115
1116 ret = lttng_ctl_ask_sessiond(&lsm, (void**) domains);
1117 if (ret < 0) {
1118 return ret;
1119 }
1120
1121 return ret / sizeof(struct lttng_domain);
1122 }
1123
1124 /*
1125 * Ask the session daemon for all available channels of a session.
1126 * Sets the contents of the channels array.
1127 * Returns the number of lttng_channel entries in channels;
1128 * on error, returns a negative value.
1129 */
1130 int lttng_list_channels(struct lttng_handle *handle,
1131 struct lttng_channel **channels)
1132 {
1133 int ret;
1134 struct lttcomm_session_msg lsm;
1135
1136 if (handle == NULL) {
1137 return -LTTNG_ERR_INVALID;
1138 }
1139
1140 lsm.cmd_type = LTTNG_LIST_CHANNELS;
1141 lttng_ctl_copy_string(lsm.session.name, handle->session_name,
1142 sizeof(lsm.session.name));
1143
1144 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
1145
1146 ret = lttng_ctl_ask_sessiond(&lsm, (void**) channels);
1147 if (ret < 0) {
1148 return ret;
1149 }
1150
1151 return ret / sizeof(struct lttng_channel);
1152 }
1153
1154 /*
1155 * Ask the session daemon for all available events of a session channel.
1156 * Sets the contents of the events array.
1157 * Returns the number of lttng_event entries in events;
1158 * on error, returns a negative value.
1159 */
1160 int lttng_list_events(struct lttng_handle *handle,
1161 const char *channel_name, struct lttng_event **events)
1162 {
1163 int ret;
1164 struct lttcomm_session_msg lsm;
1165
1166 /* Safety check. An handle and channel name are mandatory */
1167 if (handle == NULL || channel_name == NULL) {
1168 return -LTTNG_ERR_INVALID;
1169 }
1170
1171 lsm.cmd_type = LTTNG_LIST_EVENTS;
1172 lttng_ctl_copy_string(lsm.session.name, handle->session_name,
1173 sizeof(lsm.session.name));
1174 lttng_ctl_copy_string(lsm.u.list.channel_name, channel_name,
1175 sizeof(lsm.u.list.channel_name));
1176
1177 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
1178
1179 ret = lttng_ctl_ask_sessiond(&lsm, (void**) events);
1180 if (ret < 0) {
1181 return ret;
1182 }
1183
1184 return ret / sizeof(struct lttng_event);
1185 }
1186
1187 /*
1188 * Sets the tracing_group variable with name.
1189 * This function allocates memory pointed to by tracing_group.
1190 * On success, returns 0, on error, returns -1 (null name) or -ENOMEM.
1191 */
1192 int lttng_set_tracing_group(const char *name)
1193 {
1194 if (name == NULL) {
1195 return -LTTNG_ERR_INVALID;
1196 }
1197
1198 if (asprintf(&tracing_group, "%s", name) < 0) {
1199 return -LTTNG_ERR_FATAL;
1200 }
1201
1202 return 0;
1203 }
1204
1205 /*
1206 * Returns size of returned session payload data or a negative error code.
1207 */
1208 int lttng_calibrate(struct lttng_handle *handle,
1209 struct lttng_calibrate *calibrate)
1210 {
1211 struct lttcomm_session_msg lsm;
1212
1213 /* Safety check. NULL pointer are forbidden */
1214 if (handle == NULL || calibrate == NULL) {
1215 return -LTTNG_ERR_INVALID;
1216 }
1217
1218 lsm.cmd_type = LTTNG_CALIBRATE;
1219 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
1220
1221 memcpy(&lsm.u.calibrate, calibrate, sizeof(lsm.u.calibrate));
1222
1223 return lttng_ctl_ask_sessiond(&lsm, NULL);
1224 }
1225
1226 /*
1227 * Set default channel attributes.
1228 * If either or both of the arguments are null, attr content is zeroe'd.
1229 */
1230 void lttng_channel_set_default_attr(struct lttng_domain *domain,
1231 struct lttng_channel_attr *attr)
1232 {
1233 /* Safety check */
1234 if (attr == NULL || domain == NULL) {
1235 return;
1236 }
1237
1238 memset(attr, 0, sizeof(struct lttng_channel_attr));
1239
1240 /* Same for all domains. */
1241 attr->overwrite = DEFAULT_CHANNEL_OVERWRITE;
1242 attr->tracefile_size = DEFAULT_CHANNEL_TRACEFILE_SIZE;
1243 attr->tracefile_count = DEFAULT_CHANNEL_TRACEFILE_COUNT;
1244
1245 switch (domain->type) {
1246 case LTTNG_DOMAIN_KERNEL:
1247 attr->switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
1248 attr->read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER;
1249 attr->subbuf_size = default_get_kernel_channel_subbuf_size();
1250 attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
1251 attr->output = DEFAULT_KERNEL_CHANNEL_OUTPUT;
1252 break;
1253 case LTTNG_DOMAIN_UST:
1254 switch (domain->buf_type) {
1255 case LTTNG_BUFFER_PER_UID:
1256 attr->subbuf_size = default_get_ust_uid_channel_subbuf_size();
1257 attr->num_subbuf = DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM;
1258 attr->output = DEFAULT_UST_UID_CHANNEL_OUTPUT;
1259 attr->switch_timer_interval = DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER;
1260 attr->read_timer_interval = DEFAULT_UST_UID_CHANNEL_READ_TIMER;
1261 break;
1262 case LTTNG_BUFFER_PER_PID:
1263 default:
1264 attr->subbuf_size = default_get_ust_pid_channel_subbuf_size();
1265 attr->num_subbuf = DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM;
1266 attr->output = DEFAULT_UST_PID_CHANNEL_OUTPUT;
1267 attr->switch_timer_interval = DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER;
1268 attr->read_timer_interval = DEFAULT_UST_PID_CHANNEL_READ_TIMER;
1269 break;
1270 }
1271 default:
1272 /* Default behavior: leave set to 0. */
1273 break;
1274 }
1275 }
1276
1277 /*
1278 * Check if session daemon is alive.
1279 *
1280 * Return 1 if alive or 0 if not.
1281 * On error returns a negative value.
1282 */
1283 int lttng_session_daemon_alive(void)
1284 {
1285 int ret;
1286
1287 ret = set_session_daemon_path();
1288 if (ret < 0) {
1289 /* Error */
1290 return ret;
1291 }
1292
1293 if (*sessiond_sock_path == '\0') {
1294 /*
1295 * No socket path set. Weird error which means the constructor was not
1296 * called.
1297 */
1298 assert(0);
1299 }
1300
1301 ret = try_connect_sessiond(sessiond_sock_path);
1302 if (ret < 0) {
1303 /* Not alive */
1304 return 0;
1305 }
1306
1307 /* Is alive */
1308 return 1;
1309 }
1310
1311 /*
1312 * Set URL for a consumer for a session and domain.
1313 *
1314 * Return 0 on success, else a negative value.
1315 */
1316 int lttng_set_consumer_url(struct lttng_handle *handle,
1317 const char *control_url, const char *data_url)
1318 {
1319 int ret;
1320 ssize_t size;
1321 struct lttcomm_session_msg lsm;
1322 struct lttng_uri *uris = NULL;
1323
1324 if (handle == NULL || (control_url == NULL && data_url == NULL)) {
1325 return -LTTNG_ERR_INVALID;
1326 }
1327
1328 memset(&lsm, 0, sizeof(lsm));
1329
1330 lsm.cmd_type = LTTNG_SET_CONSUMER_URI;
1331
1332 lttng_ctl_copy_string(lsm.session.name, handle->session_name,
1333 sizeof(lsm.session.name));
1334 lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
1335
1336 size = uri_parse_str_urls(control_url, data_url, &uris);
1337 if (size < 0) {
1338 return -LTTNG_ERR_INVALID;
1339 }
1340
1341 lsm.u.uri.size = size;
1342
1343 ret = lttng_ctl_ask_sessiond_varlen(&lsm, uris,
1344 sizeof(struct lttng_uri) * size, NULL);
1345
1346 free(uris);
1347 return ret;
1348 }
1349
1350 /*
1351 * [OBSOLETE]
1352 */
1353 int lttng_enable_consumer(struct lttng_handle *handle)
1354 {
1355 return -ENOSYS;
1356 }
1357
1358 /*
1359 * [OBSOLETE]
1360 */
1361 int lttng_disable_consumer(struct lttng_handle *handle)
1362 {
1363 return -ENOSYS;
1364 }
1365
1366 /*
1367 * This is an extension of create session that is ONLY and SHOULD only be used
1368 * by the lttng command line program. It exists to avoid using URI parsing in
1369 * the lttng client.
1370 *
1371 * We need the date and time for the trace path subdirectory for the case where
1372 * the user does NOT define one using either -o or -U. Using the normal
1373 * lttng_create_session API call, we have no clue on the session daemon side if
1374 * the URL was generated automatically by the client or define by the user.
1375 *
1376 * So this function "wrapper" is hidden from the public API, takes the datetime
1377 * string and appends it if necessary to the URI subdirectory before sending it
1378 * to the session daemon.
1379 *
1380 * With this extra function, the lttng_create_session call behavior is not
1381 * changed and the timestamp is appended to the URI on the session daemon side
1382 * if necessary.
1383 */
1384 int _lttng_create_session_ext(const char *name, const char *url,
1385 const char *datetime)
1386 {
1387 int ret;
1388 ssize_t size;
1389 struct lttcomm_session_msg lsm;
1390 struct lttng_uri *uris = NULL;
1391
1392 if (name == NULL || datetime == NULL) {
1393 return -LTTNG_ERR_INVALID;
1394 }
1395
1396 memset(&lsm, 0, sizeof(lsm));
1397
1398 lsm.cmd_type = LTTNG_CREATE_SESSION;
1399 lttng_ctl_copy_string(lsm.session.name, name, sizeof(lsm.session.name));
1400
1401 /* There should never be a data URL */
1402 size = uri_parse_str_urls(url, NULL, &uris);
1403 if (size < 0) {
1404 ret = -LTTNG_ERR_INVALID;
1405 goto error;
1406 }
1407
1408 lsm.u.uri.size = size;
1409
1410 if (size > 0 && uris[0].dtype != LTTNG_DST_PATH && strlen(uris[0].subdir) == 0) {
1411 /* Don't append datetime if the name was automatically created. */
1412 if (strncmp(name, DEFAULT_SESSION_NAME "-",
1413 strlen(DEFAULT_SESSION_NAME) + 1)) {
1414 ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s-%s",
1415 name, datetime);
1416 } else {
1417 ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s", name);
1418 }
1419 if (ret < 0) {
1420 PERROR("snprintf uri subdir");
1421 ret = -LTTNG_ERR_FATAL;
1422 goto error;
1423 }
1424 }
1425
1426 ret = lttng_ctl_ask_sessiond_varlen(&lsm, uris,
1427 sizeof(struct lttng_uri) * size, NULL);
1428
1429 error:
1430 free(uris);
1431 return ret;
1432 }
1433
1434 /*
1435 * For a given session name, this call checks if the data is ready to be read
1436 * or is still being extracted by the consumer(s) hence not ready to be used by
1437 * any readers.
1438 */
1439 int lttng_data_pending(const char *session_name)
1440 {
1441 int ret;
1442 struct lttcomm_session_msg lsm;
1443
1444 if (session_name == NULL) {
1445 return -LTTNG_ERR_INVALID;
1446 }
1447
1448 lsm.cmd_type = LTTNG_DATA_PENDING;
1449
1450 lttng_ctl_copy_string(lsm.session.name, session_name,
1451 sizeof(lsm.session.name));
1452
1453 ret = lttng_ctl_ask_sessiond(&lsm, NULL);
1454
1455 /*
1456 * The lttng_ctl_ask_sessiond function negate the return code if it's not
1457 * LTTNG_OK so getting -1 means that the reply ret_code was 1 thus meaning
1458 * that the data is available. Yes it is hackish but for now this is the
1459 * only way.
1460 */
1461 if (ret == -1) {
1462 ret = 1;
1463 }
1464
1465 return ret;
1466 }
1467
1468 /*
1469 * Create a session exclusively used for snapshot.
1470 *
1471 * Returns LTTNG_OK on success or a negative error code.
1472 */
1473 int lttng_create_session_snapshot(const char *name, const char *snapshot_url)
1474 {
1475 int ret;
1476 ssize_t size;
1477 struct lttcomm_session_msg lsm;
1478 struct lttng_uri *uris = NULL;
1479
1480 if (name == NULL) {
1481 return -LTTNG_ERR_INVALID;
1482 }
1483
1484 memset(&lsm, 0, sizeof(lsm));
1485
1486 lsm.cmd_type = LTTNG_CREATE_SESSION_SNAPSHOT;
1487 lttng_ctl_copy_string(lsm.session.name, name, sizeof(lsm.session.name));
1488
1489 size = uri_parse_str_urls(snapshot_url, NULL, &uris);
1490 if (size < 0) {
1491 return -LTTNG_ERR_INVALID;
1492 }
1493
1494 lsm.u.uri.size = size;
1495
1496 ret = lttng_ctl_ask_sessiond_varlen(&lsm, uris,
1497 sizeof(struct lttng_uri) * size, NULL);
1498
1499 free(uris);
1500 return ret;
1501 }
1502
1503 /*
1504 * Create a session exclusively used for live.
1505 *
1506 * Returns LTTNG_OK on success or a negative error code.
1507 */
1508 int lttng_create_session_live(const char *name, const char *url,
1509 unsigned int timer_interval)
1510 {
1511 int ret;
1512 ssize_t size;
1513 struct lttcomm_session_msg lsm;
1514 struct lttng_uri *uris = NULL;
1515
1516 if (name == NULL) {
1517 return -LTTNG_ERR_INVALID;
1518 }
1519
1520 memset(&lsm, 0, sizeof(lsm));
1521
1522 lsm.cmd_type = LTTNG_CREATE_SESSION_LIVE;
1523 lttng_ctl_copy_string(lsm.session.name, name, sizeof(lsm.session.name));
1524
1525 size = uri_parse_str_urls(url, NULL, &uris);
1526 if (size < 0) {
1527 ret = -LTTNG_ERR_INVALID;
1528 goto end;
1529 }
1530
1531 /* file:// is not accepted for live session. */
1532 if (uris[0].dtype == LTTNG_DST_PATH) {
1533 ret = -LTTNG_ERR_INVALID;
1534 goto end;
1535 }
1536
1537 lsm.u.session_live.nb_uri = size;
1538 lsm.u.session_live.timer_interval = timer_interval;
1539
1540 ret = lttng_ctl_ask_sessiond_varlen(&lsm, uris,
1541 sizeof(struct lttng_uri) * size, NULL);
1542
1543 end:
1544 free(uris);
1545 return ret;
1546 }
1547
1548 /*
1549 * lib constructor
1550 */
1551 static void __attribute__((constructor)) init()
1552 {
1553 /* Set default session group */
1554 lttng_set_tracing_group(DEFAULT_TRACING_GROUP);
1555 }
1556
1557 /*
1558 * lib destructor
1559 */
1560 static void __attribute__((destructor)) lttng_ctl_exit()
1561 {
1562 free(tracing_group);
1563 }
This page took 0.075806 seconds and 5 git commands to generate.