*/
unsigned int tsc_bits;
struct lttng_ust_lib_ring_buffer_client_cb cb;
+ /*
+ * client_type is used by the consumer process (which is in a
+ * different address space) to lookup the appropriate client
+ * callbacks and update the cb pointers.
+ */
+ int client_type;
};
/*
struct ltt_session;
struct lttng_ust_lib_ring_buffer_ctx;
+/*
+ * LTTng client type enumeration. Used by the consumer to map the
+ * callbacks from its own address space.
+ */
+enum lttng_client_types {
+ LTTNG_CLIENT_METADATA = 0,
+ LTTNG_CLIENT_DISCARD = 1,
+ LTTNG_CLIENT_OVERWRITE = 2,
+ LTTNG_NR_CLIENT_TYPES,
+};
+
/* Type description */
/* Update the astract_types name table in lttng-types.c along with this enum */
void lttng_context_vtid_reset(void);
void lttng_context_vpid_reset(void);
+const struct lttng_ust_lib_ring_buffer_config *lttng_client_callbacks_metadata;
+const struct lttng_ust_lib_ring_buffer_config *lttng_client_callbacks_discard;
+const struct lttng_ust_lib_ring_buffer_config *lttng_client_callbacks_overwrite;
+
+struct cds_list_head ltt_transport_list;
+struct ltt_transport *ltt_transport_find(const char *name);
+
#endif /* _UST_LTTNG_EVENTS_H */
liblttng_ust_ctl_la_LIBADD = \
$(top_builddir)/liblttng-ust-comm/liblttng-ust-comm.la \
- $(top_builddir)/libringbuffer/libringbuffer.la \
+ $(top_builddir)/liblttng-ust/liblttng-ust-support.la \
$(top_builddir)/snprintf/libustsnprintf.la
#include <lttng/ust-abi.h>
#include <lttng/usterr-signal-safe.h>
#include <lttng/ust-comm.h>
+#include <lttng/ust-events.h>
#include "../libringbuffer/backend.h"
#include "../libringbuffer/frontend.h"
struct lttng_ust_shm_handle *handle;
struct channel *chan;
size_t chan_size;
+ struct lttng_ust_lib_ring_buffer_config *config;
handle = channel_handle_create(chan_data->shm_fd,
chan_data->wait_fd,
memcpy(handle->shadow_chan, chan, chan_size);
/*
* The callback pointers in the producer are invalid in the
- * consumer. Zero them out.
+ * consumer. We need to look them up here.
*/
- memset(&handle->shadow_chan->backend.config.cb, 0,
- sizeof(handle->shadow_chan->backend.config.cb));
+ config = &handle->shadow_chan->backend.config;
+ switch (config->client_type) {
+ case LTTNG_CLIENT_METADATA:
+ memcpy(&config->cb, lttng_client_callbacks_metadata,
+ sizeof(config->cb));
+ break;
+ case LTTNG_CLIENT_DISCARD:
+ memcpy(&config->cb, lttng_client_callbacks_discard,
+ sizeof(config->cb));
+ break;
+ case LTTNG_CLIENT_OVERWRITE:
+ memcpy(&config->cb, lttng_client_callbacks_overwrite,
+ sizeof(config->cb));
+ break;
+ default:
+ ERR("Unknown client type %d", config->client_type);
+ channel_destroy(chan, handle, 1);
+ return NULL;
+ }
return handle;
}
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CFLAGS = -fno-strict-aliasing
+noinst_LTLIBRARIES = liblttng-ust-runtime.la liblttng-ust-support.la
+
lib_LTLIBRARIES = liblttng-ust.la
-liblttng_ust_la_SOURCES = \
- tracepoint.c \
- ltt-tracer.h \
- ltt-tracer-core.h \
- ltt-ring-buffer-client.h \
- ltt-ring-buffer-client-discard.c \
- ltt-ring-buffer-client-overwrite.c \
- ltt-ring-buffer-metadata-client.h \
- ltt-ring-buffer-metadata-client.c \
- ltt-events.c \
- ltt-probes.c \
- lttng-ust-abi.c \
+liblttng_ust_runtime_la_SOURCES = \
lttng-ust-comm.c \
- ust-core.c \
+ lttng-ust-abi.c \
+ ltt-probes.c \
probes/lttng-probe-ust.c \
probes/lttng-probe-ust.h \
lttng-context-vtid.c \
lttng-context-vpid.c \
lttng-context-pthread-id.c \
lttng-context-procname.c \
- ltt-context.c
+ ltt-context.c \
+ ltt-events.c \
+ tracepoint.c
+
+liblttng_ust_support_la_SOURCES = \
+ ltt-tracer.h \
+ ltt-tracer-core.h \
+ ust-core.c \
+ ltt-ring-buffer-client.h \
+ ltt-ring-buffer-client-discard.c \
+ ltt-ring-buffer-client-overwrite.c \
+ ltt-ring-buffer-metadata-client.h \
+ ltt-ring-buffer-metadata-client.c
+
+liblttng_ust_la_SOURCES =
liblttng_ust_la_LDFLAGS = -no-undefined -version-info 0:0:0
+liblttng_ust_support_la_LIBADD = \
+ $(top_builddir)/libringbuffer/libringbuffer.la
+
liblttng_ust_la_LIBADD = \
-lpthread \
-lrt \
-luuid \
$(top_builddir)/snprintf/libustsnprintf.la \
- $(top_builddir)/libringbuffer/libringbuffer.la \
- $(top_builddir)/liblttng-ust-comm/liblttng-ust-comm.la
+ $(top_builddir)/liblttng-ust-comm/liblttng-ust-comm.la \
+ liblttng-ust-runtime.la liblttng-ust-support.la
liblttng_ust_la_CFLAGS = -DUST_COMPONENT="liblttng-ust" -fno-strict-aliasing
}
static CDS_LIST_HEAD(sessions);
-static CDS_LIST_HEAD(ltt_transport_list);
/*
* Pending probes hash table, containing the registered ltt events for
return 0;
}
-static struct ltt_transport *ltt_transport_find(const char *name)
-{
- struct ltt_transport *transport;
-
- cds_list_for_each_entry(transport, <t_transport_list, node) {
- if (!strcmp(transport->name, name))
- return transport;
- }
- return NULL;
-}
-
struct ltt_channel *ltt_channel_create(struct ltt_session *session,
const char *transport_name,
void *buf_addr,
return ret;
}
-/**
- * ltt_transport_register - LTT transport registration
- * @transport: transport structure
- *
- * Registers a transport which can be used as output to extract the data out of
- * LTTng. Called with ust_lock held.
- */
-void ltt_transport_register(struct ltt_transport *transport)
-{
- cds_list_add_tail(&transport->node, <t_transport_list);
-}
-
-/**
- * ltt_transport_unregister - LTT transport unregistration
- * @transport: transport structure
- * Called with ust_lock held.
- */
-void ltt_transport_unregister(struct ltt_transport *transport)
-{
- cds_list_del(&transport->node);
-}
-
void lttng_ust_events_exit(void)
{
struct ltt_session *session, *tmpsession;
ltt_ring_buffer_client_discard_init
#define RING_BUFFER_MODE_TEMPLATE_EXIT \
ltt_ring_buffer_client_discard_exit
+#define LTTNG_CLIENT_TYPE LTTNG_CLIENT_DISCARD
+#define LTTNG_CLIENT_CALLBACKS lttng_client_callbacks_discard
#include "ltt-ring-buffer-client.h"
ltt_ring_buffer_client_overwrite_init
#define RING_BUFFER_MODE_TEMPLATE_EXIT \
ltt_ring_buffer_client_overwrite_exit
+#define LTTNG_CLIENT_TYPE LTTNG_CLIENT_OVERWRITE
+#define LTTNG_CLIENT_CALLBACKS lttng_client_callbacks_overwrite
#include "ltt-ring-buffer-client.h"
.oops = RING_BUFFER_OOPS_CONSISTENCY,
.ipi = RING_BUFFER_NO_IPI_BARRIER,
.wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
+ .client_type = LTTNG_CLIENT_TYPE,
};
+const struct lttng_ust_lib_ring_buffer_config *LTTNG_CLIENT_CALLBACKS = &client_config;
+
static
struct ltt_channel *_channel_create(const char *name,
struct ltt_channel *ltt_chan, void *buf_addr,
ltt_ring_buffer_metadata_client_init
#define RING_BUFFER_MODE_TEMPLATE_EXIT \
ltt_ring_buffer_metadata_client_exit
+#define LTTNG_CLIENT_TYPE LTTNG_CLIENT_METADATA
+#define LTTNG_CLIENT_CALLBACKS lttng_client_callbacks_metadata
#include "ltt-ring-buffer-metadata-client.h"
.oops = RING_BUFFER_OOPS_CONSISTENCY,
.ipi = RING_BUFFER_NO_IPI_BARRIER,
.wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
+ .client_type = LTTNG_CLIENT_TYPE,
};
+const struct lttng_ust_lib_ring_buffer_config *LTTNG_CLIENT_CALLBACKS = &client_config;
+
static
struct ltt_channel *_channel_create(const char *name,
struct ltt_channel *ltt_chan, void *buf_addr,
*/
#include <lttng/usterr-signal-safe.h>
+#include <lttng/ust-events.h>
#include <stdlib.h>
+CDS_LIST_HEAD(ltt_transport_list);
+
volatile enum ust_loglevel ust_loglevel;
void init_usterr(void)
ust_loglevel = UST_LOGLEVEL_NORMAL;
}
}
+
+struct ltt_transport *ltt_transport_find(const char *name)
+{
+ struct ltt_transport *transport;
+
+ cds_list_for_each_entry(transport, <t_transport_list, node) {
+ if (!strcmp(transport->name, name))
+ return transport;
+ }
+ return NULL;
+}
+
+/**
+ * ltt_transport_register - LTT transport registration
+ * @transport: transport structure
+ *
+ * Registers a transport which can be used as output to extract the data out of
+ * LTTng. Called with ust_lock held.
+ */
+void ltt_transport_register(struct ltt_transport *transport)
+{
+ cds_list_add_tail(&transport->node, <t_transport_list);
+}
+
+/**
+ * ltt_transport_unregister - LTT transport unregistration
+ * @transport: transport structure
+ * Called with ust_lock held.
+ */
+void ltt_transport_unregister(struct ltt_transport *transport)
+{
+ cds_list_del(&transport->node);
+}
/* Calculate the shm allocation layout */
shmsize = sizeof(struct channel);
+ shmsize += offset_align(shmsize, __alignof__(struct lttng_ust_lib_ring_buffer_shmp));
if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
shmsize += sizeof(struct lttng_ust_lib_ring_buffer_shmp) * num_possible_cpus();
else
if (!shmobj)
goto error_append;
/* struct channel is at object 0, offset 0 (hardcoded) */
- set_shmp(handle->chan, zalloc_shm(shmobj, sizeof(struct channel)));
+ set_shmp(handle->chan, zalloc_shm(shmobj, shmsize));
assert(handle->chan._ref.index == 0);
assert(handle->chan._ref.offset == 0);
chan = shmp(handle, handle->chan);