2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 #include <lttng/ust-ringbuffer-context.h>
14 #include "common/logging.h"
15 #include "common/tracer.h"
16 #include "common/jhash.h"
20 * Each library using the transports will have its local lists.
22 static CDS_LIST_HEAD(lttng_transport_list
);
23 static CDS_LIST_HEAD(lttng_counter_transport_list
);
25 struct lttng_transport
*lttng_ust_transport_find(const char *name
)
27 struct lttng_transport
*transport
;
29 cds_list_for_each_entry(transport
, <tng_transport_list
, node
) {
30 if (!strcmp(transport
->name
, name
))
36 struct lttng_counter_transport
*lttng_counter_transport_find(const char *name
)
38 struct lttng_counter_transport
*transport
;
40 cds_list_for_each_entry(transport
, <tng_counter_transport_list
, node
) {
41 if (!strcmp(transport
->name
, name
))
48 * lttng_transport_register - LTT transport registration
49 * @transport: transport structure
51 * Registers a transport which can be used as output to extract the data out of
52 * LTTng. Called with ust_lock held.
54 void lttng_transport_register(struct lttng_transport
*transport
)
56 cds_list_add_tail(&transport
->node
, <tng_transport_list
);
60 * lttng_transport_unregister - LTT transport unregistration
61 * @transport: transport structure
62 * Called with ust_lock held.
64 void lttng_transport_unregister(struct lttng_transport
*transport
)
66 cds_list_del(&transport
->node
);
70 * lttng_counter_transport_register - LTTng counter transport registration
71 * @transport: transport structure
73 * Registers a counter transport which can be used as output to extract
74 * the data out of LTTng. Called with ust_lock held.
76 void lttng_counter_transport_register(struct lttng_counter_transport
*transport
)
78 cds_list_add_tail(&transport
->node
, <tng_counter_transport_list
);
82 * lttng_counter_transport_unregister - LTTng counter transport unregistration
83 * @transport: transport structure
84 * Called with ust_lock held.
86 void lttng_counter_transport_unregister(struct lttng_counter_transport
*transport
)
88 cds_list_del(&transport
->node
);
91 size_t lttng_ust_dummy_get_size(void *priv
__attribute__((unused
)),
92 struct lttng_ust_probe_ctx
*probe_ctx
__attribute__((unused
)),
97 size
+= lttng_ust_ring_buffer_align(offset
, lttng_ust_rb_alignof(char));
98 size
+= sizeof(char); /* tag */
102 void lttng_ust_dummy_record(void *priv
__attribute__((unused
)),
103 struct lttng_ust_probe_ctx
*probe_ctx
__attribute__((unused
)),
104 struct lttng_ust_ring_buffer_ctx
*ctx
,
105 struct lttng_ust_channel_buffer
*chan
)
107 char sel_char
= (char) LTTNG_UST_DYNAMIC_TYPE_NONE
;
109 chan
->ops
->event_write(ctx
, &sel_char
, sizeof(sel_char
), lttng_ust_rb_alignof(sel_char
));
112 void lttng_ust_dummy_get_value(void *priv
__attribute__((unused
)),
113 struct lttng_ust_probe_ctx
*probe_ctx
__attribute__((unused
)),
114 struct lttng_ust_ctx_value
*value
)
116 value
->sel
= LTTNG_UST_DYNAMIC_TYPE_NONE
;
119 int lttng_context_is_app(const char *name
)
121 if (strncmp(name
, "$app.", strlen("$app.")) != 0) {
127 struct lttng_ust_channel_buffer
*lttng_ust_alloc_channel_buffer(void)
129 struct lttng_ust_channel_buffer
*lttng_chan_buf
;
130 struct lttng_ust_channel_common
*lttng_chan_common
;
131 struct lttng_ust_channel_buffer_private
*lttng_chan_buf_priv
;
133 lttng_chan_buf
= zmalloc(sizeof(struct lttng_ust_channel_buffer
));
135 goto lttng_chan_buf_error
;
136 lttng_chan_buf
->struct_size
= sizeof(struct lttng_ust_channel_buffer
);
137 lttng_chan_common
= zmalloc(sizeof(struct lttng_ust_channel_common
));
138 if (!lttng_chan_common
)
139 goto lttng_chan_common_error
;
140 lttng_chan_common
->struct_size
= sizeof(struct lttng_ust_channel_common
);
141 lttng_chan_buf_priv
= zmalloc(sizeof(struct lttng_ust_channel_buffer_private
));
142 if (!lttng_chan_buf_priv
)
143 goto lttng_chan_buf_priv_error
;
144 lttng_chan_buf
->parent
= lttng_chan_common
;
145 lttng_chan_common
->type
= LTTNG_UST_CHANNEL_TYPE_BUFFER
;
146 lttng_chan_common
->child
= lttng_chan_buf
;
147 lttng_chan_buf
->priv
= lttng_chan_buf_priv
;
148 lttng_chan_common
->priv
= <tng_chan_buf_priv
->parent
;
149 lttng_chan_buf_priv
->pub
= lttng_chan_buf
;
150 lttng_chan_buf_priv
->parent
.pub
= lttng_chan_common
;
152 return lttng_chan_buf
;
154 lttng_chan_buf_priv_error
:
155 free(lttng_chan_common
);
156 lttng_chan_common_error
:
157 free(lttng_chan_buf
);
158 lttng_chan_buf_error
:
162 void lttng_ust_free_channel_common(struct lttng_ust_channel_common
*chan
)
164 switch (chan
->type
) {
165 case LTTNG_UST_CHANNEL_TYPE_BUFFER
:
167 struct lttng_ust_channel_buffer
*chan_buf
;
169 chan_buf
= (struct lttng_ust_channel_buffer
*)chan
->child
;
170 free(chan_buf
->parent
);
171 free(chan_buf
->priv
);