Commit | Line | Data |
---|---|---|
5e96a467 MD |
1 | /* |
2 | * ust-core.c | |
3 | * | |
4 | * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
8 | * License as published by the Free Software Foundation; only | |
9 | * version 2.1 of the License. | |
10 | * | |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
17 | * License along with this library; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
3fbec7dc | 21 | #define _LGPL_SOURCE |
5e96a467 | 22 | #include <stdlib.h> |
44c72f10 MD |
23 | #include <lttng/ust-events.h> |
24 | #include <usterr-signal-safe.h> | |
797b05f6 | 25 | #include "lttng-tracer-core.h" |
c785c634 | 26 | #include "jhash.h" |
5e96a467 | 27 | |
7dd08bec | 28 | static CDS_LIST_HEAD(lttng_transport_list); |
c1fca457 | 29 | |
7dd08bec | 30 | struct lttng_transport *lttng_transport_find(const char *name) |
c1fca457 | 31 | { |
7dd08bec | 32 | struct lttng_transport *transport; |
c1fca457 | 33 | |
7dd08bec | 34 | cds_list_for_each_entry(transport, <tng_transport_list, node) { |
c1fca457 MD |
35 | if (!strcmp(transport->name, name)) |
36 | return transport; | |
37 | } | |
38 | return NULL; | |
39 | } | |
40 | ||
41 | /** | |
7dd08bec | 42 | * lttng_transport_register - LTT transport registration |
c1fca457 MD |
43 | * @transport: transport structure |
44 | * | |
45 | * Registers a transport which can be used as output to extract the data out of | |
46 | * LTTng. Called with ust_lock held. | |
47 | */ | |
7dd08bec | 48 | void lttng_transport_register(struct lttng_transport *transport) |
c1fca457 | 49 | { |
7dd08bec | 50 | cds_list_add_tail(&transport->node, <tng_transport_list); |
c1fca457 MD |
51 | } |
52 | ||
53 | /** | |
7dd08bec | 54 | * lttng_transport_unregister - LTT transport unregistration |
c1fca457 MD |
55 | * @transport: transport structure |
56 | * Called with ust_lock held. | |
57 | */ | |
7dd08bec | 58 | void lttng_transport_unregister(struct lttng_transport *transport) |
c1fca457 MD |
59 | { |
60 | cds_list_del(&transport->node); | |
61 | } | |
c785c634 MD |
62 | |
63 | /* | |
64 | * Needed by comm layer. | |
65 | */ | |
b33b46f7 FD |
66 | struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session, |
67 | const struct lttng_enum_desc *enum_desc) | |
c785c634 MD |
68 | { |
69 | struct lttng_enum *_enum; | |
70 | struct cds_hlist_head *head; | |
71 | struct cds_hlist_node *node; | |
b33b46f7 | 72 | size_t name_len = strlen(enum_desc->name); |
c785c634 MD |
73 | uint32_t hash; |
74 | ||
b33b46f7 | 75 | hash = jhash(enum_desc->name, name_len, 0); |
c785c634 MD |
76 | head = &session->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)]; |
77 | cds_hlist_for_each_entry(_enum, node, head, hlist) { | |
78 | assert(_enum->desc); | |
b33b46f7 | 79 | if (_enum->desc == enum_desc) |
c785c634 MD |
80 | return _enum; |
81 | } | |
82 | return NULL; | |
83 | } | |
797b05f6 MD |
84 | |
85 | size_t lttng_ust_dummy_get_size(struct lttng_ctx_field *field, size_t offset) | |
86 | { | |
87 | size_t size = 0; | |
88 | ||
89 | size += lib_ring_buffer_align(offset, lttng_alignof(char)); | |
90 | size += sizeof(char); /* tag */ | |
91 | return size; | |
92 | } | |
93 | ||
94 | void lttng_ust_dummy_record(struct lttng_ctx_field *field, | |
95 | struct lttng_ust_lib_ring_buffer_ctx *ctx, | |
96 | struct lttng_channel *chan) | |
97 | { | |
98 | char sel_char = (char) LTTNG_UST_DYNAMIC_TYPE_NONE; | |
99 | ||
100 | lib_ring_buffer_align_ctx(ctx, lttng_alignof(sel_char)); | |
101 | chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); | |
102 | } | |
103 | ||
104 | void lttng_ust_dummy_get_value(struct lttng_ctx_field *field, | |
105 | struct lttng_ctx_value *value) | |
106 | { | |
107 | value->sel = LTTNG_UST_DYNAMIC_TYPE_NONE; | |
108 | } | |
ce47f5d8 MD |
109 | |
110 | int lttng_context_is_app(const char *name) | |
111 | { | |
112 | if (strncmp(name, "$app.", strlen("$app.")) != 0) { | |
113 | return 0; | |
114 | } | |
115 | return 1; | |
116 | } |