From 45a00b05b7e0fc627f98fa15775d451c595117a9 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Tue, 7 Jul 2015 13:08:16 -0400 Subject: [PATCH] Export the stream instance ID Allow the lttng-consumer to query the stream instance ID. Signed-off-by: Julien Desfossez Acked-by: Mathieu Desnoyers Signed-off-by: Mathieu Desnoyers --- include/lttng/ust-ctl.h | 2 ++ liblttng-ust-ctl/ustctl.c | 17 +++++++++++++++++ liblttng-ust/lttng-rb-clients.h | 2 ++ liblttng-ust/lttng-ring-buffer-client.h | 12 ++++++++++++ 4 files changed, 33 insertions(+) diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h index f62c5022..379ad41f 100644 --- a/include/lttng/ust-ctl.h +++ b/include/lttng/ust-ctl.h @@ -254,6 +254,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 fcb6f0d5..0165786c 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -1725,6 +1725,23 @@ 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 788f0754..e54decbe 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 07dc4700..9e22b93e 100644 --- a/liblttng-ust/lttng-ring-buffer-client.h +++ b/liblttng-ust/lttng-ring-buffer-client.h @@ -520,6 +520,17 @@ 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 = { @@ -541,6 +552,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 = { -- 2.34.1