Filter: receive, attach and link empty filter
[lttng-ust.git] / liblttng-ust / ltt-events.c
1 /*
2 * ltt-events.c
3 *
4 * Holds LTTng per-session event registry.
5 *
6 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; only
11 * version 2.1 of the License.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #define _GNU_SOURCE
24 #include <stdio.h>
25 #include <urcu/list.h>
26 #include <urcu/hlist.h>
27 #include <pthread.h>
28 #include <errno.h>
29 #include <sys/shm.h>
30 #include <sys/ipc.h>
31 #include <stdint.h>
32 #include <stddef.h>
33 #include <inttypes.h>
34 #include <time.h>
35 #include <lttng/ust-endian.h>
36 #include "clock.h"
37
38 #include <urcu-bp.h>
39 #include <urcu/compiler.h>
40 #include <urcu/uatomic.h>
41 #include <urcu/arch.h>
42
43 #include <lttng/tracepoint.h>
44 #include <lttng/ust-events.h>
45
46 #include <usterr-signal-safe.h>
47 #include <helper.h>
48 #include "error.h"
49 #include "compat.h"
50 #include "lttng-ust-uuid.h"
51
52 #include "tracepoint-internal.h"
53 #include "ltt-tracer.h"
54 #include "ltt-tracer-core.h"
55 #include "wait.h"
56 #include "../libringbuffer/shm.h"
57 #include "jhash.h"
58
59 /*
60 * The sessions mutex is the centralized mutex across UST tracing
61 * control and probe registration. All operations within this file are
62 * called by the communication thread, under ust_lock protection.
63 */
64 static pthread_mutex_t sessions_mutex = PTHREAD_MUTEX_INITIALIZER;
65
66 void ust_lock(void)
67 {
68 pthread_mutex_lock(&sessions_mutex);
69 }
70
71 void ust_unlock(void)
72 {
73 pthread_mutex_unlock(&sessions_mutex);
74 }
75
76 static CDS_LIST_HEAD(sessions);
77
78 /*
79 * Wildcard list, containing the active wildcards.
80 * Protected by ust lock.
81 */
82 static CDS_LIST_HEAD(wildcard_list);
83
84 /*
85 * Pending probes hash table, containing the registered ltt events for
86 * which tracepoint probes are still missing. Protected by the sessions
87 * mutex.
88 */
89 #define PENDING_PROBE_HASH_BITS 6
90 #define PENDING_PROBE_HASH_SIZE (1 << PENDING_PROBE_HASH_BITS)
91 static struct cds_hlist_head pending_probe_table[PENDING_PROBE_HASH_SIZE];
92
93 struct ust_pending_probe {
94 struct ltt_event *event;
95 struct cds_hlist_node node;
96 enum lttng_ust_loglevel_type loglevel_type;
97 int loglevel;
98 char name[];
99 };
100
101 static void _ltt_event_destroy(struct ltt_event *event);
102 static void _ltt_wildcard_destroy(struct session_wildcard *sw);
103 static void _ltt_channel_destroy(struct ltt_channel *chan);
104 static int _ltt_event_unregister(struct ltt_event *event);
105 static
106 int _ltt_event_metadata_statedump(struct ltt_session *session,
107 struct ltt_channel *chan,
108 struct ltt_event *event);
109 static
110 int _ltt_session_metadata_statedump(struct ltt_session *session);
111
112 int ltt_loglevel_match(const struct lttng_event_desc *desc,
113 enum lttng_ust_loglevel_type req_type,
114 int req_loglevel)
115 {
116 int ev_loglevel;
117
118 if (req_type == LTTNG_UST_LOGLEVEL_ALL)
119 return 1;
120 if (!desc->loglevel)
121 ev_loglevel = TRACE_DEFAULT;
122 else
123 ev_loglevel = *(*desc->loglevel);
124 switch (req_type) {
125 case LTTNG_UST_LOGLEVEL_RANGE:
126 if (ev_loglevel <= req_loglevel || req_loglevel == -1)
127 return 1;
128 else
129 return 0;
130 case LTTNG_UST_LOGLEVEL_SINGLE:
131 if (ev_loglevel == req_loglevel || req_loglevel == -1)
132 return 1;
133 else
134 return 0;
135 case LTTNG_UST_LOGLEVEL_ALL:
136 default:
137 return 1;
138 }
139 }
140
141 /*
142 * Return wildcard for a given event name if the event name match the
143 * one of the wildcards.
144 * Must be called with ust lock held.
145 * Returns NULL if not present.
146 */
147 static
148 struct wildcard_entry *match_wildcard(const struct lttng_event_desc *desc)
149 {
150 struct wildcard_entry *e;
151
152 cds_list_for_each_entry(e, &wildcard_list, list) {
153 /* If only contain '*' */
154 if (strlen(e->name) == 1)
155 goto possible_match;
156 /* Compare excluding final '*' */
157 if (!strncmp(desc->name, e->name, strlen(e->name) - 1))
158 goto possible_match;
159 continue; /* goto next, no match */
160 possible_match:
161 if (ltt_loglevel_match(desc,
162 e->loglevel_type,
163 e->loglevel)) {
164 return e;
165 }
166 /* no match, loop to next */
167 }
168 return NULL;
169 }
170
171 /*
172 * called at event creation if probe is missing.
173 * called with session mutex held.
174 */
175 static
176 int add_pending_probe(struct ltt_event *event, const char *name,
177 enum lttng_ust_loglevel_type loglevel_type,
178 int loglevel)
179 {
180 struct cds_hlist_head *head;
181 struct ust_pending_probe *e;
182 size_t name_len = strlen(name) + 1;
183 uint32_t hash;
184
185 if (name_len > LTTNG_UST_SYM_NAME_LEN) {
186 WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN);
187 name_len = LTTNG_UST_SYM_NAME_LEN;
188 }
189 hash = jhash(name, name_len - 1, 0);
190 head = &pending_probe_table[hash & (PENDING_PROBE_HASH_SIZE - 1)];
191 e = zmalloc(sizeof(struct ust_pending_probe) + name_len);
192 if (!e)
193 return -ENOMEM;
194 memcpy(&e->name[0], name, name_len);
195 e->name[name_len - 1] = '\0';
196 e->loglevel_type = loglevel_type;
197 e->loglevel = loglevel;
198 cds_hlist_add_head(&e->node, head);
199 e->event = event;
200 event->pending_probe = e;
201 return 0;
202 }
203
204 /*
205 * remove a pending probe. called when at event teardown and when an
206 * event is fixed (probe is loaded).
207 * called with session mutex held.
208 */
209 static
210 void remove_pending_probe(struct ust_pending_probe *e)
211 {
212 if (!e)
213 return;
214 cds_hlist_del(&e->node);
215 free(e);
216 }
217
218 /*
219 * Called at library load: connect the probe on the events pending on
220 * probe load.
221 * called with session mutex held.
222 */
223 int pending_probe_fix_events(const struct lttng_event_desc *desc)
224 {
225 struct cds_hlist_head *head;
226 struct cds_hlist_node *node, *p;
227 struct ust_pending_probe *e;
228 const char *name = desc->name;
229 int ret = 0;
230 struct lttng_ust_event event_param;
231 size_t name_len = strlen(name) + 1;
232 uint32_t hash;
233
234 /* Wildcard */
235 {
236 struct wildcard_entry *wildcard;
237
238 wildcard = match_wildcard(desc);
239 if (strcmp(desc->name, "lttng_ust:metadata") && wildcard) {
240 struct session_wildcard *sw;
241
242 cds_list_for_each_entry(sw, &wildcard->session_list,
243 session_list) {
244 struct ltt_event *ev;
245 int ret;
246
247 memcpy(&event_param, &sw->event_param,
248 sizeof(event_param));
249 memcpy(event_param.name,
250 desc->name,
251 sizeof(event_param.name));
252 /* create event */
253 ret = ltt_event_create(sw->chan,
254 &event_param, &ev);
255 if (ret) {
256 DBG("Error creating event");
257 continue;
258 }
259 cds_list_add(&ev->wildcard_list,
260 &sw->events);
261 lttng_filter_event_link_bytecode(ev,
262 sw->filter_bytecode);
263 }
264 }
265 }
266
267 if (name_len > LTTNG_UST_SYM_NAME_LEN) {
268 WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN);
269 name_len = LTTNG_UST_SYM_NAME_LEN;
270 }
271 hash = jhash(name, name_len - 1, 0);
272 head = &pending_probe_table[hash & (PENDING_PROBE_HASH_SIZE - 1)];
273 cds_hlist_for_each_entry_safe(e, node, p, head, node) {
274 struct ltt_event *event;
275 struct ltt_channel *chan;
276
277 if (!ltt_loglevel_match(desc,
278 e->loglevel_type,
279 e->loglevel)) {
280 continue;
281 }
282 if (strncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1)) {
283 continue;
284 }
285 event = e->event;
286 chan = event->chan;
287 assert(!event->desc);
288 event->desc = desc;
289 event->pending_probe = NULL;
290 remove_pending_probe(e);
291 ret |= __tracepoint_probe_register(name,
292 event->desc->probe_callback,
293 event, event->desc->signature);
294 if (ret)
295 continue;
296 event->id = chan->free_event_id++;
297 ret |= _ltt_event_metadata_statedump(chan->session, chan,
298 event);
299 }
300 return ret;
301 }
302
303 void synchronize_trace(void)
304 {
305 synchronize_rcu();
306 }
307
308 struct ltt_session *ltt_session_create(void)
309 {
310 struct ltt_session *session;
311 int ret;
312
313 session = zmalloc(sizeof(struct ltt_session));
314 if (!session)
315 return NULL;
316 CDS_INIT_LIST_HEAD(&session->chan);
317 CDS_INIT_LIST_HEAD(&session->events);
318 CDS_INIT_LIST_HEAD(&session->wildcards);
319 ret = lttng_ust_uuid_generate(session->uuid);
320 if (ret != 0) {
321 session->uuid[0] = '\0';
322 }
323 cds_list_add(&session->list, &sessions);
324 return session;
325 }
326
327 void ltt_session_destroy(struct ltt_session *session)
328 {
329 struct ltt_channel *chan, *tmpchan;
330 struct ltt_event *event, *tmpevent;
331 struct session_wildcard *wildcard, *tmpwildcard;
332 int ret;
333
334 CMM_ACCESS_ONCE(session->active) = 0;
335 cds_list_for_each_entry(event, &session->events, list) {
336 ret = _ltt_event_unregister(event);
337 WARN_ON(ret);
338 }
339 synchronize_trace(); /* Wait for in-flight events to complete */
340 cds_list_for_each_entry_safe(wildcard, tmpwildcard, &session->wildcards, list)
341 _ltt_wildcard_destroy(wildcard);
342 cds_list_for_each_entry_safe(event, tmpevent, &session->events, list)
343 _ltt_event_destroy(event);
344 cds_list_for_each_entry_safe(chan, tmpchan, &session->chan, list)
345 _ltt_channel_destroy(chan);
346 cds_list_del(&session->list);
347 free(session);
348 }
349
350 int ltt_session_enable(struct ltt_session *session)
351 {
352 int ret = 0;
353 struct ltt_channel *chan;
354
355 if (session->active) {
356 ret = -EBUSY;
357 goto end;
358 }
359
360 /*
361 * Snapshot the number of events per channel to know the type of header
362 * we need to use.
363 */
364 cds_list_for_each_entry(chan, &session->chan, list) {
365 if (chan->header_type)
366 continue; /* don't change it if session stop/restart */
367 if (chan->free_event_id < 31)
368 chan->header_type = 1; /* compact */
369 else
370 chan->header_type = 2; /* large */
371 }
372
373 CMM_ACCESS_ONCE(session->active) = 1;
374 CMM_ACCESS_ONCE(session->been_active) = 1;
375 ret = _ltt_session_metadata_statedump(session);
376 if (ret)
377 CMM_ACCESS_ONCE(session->active) = 0;
378 end:
379 return ret;
380 }
381
382 int ltt_session_disable(struct ltt_session *session)
383 {
384 int ret = 0;
385
386 if (!session->active) {
387 ret = -EBUSY;
388 goto end;
389 }
390 CMM_ACCESS_ONCE(session->active) = 0;
391 end:
392 return ret;
393 }
394
395 int ltt_channel_enable(struct ltt_channel *channel)
396 {
397 int old;
398
399 if (channel == channel->session->metadata)
400 return -EPERM;
401 old = uatomic_xchg(&channel->enabled, 1);
402 if (old)
403 return -EEXIST;
404 return 0;
405 }
406
407 int ltt_channel_disable(struct ltt_channel *channel)
408 {
409 int old;
410
411 if (channel == channel->session->metadata)
412 return -EPERM;
413 old = uatomic_xchg(&channel->enabled, 0);
414 if (!old)
415 return -EEXIST;
416 return 0;
417 }
418
419 int ltt_event_enable(struct ltt_event *event)
420 {
421 int old;
422
423 if (event->chan == event->chan->session->metadata)
424 return -EPERM;
425 old = uatomic_xchg(&event->enabled, 1);
426 if (old)
427 return -EEXIST;
428 return 0;
429 }
430
431 int ltt_event_disable(struct ltt_event *event)
432 {
433 int old;
434
435 if (event->chan == event->chan->session->metadata)
436 return -EPERM;
437 old = uatomic_xchg(&event->enabled, 0);
438 if (!old)
439 return -EEXIST;
440 return 0;
441 }
442
443 struct ltt_channel *ltt_channel_create(struct ltt_session *session,
444 const char *transport_name,
445 void *buf_addr,
446 size_t subbuf_size, size_t num_subbuf,
447 unsigned int switch_timer_interval,
448 unsigned int read_timer_interval,
449 int **shm_fd, int **wait_fd,
450 uint64_t **memory_map_size,
451 struct ltt_channel *chan_priv_init)
452 {
453 struct ltt_channel *chan = NULL;
454 struct ltt_transport *transport;
455
456 if (session->been_active)
457 goto active; /* Refuse to add channel to active session */
458 transport = ltt_transport_find(transport_name);
459 if (!transport) {
460 DBG("LTTng transport %s not found\n",
461 transport_name);
462 goto notransport;
463 }
464 chan_priv_init->id = session->free_chan_id++;
465 chan_priv_init->session = session;
466 /*
467 * Note: the channel creation op already writes into the packet
468 * headers. Therefore the "chan" information used as input
469 * should be already accessible.
470 */
471 chan = transport->ops.channel_create(transport_name, buf_addr,
472 subbuf_size, num_subbuf, switch_timer_interval,
473 read_timer_interval, shm_fd, wait_fd,
474 memory_map_size, chan_priv_init);
475 if (!chan)
476 goto create_error;
477 chan->enabled = 1;
478 chan->ops = &transport->ops;
479 cds_list_add(&chan->list, &session->chan);
480 return chan;
481
482 create_error:
483 notransport:
484 active:
485 return NULL;
486 }
487
488 /*
489 * Only used internally at session destruction.
490 */
491 static
492 void _ltt_channel_destroy(struct ltt_channel *chan)
493 {
494 cds_list_del(&chan->list);
495 lttng_destroy_context(chan->ctx);
496 chan->ops->channel_destroy(chan);
497 }
498
499 /*
500 * Supports event creation while tracing session is active.
501 */
502 int ltt_event_create(struct ltt_channel *chan,
503 struct lttng_ust_event *event_param,
504 struct ltt_event **_event)
505 {
506 const struct lttng_event_desc *desc = NULL; /* silence gcc */
507 struct ltt_event *event;
508 int ret = 0;
509
510 if (chan->used_event_id == -1U) {
511 ret = -ENOMEM;
512 goto full;
513 }
514 /*
515 * This is O(n^2) (for each event, the loop is called at event
516 * creation). Might require a hash if we have lots of events.
517 */
518 cds_list_for_each_entry(event, &chan->session->events, list) {
519 if (event->desc && !strncmp(event->desc->name,
520 event_param->name,
521 LTTNG_UST_SYM_NAME_LEN - 1)) {
522 ret = -EEXIST;
523 goto exist;
524 }
525 }
526
527 /*
528 * Check if loglevel match. Refuse to connect event if not.
529 */
530 if (event_param->instrumentation == LTTNG_UST_TRACEPOINT) {
531 desc = ltt_event_get(event_param->name);
532 if (desc) {
533 if (!ltt_loglevel_match(desc,
534 event_param->loglevel_type,
535 event_param->loglevel)) {
536 ret = -EPERM;
537 goto no_loglevel_match;
538 }
539 }
540 /*
541 * If descriptor is not there, it will be added to
542 * pending probes.
543 */
544 }
545 event = zmalloc(sizeof(struct ltt_event));
546 if (!event) {
547 ret = -ENOMEM;
548 goto cache_error;
549 }
550 event->chan = chan;
551 /*
552 * used_event_id counts the maximum number of event IDs that can
553 * register if all probes register.
554 */
555 chan->used_event_id++;
556 event->enabled = 1;
557 event->instrumentation = event_param->instrumentation;
558 /* Populate ltt_event structure before tracepoint registration. */
559 cmm_smp_wmb();
560 switch (event_param->instrumentation) {
561 case LTTNG_UST_TRACEPOINT:
562 event->desc = desc;
563 if (event->desc) {
564 ret = __tracepoint_probe_register(event_param->name,
565 event->desc->probe_callback,
566 event, event->desc->signature);
567 if (ret)
568 goto register_error;
569 event->id = chan->free_event_id++;
570 } else {
571 /*
572 * If the probe is not present, event->desc stays NULL,
573 * waiting for the probe to register, and the event->id
574 * stays unallocated.
575 */
576 ret = add_pending_probe(event, event_param->name,
577 event_param->loglevel_type,
578 event_param->loglevel);
579 if (ret)
580 goto add_pending_error;
581 }
582 break;
583 default:
584 WARN_ON_ONCE(1);
585 }
586 if (event->desc) {
587 ret = _ltt_event_metadata_statedump(chan->session, chan, event);
588 if (ret)
589 goto statedump_error;
590 }
591 cds_list_add(&event->list, &chan->session->events);
592 *_event = event;
593 return 0;
594
595 statedump_error:
596 if (event->desc) {
597 WARN_ON_ONCE(__tracepoint_probe_unregister(event_param->name,
598 event->desc->probe_callback,
599 event));
600 ltt_event_put(event->desc);
601 }
602 add_pending_error:
603 register_error:
604 free(event);
605 cache_error:
606 no_loglevel_match:
607 exist:
608 full:
609 return ret;
610 }
611
612 /*
613 * Only used internally at session destruction.
614 */
615 int _ltt_event_unregister(struct ltt_event *event)
616 {
617 int ret = -EINVAL;
618
619 switch (event->instrumentation) {
620 case LTTNG_UST_TRACEPOINT:
621 if (event->desc) {
622 ret = __tracepoint_probe_unregister(event->desc->name,
623 event->desc->probe_callback,
624 event);
625 if (ret)
626 return ret;
627 } else {
628 remove_pending_probe(event->pending_probe);
629 ret = 0;
630 }
631 break;
632 default:
633 WARN_ON_ONCE(1);
634 }
635 return ret;
636 }
637
638 /*
639 * Only used internally at session destruction.
640 */
641 static
642 void _ltt_event_destroy(struct ltt_event *event)
643 {
644 switch (event->instrumentation) {
645 case LTTNG_UST_TRACEPOINT:
646 if (event->desc) {
647 ltt_event_put(event->desc);
648 }
649 break;
650 default:
651 WARN_ON_ONCE(1);
652 }
653 cds_list_del(&event->list);
654 lttng_destroy_context(event->ctx);
655 free(event->filter_bytecode);
656 free(event->filter_data);
657 free(event);
658 }
659
660 /*
661 * We have exclusive access to our metadata buffer (protected by the
662 * ust_lock), so we can do racy operations such as looking for
663 * remaining space left in packet and write, since mutual exclusion
664 * protects us from concurrent writes.
665 */
666 int lttng_metadata_printf(struct ltt_session *session,
667 const char *fmt, ...)
668 {
669 struct lttng_ust_lib_ring_buffer_ctx ctx;
670 struct ltt_channel *chan = session->metadata;
671 char *str = NULL;
672 int ret = 0, waitret;
673 size_t len, reserve_len, pos;
674 va_list ap;
675
676 WARN_ON_ONCE(!CMM_ACCESS_ONCE(session->active));
677
678 va_start(ap, fmt);
679 ret = vasprintf(&str, fmt, ap);
680 va_end(ap);
681 if (ret < 0)
682 return -ENOMEM;
683
684 len = strlen(str);
685 pos = 0;
686
687 for (pos = 0; pos < len; pos += reserve_len) {
688 reserve_len = min_t(size_t,
689 chan->ops->packet_avail_size(chan->chan, chan->handle),
690 len - pos);
691 lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len,
692 sizeof(char), -1, chan->handle);
693 /*
694 * We don't care about metadata buffer's records lost
695 * count, because we always retry here. Report error if
696 * we need to bail out after timeout or being
697 * interrupted.
698 */
699 waitret = wait_cond_interruptible_timeout(
700 ({
701 ret = chan->ops->event_reserve(&ctx, 0);
702 ret != -ENOBUFS || !ret;
703 }),
704 LTTNG_METADATA_TIMEOUT_MSEC);
705 if (waitret == -ETIMEDOUT || waitret == -EINTR || ret) {
706 DBG("LTTng: Failure to write metadata to buffers (%s)\n",
707 waitret == -EINTR ? "interrupted" :
708 (ret == -ENOBUFS ? "timeout" : "I/O error"));
709 if (waitret == -EINTR)
710 ret = waitret;
711 goto end;
712 }
713 chan->ops->event_write(&ctx, &str[pos], reserve_len);
714 chan->ops->event_commit(&ctx);
715 }
716 end:
717 free(str);
718 return ret;
719 }
720
721 static
722 int _ltt_field_statedump(struct ltt_session *session,
723 const struct lttng_event_field *field)
724 {
725 int ret = 0;
726
727 switch (field->type.atype) {
728 case atype_integer:
729 ret = lttng_metadata_printf(session,
730 " integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s;\n",
731 field->type.u.basic.integer.size,
732 field->type.u.basic.integer.alignment,
733 field->type.u.basic.integer.signedness,
734 (field->type.u.basic.integer.encoding == lttng_encode_none)
735 ? "none"
736 : (field->type.u.basic.integer.encoding == lttng_encode_UTF8)
737 ? "UTF8"
738 : "ASCII",
739 field->type.u.basic.integer.base,
740 #if (BYTE_ORDER == BIG_ENDIAN)
741 field->type.u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
742 #else
743 field->type.u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
744 #endif
745 field->name);
746 break;
747 case atype_float:
748 ret = lttng_metadata_printf(session,
749 " floating_point { exp_dig = %u; mant_dig = %u; align = %u;%s } _%s;\n",
750 field->type.u.basic._float.exp_dig,
751 field->type.u.basic._float.mant_dig,
752 field->type.u.basic._float.alignment,
753 #if (BYTE_ORDER == BIG_ENDIAN)
754 field->type.u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
755 #else
756 field->type.u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
757 #endif
758 field->name);
759 break;
760 case atype_enum:
761 ret = lttng_metadata_printf(session,
762 " %s %s;\n",
763 field->type.u.basic.enumeration.name,
764 field->name);
765 break;
766 case atype_array:
767 {
768 const struct lttng_basic_type *elem_type;
769
770 elem_type = &field->type.u.array.elem_type;
771 ret = lttng_metadata_printf(session,
772 " integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[%u];\n",
773 elem_type->u.basic.integer.size,
774 elem_type->u.basic.integer.alignment,
775 elem_type->u.basic.integer.signedness,
776 (elem_type->u.basic.integer.encoding == lttng_encode_none)
777 ? "none"
778 : (elem_type->u.basic.integer.encoding == lttng_encode_UTF8)
779 ? "UTF8"
780 : "ASCII",
781 elem_type->u.basic.integer.base,
782 #if (BYTE_ORDER == BIG_ENDIAN)
783 elem_type->u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
784 #else
785 elem_type->u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
786 #endif
787 field->name, field->type.u.array.length);
788 break;
789 }
790 case atype_sequence:
791 {
792 const struct lttng_basic_type *elem_type;
793 const struct lttng_basic_type *length_type;
794
795 elem_type = &field->type.u.sequence.elem_type;
796 length_type = &field->type.u.sequence.length_type;
797 ret = lttng_metadata_printf(session,
798 " integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } __%s_length;\n",
799 length_type->u.basic.integer.size,
800 (unsigned int) length_type->u.basic.integer.alignment,
801 length_type->u.basic.integer.signedness,
802 (length_type->u.basic.integer.encoding == lttng_encode_none)
803 ? "none"
804 : ((length_type->u.basic.integer.encoding == lttng_encode_UTF8)
805 ? "UTF8"
806 : "ASCII"),
807 length_type->u.basic.integer.base,
808 #if (BYTE_ORDER == BIG_ENDIAN)
809 length_type->u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
810 #else
811 length_type->u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
812 #endif
813 field->name);
814 if (ret)
815 return ret;
816
817 ret = lttng_metadata_printf(session,
818 " integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[ __%s_length ];\n",
819 elem_type->u.basic.integer.size,
820 (unsigned int) elem_type->u.basic.integer.alignment,
821 elem_type->u.basic.integer.signedness,
822 (elem_type->u.basic.integer.encoding == lttng_encode_none)
823 ? "none"
824 : ((elem_type->u.basic.integer.encoding == lttng_encode_UTF8)
825 ? "UTF8"
826 : "ASCII"),
827 elem_type->u.basic.integer.base,
828 #if (BYTE_ORDER == BIG_ENDIAN)
829 elem_type->u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
830 #else
831 elem_type->u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
832 #endif
833 field->name,
834 field->name);
835 break;
836 }
837
838 case atype_string:
839 /* Default encoding is UTF8 */
840 ret = lttng_metadata_printf(session,
841 " string%s _%s;\n",
842 field->type.u.basic.string.encoding == lttng_encode_ASCII ?
843 " { encoding = ASCII; }" : "",
844 field->name);
845 break;
846 default:
847 WARN_ON_ONCE(1);
848 return -EINVAL;
849 }
850 return ret;
851 }
852
853 static
854 int _ltt_context_metadata_statedump(struct ltt_session *session,
855 struct lttng_ctx *ctx)
856 {
857 int ret = 0;
858 int i;
859
860 if (!ctx)
861 return 0;
862 for (i = 0; i < ctx->nr_fields; i++) {
863 const struct lttng_ctx_field *field = &ctx->fields[i];
864
865 ret = _ltt_field_statedump(session, &field->event_field);
866 if (ret)
867 return ret;
868 }
869 return ret;
870 }
871
872 static
873 int _ltt_fields_metadata_statedump(struct ltt_session *session,
874 struct ltt_event *event)
875 {
876 const struct lttng_event_desc *desc = event->desc;
877 int ret = 0;
878 int i;
879
880 for (i = 0; i < desc->nr_fields; i++) {
881 const struct lttng_event_field *field = &desc->fields[i];
882
883 ret = _ltt_field_statedump(session, field);
884 if (ret)
885 return ret;
886 }
887 return ret;
888 }
889
890 static
891 int _ltt_event_metadata_statedump(struct ltt_session *session,
892 struct ltt_channel *chan,
893 struct ltt_event *event)
894 {
895 int ret = 0;
896 int loglevel = TRACE_DEFAULT;
897
898 if (event->metadata_dumped || !CMM_ACCESS_ONCE(session->active))
899 return 0;
900 if (chan == session->metadata)
901 return 0;
902 /*
903 * Don't print events for which probe load is pending.
904 */
905 if (!event->desc)
906 return 0;
907
908 ret = lttng_metadata_printf(session,
909 "event {\n"
910 " name = \"%s\";\n"
911 " id = %u;\n"
912 " stream_id = %u;\n",
913 event->desc->name,
914 event->id,
915 event->chan->id);
916 if (ret)
917 goto end;
918
919 if (event->desc->loglevel)
920 loglevel = *(*event->desc->loglevel);
921
922 ret = lttng_metadata_printf(session,
923 " loglevel = %d;\n",
924 loglevel);
925 if (ret)
926 goto end;
927
928 if (event->ctx) {
929 ret = lttng_metadata_printf(session,
930 " context := struct {\n");
931 if (ret)
932 goto end;
933 }
934 ret = _ltt_context_metadata_statedump(session, event->ctx);
935 if (ret)
936 goto end;
937 if (event->ctx) {
938 ret = lttng_metadata_printf(session,
939 " };\n");
940 if (ret)
941 goto end;
942 }
943
944 ret = lttng_metadata_printf(session,
945 " fields := struct {\n"
946 );
947 if (ret)
948 goto end;
949
950 ret = _ltt_fields_metadata_statedump(session, event);
951 if (ret)
952 goto end;
953
954 /*
955 * LTTng space reservation can only reserve multiples of the
956 * byte size.
957 */
958 ret = lttng_metadata_printf(session,
959 " };\n"
960 "};\n\n");
961 if (ret)
962 goto end;
963
964 event->metadata_dumped = 1;
965 end:
966 return ret;
967
968 }
969
970 static
971 int _ltt_channel_metadata_statedump(struct ltt_session *session,
972 struct ltt_channel *chan)
973 {
974 int ret = 0;
975
976 if (chan->metadata_dumped || !CMM_ACCESS_ONCE(session->active))
977 return 0;
978 if (chan == session->metadata)
979 return 0;
980
981 WARN_ON_ONCE(!chan->header_type);
982 ret = lttng_metadata_printf(session,
983 "stream {\n"
984 " id = %u;\n"
985 " event.header := %s;\n"
986 " packet.context := struct packet_context;\n",
987 chan->id,
988 chan->header_type == 1 ? "struct event_header_compact" :
989 "struct event_header_large");
990 if (ret)
991 goto end;
992
993 if (chan->ctx) {
994 ret = lttng_metadata_printf(session,
995 " event.context := struct {\n");
996 if (ret)
997 goto end;
998 }
999 ret = _ltt_context_metadata_statedump(session, chan->ctx);
1000 if (ret)
1001 goto end;
1002 if (chan->ctx) {
1003 ret = lttng_metadata_printf(session,
1004 " };\n");
1005 if (ret)
1006 goto end;
1007 }
1008
1009 ret = lttng_metadata_printf(session,
1010 "};\n\n");
1011
1012 chan->metadata_dumped = 1;
1013 end:
1014 return ret;
1015 }
1016
1017 static
1018 int _ltt_stream_packet_context_declare(struct ltt_session *session)
1019 {
1020 return lttng_metadata_printf(session,
1021 "struct packet_context {\n"
1022 " uint64_clock_monotonic_t timestamp_begin;\n"
1023 " uint64_clock_monotonic_t timestamp_end;\n"
1024 " unsigned long events_discarded;\n"
1025 " uint32_t content_size;\n"
1026 " uint32_t packet_size;\n"
1027 " uint32_t cpu_id;\n"
1028 "};\n\n"
1029 );
1030 }
1031
1032 /*
1033 * Compact header:
1034 * id: range: 0 - 30.
1035 * id 31 is reserved to indicate an extended header.
1036 *
1037 * Large header:
1038 * id: range: 0 - 65534.
1039 * id 65535 is reserved to indicate an extended header.
1040 */
1041 static
1042 int _ltt_event_header_declare(struct ltt_session *session)
1043 {
1044 return lttng_metadata_printf(session,
1045 "struct event_header_compact {\n"
1046 " enum : uint5_t { compact = 0 ... 30, extended = 31 } id;\n"
1047 " variant <id> {\n"
1048 " struct {\n"
1049 " uint27_clock_monotonic_t timestamp;\n"
1050 " } compact;\n"
1051 " struct {\n"
1052 " uint32_t id;\n"
1053 " uint64_clock_monotonic_t timestamp;\n"
1054 " } extended;\n"
1055 " } v;\n"
1056 "} align(%u);\n"
1057 "\n"
1058 "struct event_header_large {\n"
1059 " enum : uint16_t { compact = 0 ... 65534, extended = 65535 } id;\n"
1060 " variant <id> {\n"
1061 " struct {\n"
1062 " uint32_clock_monotonic_t timestamp;\n"
1063 " } compact;\n"
1064 " struct {\n"
1065 " uint32_t id;\n"
1066 " uint64_clock_monotonic_t timestamp;\n"
1067 " } extended;\n"
1068 " } v;\n"
1069 "} align(%u);\n\n",
1070 lttng_alignof(uint32_t) * CHAR_BIT,
1071 lttng_alignof(uint16_t) * CHAR_BIT
1072 );
1073 }
1074
1075 /*
1076 * Approximation of NTP time of day to clock monotonic correlation,
1077 * taken at start of trace.
1078 * Yes, this is only an approximation. Yes, we can (and will) do better
1079 * in future versions.
1080 */
1081 static
1082 uint64_t measure_clock_offset(void)
1083 {
1084 uint64_t offset, monotonic[2], realtime;
1085 struct timespec rts = { 0, 0 };
1086 int ret;
1087
1088 monotonic[0] = trace_clock_read64();
1089 ret = clock_gettime(CLOCK_REALTIME, &rts);
1090 if (ret < 0)
1091 return 0;
1092 monotonic[1] = trace_clock_read64();
1093 offset = (monotonic[0] + monotonic[1]) >> 1;
1094 realtime = (uint64_t) rts.tv_sec * 1000000000ULL;
1095 realtime += rts.tv_nsec;
1096 offset = realtime - offset;
1097 return offset;
1098 }
1099
1100 /*
1101 * Output metadata into this session's metadata buffers.
1102 */
1103 static
1104 int _ltt_session_metadata_statedump(struct ltt_session *session)
1105 {
1106 unsigned char *uuid_c = session->uuid;
1107 char uuid_s[LTTNG_UST_UUID_STR_LEN],
1108 clock_uuid_s[LTTNG_UST_UUID_STR_LEN];
1109 struct ltt_channel *chan;
1110 struct ltt_event *event;
1111 int ret = 0;
1112 char procname[LTTNG_UST_PROCNAME_LEN] = "";
1113
1114 if (!CMM_ACCESS_ONCE(session->active))
1115 return 0;
1116 if (session->metadata_dumped)
1117 goto skip_session;
1118 if (!session->metadata) {
1119 DBG("LTTng: attempt to start tracing, but metadata channel is not found. Operation abort.\n");
1120 return -EPERM;
1121 }
1122
1123 snprintf(uuid_s, sizeof(uuid_s),
1124 "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
1125 uuid_c[0], uuid_c[1], uuid_c[2], uuid_c[3],
1126 uuid_c[4], uuid_c[5], uuid_c[6], uuid_c[7],
1127 uuid_c[8], uuid_c[9], uuid_c[10], uuid_c[11],
1128 uuid_c[12], uuid_c[13], uuid_c[14], uuid_c[15]);
1129
1130 ret = lttng_metadata_printf(session,
1131 "typealias integer { size = 8; align = %u; signed = false; } := uint8_t;\n"
1132 "typealias integer { size = 16; align = %u; signed = false; } := uint16_t;\n"
1133 "typealias integer { size = 32; align = %u; signed = false; } := uint32_t;\n"
1134 "typealias integer { size = 64; align = %u; signed = false; } := uint64_t;\n"
1135 "typealias integer { size = %u; align = %u; signed = false; } := unsigned long;\n"
1136 "typealias integer { size = 5; align = 1; signed = false; } := uint5_t;\n"
1137 "typealias integer { size = 27; align = 1; signed = false; } := uint27_t;\n"
1138 "\n"
1139 "trace {\n"
1140 " major = %u;\n"
1141 " minor = %u;\n"
1142 " uuid = \"%s\";\n"
1143 " byte_order = %s;\n"
1144 " packet.header := struct {\n"
1145 " uint32_t magic;\n"
1146 " uint8_t uuid[16];\n"
1147 " uint32_t stream_id;\n"
1148 " };\n"
1149 "};\n\n",
1150 lttng_alignof(uint8_t) * CHAR_BIT,
1151 lttng_alignof(uint16_t) * CHAR_BIT,
1152 lttng_alignof(uint32_t) * CHAR_BIT,
1153 lttng_alignof(uint64_t) * CHAR_BIT,
1154 sizeof(unsigned long) * CHAR_BIT,
1155 lttng_alignof(unsigned long) * CHAR_BIT,
1156 CTF_SPEC_MAJOR,
1157 CTF_SPEC_MINOR,
1158 uuid_s,
1159 #if (BYTE_ORDER == BIG_ENDIAN)
1160 "be"
1161 #else
1162 "le"
1163 #endif
1164 );
1165 if (ret)
1166 goto end;
1167
1168 /* ignore error, just use empty string if error. */
1169 lttng_ust_getprocname(procname);
1170 procname[LTTNG_UST_PROCNAME_LEN - 1] = '\0';
1171 ret = lttng_metadata_printf(session,
1172 "env {\n"
1173 " vpid = %d;\n"
1174 " procname = \"%s\";\n"
1175 " domain = \"ust\";\n"
1176 " tracer_name = \"lttng-ust\";\n"
1177 " tracer_major = %u;\n"
1178 " tracer_minor = %u;\n"
1179 " tracer_patchlevel = %u;\n"
1180 "};\n\n",
1181 (int) getpid(),
1182 procname,
1183 LTTNG_UST_MAJOR_VERSION,
1184 LTTNG_UST_MINOR_VERSION,
1185 LTTNG_UST_PATCHLEVEL_VERSION
1186 );
1187 if (ret)
1188 goto end;
1189
1190 ret = lttng_metadata_printf(session,
1191 "clock {\n"
1192 " name = %s;\n",
1193 "monotonic"
1194 );
1195 if (ret)
1196 goto end;
1197
1198 if (!trace_clock_uuid(clock_uuid_s)) {
1199 ret = lttng_metadata_printf(session,
1200 " uuid = \"%s\";\n",
1201 clock_uuid_s
1202 );
1203 if (ret)
1204 goto end;
1205 }
1206
1207 ret = lttng_metadata_printf(session,
1208 " description = \"Monotonic Clock\";\n"
1209 " freq = %" PRIu64 "; /* Frequency, in Hz */\n"
1210 " /* clock value offset from Epoch is: offset * (1/freq) */\n"
1211 " offset = %" PRIu64 ";\n"
1212 "};\n\n",
1213 trace_clock_freq(),
1214 measure_clock_offset()
1215 );
1216 if (ret)
1217 goto end;
1218
1219 ret = lttng_metadata_printf(session,
1220 "typealias integer {\n"
1221 " size = 27; align = 1; signed = false;\n"
1222 " map = clock.monotonic.value;\n"
1223 "} := uint27_clock_monotonic_t;\n"
1224 "\n"
1225 "typealias integer {\n"
1226 " size = 32; align = %u; signed = false;\n"
1227 " map = clock.monotonic.value;\n"
1228 "} := uint32_clock_monotonic_t;\n"
1229 "\n"
1230 "typealias integer {\n"
1231 " size = 64; align = %u; signed = false;\n"
1232 " map = clock.monotonic.value;\n"
1233 "} := uint64_clock_monotonic_t;\n\n",
1234 lttng_alignof(uint32_t) * CHAR_BIT,
1235 lttng_alignof(uint64_t) * CHAR_BIT
1236 );
1237 if (ret)
1238 goto end;
1239
1240 ret = _ltt_stream_packet_context_declare(session);
1241 if (ret)
1242 goto end;
1243
1244 ret = _ltt_event_header_declare(session);
1245 if (ret)
1246 goto end;
1247
1248 skip_session:
1249 cds_list_for_each_entry(chan, &session->chan, list) {
1250 ret = _ltt_channel_metadata_statedump(session, chan);
1251 if (ret)
1252 goto end;
1253 }
1254
1255 cds_list_for_each_entry(event, &session->events, list) {
1256 ret = _ltt_event_metadata_statedump(session, event->chan, event);
1257 if (ret)
1258 goto end;
1259 }
1260 session->metadata_dumped = 1;
1261 end:
1262 return ret;
1263 }
1264
1265 void lttng_ust_events_exit(void)
1266 {
1267 struct ltt_session *session, *tmpsession;
1268
1269 cds_list_for_each_entry_safe(session, tmpsession, &sessions, list)
1270 ltt_session_destroy(session);
1271 }
1272
1273 /* WILDCARDS */
1274
1275 static
1276 int wildcard_same_loglevel(struct wildcard_entry *e,
1277 enum lttng_ust_loglevel_type loglevel_type,
1278 int loglevel)
1279 {
1280 if (e->loglevel_type == loglevel_type && e->loglevel == loglevel)
1281 return 1;
1282 else
1283 return 0;
1284 }
1285
1286 #if 0
1287 static
1288 int wildcard_is_within(struct wildcard_entry *e,
1289 enum lttng_ust_loglevel_type loglevel_type,
1290 int loglevel)
1291 {
1292 if (e->loglevel_type == LTTNG_UST_LOGLEVEL_ALL
1293 || e->loglevel == -1)
1294 return 1;
1295 switch (e->loglevel_type) {
1296 case LTTNG_UST_LOGLEVEL_RANGE:
1297 switch (loglevel_type) {
1298 case LTTNG_UST_LOGLEVEL_RANGE:
1299 if (e->loglevel >= loglevel)
1300 return 1;
1301 else
1302 return 0;
1303 case LTTNG_UST_LOGLEVEL_SINGLE:
1304 if (e->loglevel <= 0 && loglevel == 0)
1305 return 1;
1306 else
1307 return 0;
1308 }
1309 case LTTNG_UST_LOGLEVEL_SINGLE:
1310 switch (loglevel_type) {
1311 case LTTNG_UST_LOGLEVEL_RANGE:
1312 if (loglevel <= 0)
1313 return 1;
1314 else
1315 return 0;
1316 case LTTNG_UST_LOGLEVEL_SINGLE:
1317 if (e->loglevel == loglevel)
1318 return 1;
1319 else
1320 return 0;
1321 }
1322 }
1323 }
1324 #endif
1325
1326 /*
1327 * Add the wildcard to the wildcard list. Must be called with
1328 * ust lock held.
1329 */
1330 static
1331 struct session_wildcard *add_wildcard(struct ltt_channel *chan,
1332 struct lttng_ust_event *event_param)
1333 {
1334 struct wildcard_entry *e;
1335 struct session_wildcard *sw;
1336 size_t name_len = strlen(event_param->name) + 1;
1337 int found = 0;
1338
1339 /*
1340 * Try to find global wildcard entry. Given that this is shared
1341 * across all sessions, we need to check for exact loglevel
1342 * match, not just whether contained within the existing ones.
1343 */
1344 cds_list_for_each_entry(e, &wildcard_list, list) {
1345 if (!strncmp(event_param->name, e->name,
1346 LTTNG_UST_SYM_NAME_LEN - 1)) {
1347 if (wildcard_same_loglevel(e,
1348 event_param->loglevel_type,
1349 event_param->loglevel)) {
1350 found = 1;
1351 break;
1352 }
1353 }
1354 }
1355
1356 if (!found) {
1357 /*
1358 * Create global wildcard entry if not found. Using
1359 * zmalloc here to allocate a variable length element.
1360 * Could cause some memory fragmentation if overused.
1361 */
1362 e = zmalloc(sizeof(struct wildcard_entry) + name_len);
1363 if (!e)
1364 return ERR_PTR(-ENOMEM);
1365 memcpy(&e->name[0], event_param->name, name_len);
1366 e->loglevel_type = event_param->loglevel_type;
1367 e->loglevel = event_param->loglevel;
1368 cds_list_add(&e->list, &wildcard_list);
1369 CDS_INIT_LIST_HEAD(&e->session_list);
1370 }
1371
1372 /* session wildcard */
1373 cds_list_for_each_entry(sw, &e->session_list, session_list) {
1374 if (chan == sw->chan) {
1375 DBG("wildcard %s busy for this channel",
1376 event_param->name);
1377 return ERR_PTR(-EEXIST); /* Already there */
1378 }
1379 }
1380 sw = zmalloc(sizeof(struct session_wildcard));
1381 if (!sw)
1382 return ERR_PTR(-ENOMEM);
1383 sw->chan = chan;
1384 sw->enabled = 1;
1385 memcpy(&sw->event_param, event_param, sizeof(sw->event_param));
1386 sw->event_param.instrumentation = LTTNG_UST_TRACEPOINT;
1387 sw->event_param.loglevel_type = event_param->loglevel_type;
1388 sw->event_param.loglevel = event_param->loglevel;
1389 CDS_INIT_LIST_HEAD(&sw->events);
1390 cds_list_add(&sw->list, &chan->session->wildcards);
1391 cds_list_add(&sw->session_list, &e->session_list);
1392 sw->entry = e;
1393 ltt_probes_create_wildcard_events(e, sw);
1394 return sw;
1395 }
1396
1397 /*
1398 * Remove the wildcard from the wildcard list. Must be called with
1399 * ust_lock held. Only called at session teardown.
1400 */
1401 static
1402 void _remove_wildcard(struct session_wildcard *wildcard)
1403 {
1404 struct ltt_event *ev, *tmp;
1405
1406 /*
1407 * Just remove the events owned (for enable/disable) by this
1408 * wildcard from the list. The session teardown will take care
1409 * of freeing the event memory.
1410 */
1411 cds_list_for_each_entry_safe(ev, tmp, &wildcard->events,
1412 wildcard_list) {
1413 cds_list_del(&ev->wildcard_list);
1414 }
1415 cds_list_del(&wildcard->session_list);
1416 cds_list_del(&wildcard->list);
1417 if (cds_list_empty(&wildcard->entry->session_list)) {
1418 cds_list_del(&wildcard->entry->list);
1419 free(wildcard->entry);
1420 }
1421 free(wildcard->filter_bytecode);
1422 free(wildcard);
1423 }
1424
1425 int ltt_wildcard_create(struct ltt_channel *chan,
1426 struct lttng_ust_event *event_param,
1427 struct session_wildcard **_sw)
1428 {
1429 struct session_wildcard *sw;
1430
1431 sw = add_wildcard(chan, event_param);
1432 if (!sw || IS_ERR(sw)) {
1433 return PTR_ERR(sw);
1434 }
1435 *_sw = sw;
1436 return 0;
1437 }
1438
1439 static
1440 void _ltt_wildcard_destroy(struct session_wildcard *sw)
1441 {
1442 _remove_wildcard(sw);
1443 }
1444
1445 int ltt_wildcard_enable(struct session_wildcard *wildcard)
1446 {
1447 struct ltt_event *ev;
1448 int ret;
1449
1450 if (wildcard->enabled)
1451 return -EEXIST;
1452 cds_list_for_each_entry(ev, &wildcard->events, wildcard_list) {
1453 ret = ltt_event_enable(ev);
1454 if (ret) {
1455 DBG("Error: enable error.\n");
1456 return ret;
1457 }
1458 }
1459 wildcard->enabled = 1;
1460 return 0;
1461 }
1462
1463 int ltt_wildcard_disable(struct session_wildcard *wildcard)
1464 {
1465 struct ltt_event *ev;
1466 int ret;
1467
1468 if (!wildcard->enabled)
1469 return -EEXIST;
1470 cds_list_for_each_entry(ev, &wildcard->events, wildcard_list) {
1471 ret = ltt_event_disable(ev);
1472 if (ret) {
1473 DBG("Error: disable error.\n");
1474 return ret;
1475 }
1476 }
1477 wildcard->enabled = 0;
1478 return 0;
1479 }
1480
1481 /*
1482 * Take the TLS "fault" in libuuid if dlopen'd, which can take the
1483 * dynamic linker mutex, outside of the UST lock, since the UST lock is
1484 * taken in constructors, which are called with dynamic linker mutex
1485 * held.
1486 */
1487 void lttng_fixup_event_tls(void)
1488 {
1489 unsigned char uuid[LTTNG_UST_UUID_STR_LEN];
1490
1491 (void) lttng_ust_uuid_generate(uuid);
1492 }
This page took 0.059164 seconds and 4 git commands to generate.