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