#include <lttng/ust-ctl.h>
#include <lttng/ust-abi.h>
#include <lttng/ust-endian.h>
+#include <lttng/ust-common.h>
#include "common/logging.h"
#include "common/ustcomm.h"
#include "common/macros.h"
#include "common/align.h"
-#include "libringbuffer/backend.h"
-#include "libringbuffer/frontend.h"
-#include "liblttng-ust/ust-events-internal.h"
-#include "liblttng-ust/wait.h"
-#include "liblttng-ust/lttng-rb-clients.h"
-#include "liblttng-ust/clock.h"
-#include "liblttng-ust/getenv.h"
-#include "liblttng-ust/lttng-tracer-core.h"
-#include "liblttng-ust/lttng-counter-client.h"
+#include "common/ringbuffer/backend.h"
+#include "common/ringbuffer/frontend.h"
+#include "common/events.h"
+#include "common/wait.h"
+#include "lib/lttng-ust/lttng-rb-clients.h"
+#include "common/clock.h"
+#include "common/getenv.h"
+#include "lib/lttng-ust/lttng-tracer-core.h"
+#include "lib/lttng-ust/lttng-counter-client.h"
-#include "libcounter/shm.h"
-#include "libcounter/smp.h"
-#include "libcounter/counter.h"
+#include "common/smp.h"
+#include "common/counter/counter.h"
/*
* Number of milliseconds to retry before failing metadata writes on
* Stream representation within consumer.
*/
struct ustctl_consumer_stream {
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *chan;
int shm_fd, wait_fd, wakeup_fd;
int cpu;
const char *metadata_str, /* NOT null-terminated */
size_t len) /* metadata length */
{
- struct lttng_ust_lib_ring_buffer_ctx ctx;
+ struct lttng_ust_ring_buffer_ctx ctx;
struct lttng_ust_channel_buffer *lttng_chan_buf = channel->chan;
- struct lttng_ust_lib_ring_buffer_channel *rb_chan = lttng_chan_buf->priv->rb_chan;
+ struct lttng_ust_ring_buffer_channel *rb_chan = lttng_chan_buf->priv->rb_chan;
const char *str = metadata_str;
int ret = 0, waitret;
size_t reserve_len, pos;
reserve_len = min_t(size_t,
lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf),
len - pos);
- lttng_ust_lib_ring_buffer_ctx_init(&ctx, rb_chan, reserve_len, sizeof(char), NULL);
+ lttng_ust_ring_buffer_ctx_init(&ctx, rb_chan, reserve_len, sizeof(char), NULL);
/*
* We don't care about metadata buffer's records lost
* count, because we always retry here. Report error if
const char *metadata_str, /* NOT null-terminated */
size_t len) /* metadata length */
{
- struct lttng_ust_lib_ring_buffer_ctx ctx;
+ struct lttng_ust_ring_buffer_ctx ctx;
struct lttng_ust_channel_buffer *lttng_chan_buf = channel->chan;
- struct lttng_ust_lib_ring_buffer_channel *rb_chan = lttng_chan_buf->priv->rb_chan;
+ struct lttng_ust_ring_buffer_channel *rb_chan = lttng_chan_buf->priv->rb_chan;
const char *str = metadata_str;
ssize_t reserve_len;
int ret;
reserve_len = min_t(ssize_t,
lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf),
len);
- lttng_ust_lib_ring_buffer_ctx_init(&ctx, rb_chan, reserve_len, sizeof(char), NULL);
+ lttng_ust_ring_buffer_ctx_init(&ctx, rb_chan, reserve_len, sizeof(char), NULL);
ret = lttng_chan_buf->ops->event_reserve(&ctx);
if (ret != 0) {
DBG("LTTng: event reservation failed");
int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan)
{
- struct lttng_ust_lib_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer_channel *chan;
int ret;
chan = consumer_chan->chan->priv->rb_chan;
int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan)
{
- struct lttng_ust_lib_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer_channel *chan;
int ret;
chan = consumer_chan->chan->priv->rb_chan;
int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer_channel *chan;
chan = stream->chan->chan->priv->rb_chan;
return ring_buffer_stream_close_wait_fd(&chan->backend.config,
int ustctl_stream_close_wakeup_fd(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer_channel *chan;
chan = stream->chan->chan->priv->rb_chan;
return ring_buffer_stream_close_wakeup_fd(&chan->backend.config,
{
struct ustctl_consumer_stream *stream;
struct lttng_ust_shm_handle *handle;
- struct lttng_ust_lib_ring_buffer_channel *rb_chan;
+ struct lttng_ust_ring_buffer_channel *rb_chan;
int shm_fd, wait_fd, wakeup_fd;
uint64_t memory_map_size;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
int ret;
if (!channel)
void ustctl_destroy_stream(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
assert(stream);
int ustctl_stream_get_wait_fd(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
if (!stream)
int ustctl_stream_get_wakeup_fd(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
if (!stream)
void *ustctl_get_mmap_base(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
if (!stream)
{
struct ustctl_consumer_channel *consumer_chan;
unsigned long mmap_buf_len;
- struct lttng_ust_lib_ring_buffer_channel *rb_chan;
+ struct lttng_ust_ring_buffer_channel *rb_chan;
if (!stream)
return -EINVAL;
unsigned long *len)
{
struct ustctl_consumer_channel *consumer_chan;
- struct lttng_ust_lib_ring_buffer_channel *rb_chan;
+ struct lttng_ust_ring_buffer_channel *rb_chan;
if (!stream)
return -EINVAL;
int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream,
unsigned long *off)
{
- struct lttng_ust_lib_ring_buffer_channel *rb_chan;
+ struct lttng_ust_ring_buffer_channel *rb_chan;
unsigned long sb_bindex;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
- struct lttng_ust_lib_ring_buffer_backend_pages_shmp *barray_idx;
- struct lttng_ust_lib_ring_buffer_backend_pages *pages;
+ struct lttng_ust_ring_buffer_backend_pages_shmp *barray_idx;
+ struct lttng_ust_ring_buffer_backend_pages *pages;
if (!stream)
return -EINVAL;
unsigned long *len)
{
struct ustctl_consumer_channel *consumer_chan;
- struct lttng_ust_lib_ring_buffer_channel *rb_chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *rb_chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream)
return -EINVAL;
unsigned long *len)
{
struct ustctl_consumer_channel *consumer_chan;
- struct lttng_ust_lib_ring_buffer_channel *rb_chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *rb_chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream)
return -EINVAL;
/* Get exclusive read access to the next sub-buffer that can be read. */
int ustctl_get_next_subbuf(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
if (!stream)
/* Release exclusive sub-buffer access, move consumer forward. */
int ustctl_put_next_subbuf(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
if (!stream)
/* Get a snapshot of the current ring buffer producer and consumer positions */
int ustctl_snapshot(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
if (!stream)
*/
int ustctl_snapshot_sample_positions(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
if (!stream)
int ustctl_snapshot_get_consumed(struct ustctl_consumer_stream *stream,
unsigned long *pos)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
if (!stream)
return -EINVAL;
int ustctl_snapshot_get_produced(struct ustctl_consumer_stream *stream,
unsigned long *pos)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
if (!stream)
return -EINVAL;
int ustctl_get_subbuf(struct ustctl_consumer_stream *stream,
unsigned long *pos)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
if (!stream)
/* Release exclusive sub-buffer access */
int ustctl_put_subbuf(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
if (!stream)
void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
int producer_active)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
assert(stream);
void ustctl_clear_buffer(struct ustctl_consumer_stream *stream)
{
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer *buf;
struct ustctl_consumer_channel *consumer_chan;
assert(stream);
static
struct lttng_ust_client_lib_ring_buffer_client_cb *get_client_cb(
- struct lttng_ust_lib_ring_buffer *buf __attribute__((unused)),
- struct lttng_ust_lib_ring_buffer_channel *chan)
+ struct lttng_ust_ring_buffer *buf __attribute__((unused)),
+ struct lttng_ust_ring_buffer_channel *chan)
{
- const struct lttng_ust_lib_ring_buffer_config *config;
+ const struct lttng_ust_ring_buffer_config *config;
struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
config = &chan->backend.config;
uint64_t *timestamp_begin)
{
struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
- struct lttng_ust_lib_ring_buffer_channel *chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream || !timestamp_begin)
return -EINVAL;
uint64_t *timestamp_end)
{
struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
- struct lttng_ust_lib_ring_buffer_channel *chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream || !timestamp_end)
return -EINVAL;
uint64_t *events_discarded)
{
struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
- struct lttng_ust_lib_ring_buffer_channel *chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream || !events_discarded)
return -EINVAL;
uint64_t *content_size)
{
struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
- struct lttng_ust_lib_ring_buffer_channel *chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream || !content_size)
return -EINVAL;
uint64_t *packet_size)
{
struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
- struct lttng_ust_lib_ring_buffer_channel *chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream || !packet_size)
return -EINVAL;
uint64_t *stream_id)
{
struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
- struct lttng_ust_lib_ring_buffer_channel *chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream || !stream_id)
return -EINVAL;
uint64_t *ts)
{
struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
- struct lttng_ust_lib_ring_buffer_channel *chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream || !ts)
return -EINVAL;
uint64_t *seq)
{
struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
- struct lttng_ust_lib_ring_buffer_channel *chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream || !seq)
return -EINVAL;
uint64_t *id)
{
struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
- struct lttng_ust_lib_ring_buffer_channel *chan;
- struct lttng_ust_lib_ring_buffer *buf;
+ struct lttng_ust_ring_buffer_channel *chan;
+ struct lttng_ust_ring_buffer *buf;
if (!stream || !id)
return -EINVAL;
return len;
if (reg_msg.magic == LTTNG_UST_ABI_COMM_MAGIC) {
- *byte_order = BYTE_ORDER == BIG_ENDIAN ?
- BIG_ENDIAN : LITTLE_ENDIAN;
- } else if (reg_msg.magic == bswap_32(LTTNG_UST_ABI_COMM_MAGIC)) {
- *byte_order = BYTE_ORDER == BIG_ENDIAN ?
- LITTLE_ENDIAN : BIG_ENDIAN;
+ *byte_order = LTTNG_UST_BYTE_ORDER == LTTNG_UST_BIG_ENDIAN ?
+ LTTNG_UST_BIG_ENDIAN : LTTNG_UST_LITTLE_ENDIAN;
+ } else if (reg_msg.magic == lttng_ust_bswap_32(LTTNG_UST_ABI_COMM_MAGIC)) {
+ *byte_order = LTTNG_UST_BYTE_ORDER == LTTNG_UST_BIG_ENDIAN ?
+ LTTNG_UST_LITTLE_ENDIAN : LTTNG_UST_BIG_ENDIAN;
} else {
return -LTTNG_UST_ERR_INVAL_MAGIC;
}
int ustctl_get_nr_cpu_per_counter(void)
{
- return lttng_counter_num_possible_cpus();
+ return num_possible_cpus();
}
struct ustctl_daemon_counter *
}
static
-void ustctl_init(void)
+void lttng_ust_ctl_ctor(void)
__attribute__((constructor));
static
-void ustctl_init(void)
+void lttng_ust_ctl_ctor(void)
{
- ust_err_init();
- lttng_ust_getenv_init(); /* Needs ust_err_init() to be completed. */
+ /*
+ * Call the liblttng-ust-common constructor to ensure it runs first.
+ */
+ lttng_ust_common_ctor();
+
lttng_ust_clock_init();
lttng_ust_ring_buffer_clients_init();
lttng_ust_counter_clients_init();