[lttng-dev] [UST PATCH 3/3] Export the stream instance ID.

Julien Desfossez jdesfossez at efficios.com
Mon Jul 13 11:12:09 EDT 2015


Allow the lttng-consumer to query the stream instance ID.

Signed-off-by: Julien Desfossez <jdesfossez at efficios.com>
---
 include/lttng/ust-ctl.h                 |  2 ++
 liblttng-ust-ctl/ustctl.c               | 18 ++++++++++++++++++
 liblttng-ust/lttng-rb-clients.h         |  2 ++
 liblttng-ust/lttng-ring-buffer-client.h | 13 +++++++++++++
 4 files changed, 35 insertions(+)

diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h
index d27ca8a..b246a51 100644
--- a/include/lttng/ust-ctl.h
+++ b/include/lttng/ust-ctl.h
@@ -243,6 +243,8 @@ int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream,
 		uint64_t *ts);
 int ustctl_get_sequence_number(struct ustctl_consumer_stream *stream,
 		uint64_t *seq);
+int ustctl_get_instance_id(struct ustctl_consumer_stream *stream,
+		uint64_t *id);
 
 /* returns whether UST has perf counters support. */
 int ustctl_has_perf_counters(void);
diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c
index 010dfd8..43fce9e 100644
--- a/liblttng-ust-ctl/ustctl.c
+++ b/liblttng-ust-ctl/ustctl.c
@@ -1663,6 +1663,24 @@ int ustctl_get_sequence_number(struct ustctl_consumer_stream *stream,
 	return client_cb->sequence_number(buf, handle, seq);
 }
 
+int ustctl_get_instance_id(struct ustctl_consumer_stream *stream,
+		uint64_t *id)
+{
+	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
+	struct lttng_ust_lib_ring_buffer *buf;
+	struct lttng_ust_shm_handle *handle;
+
+	if (!stream || !id)
+		return -EINVAL;
+	buf = stream->buf;
+	handle = stream->chan->chan->handle;
+	client_cb = get_client_cb(buf, handle);
+	if (!client_cb)
+		return -ENOSYS;
+	return client_cb->instance_id(buf, handle, id);
+}
+
+
 #if defined(__x86_64__) || defined(__i386__)
 
 int ustctl_has_perf_counters(void)
diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
index 788f075..e54decb 100644
--- a/liblttng-ust/lttng-rb-clients.h
+++ b/liblttng-ust/lttng-rb-clients.h
@@ -45,6 +45,8 @@ struct lttng_ust_client_lib_ring_buffer_client_cb {
 			uint64_t *ts);
 	int (*sequence_number) (struct lttng_ust_lib_ring_buffer *buf,
 		struct lttng_ust_shm_handle *handle, uint64_t *seq);
+	int (*instance_id) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle, uint64_t *id);
 };
 
 #endif /* _LTTNG_RB_CLIENT_H */
diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h
index 1e93cff..63df2f9 100644
--- a/liblttng-ust/lttng-ring-buffer-client.h
+++ b/liblttng-ust/lttng-ring-buffer-client.h
@@ -516,6 +516,18 @@ static int client_sequence_number(struct lttng_ust_lib_ring_buffer *buf,
 	return 0;
 }
 
+static int client_instance_id(struct lttng_ust_lib_ring_buffer *buf,
+		struct lttng_ust_shm_handle *handle,
+		uint64_t *id)
+{
+	struct packet_header *header;
+
+	header = client_packet_header(buf, handle);
+	*id = header->stream_instance_id;
+	return 0;
+}
+
+
 static const
 struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
 	.parent = {
@@ -537,6 +549,7 @@ struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
 	.stream_id = client_stream_id,
 	.current_timestamp = client_current_timestamp,
 	.sequence_number = client_sequence_number,
+	.instance_id = client_instance_id,
 };
 
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
-- 
1.9.1




More information about the lttng-dev mailing list