From: Francis Giraldeau <[email protected]>

Pass same arguments to get_size_arg() than to record(). This new
operation has the same effect than get_size(), and the client code can
implement either one.

Signed-off-by: Francis Giraldeau <[email protected]>
Signed-off-by: Mathieu Desnoyers <[email protected]>
---
 lttng-events.h             |  3 +++
 lttng-ring-buffer-client.h | 17 ++++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/lttng-events.h b/lttng-events.h
index f55bf66..7a618be 100644
--- a/lttng-events.h
+++ b/lttng-events.h
@@ -204,6 +204,9 @@ struct lttng_probe_ctx {
 struct lttng_ctx_field {
        struct lttng_event_field event_field;
        size_t (*get_size)(size_t offset);
+       size_t (*get_size_arg)(size_t offset, struct lttng_ctx_field *field,
+                              struct lib_ring_buffer_ctx *ctx,
+                              struct lttng_channel *chan);
        void (*record)(struct lttng_ctx_field *field,
                       struct lib_ring_buffer_ctx *ctx,
                       struct lttng_channel *chan);
diff --git a/lttng-ring-buffer-client.h b/lttng-ring-buffer-client.h
index 63f2b4c..db3e1ad 100644
--- a/lttng-ring-buffer-client.h
+++ b/lttng-ring-buffer-client.h
@@ -83,7 +83,9 @@ static inline notrace u64 lib_ring_buffer_clock_read(struct 
channel *chan)
 }
 
 static inline
-size_t ctx_get_size(size_t offset, struct lttng_ctx *ctx)
+size_t ctx_get_size(size_t offset, struct lib_ring_buffer_ctx *bufctx,
+                    struct lttng_channel *chan,
+                    struct lttng_ctx *ctx)
 {
        int i;
        size_t orig_offset = offset;
@@ -91,8 +93,13 @@ size_t ctx_get_size(size_t offset, struct lttng_ctx *ctx)
        if (likely(!ctx))
                return 0;
        offset += lib_ring_buffer_align(offset, ctx->largest_align);
-       for (i = 0; i < ctx->nr_fields; i++)
-               offset += ctx->fields[i].get_size(offset);
+       for (i = 0; i < ctx->nr_fields; i++) {
+               if (ctx->fields[i].get_size)
+                       offset += ctx->fields[i].get_size(offset);
+               if (ctx->fields[i].get_size_arg)
+                       offset += ctx->fields[i].get_size_arg(offset,
+                                       &ctx->fields[i], bufctx, chan);
+       }
        return offset - orig_offset;
 }
 
@@ -170,8 +177,8 @@ size_t record_header_size(const struct 
lib_ring_buffer_config *config,
                padding = 0;
                WARN_ON_ONCE(1);
        }
-       offset += ctx_get_size(offset, lttng_chan->ctx);
-       offset += ctx_get_size(offset, event->ctx);
+       offset += ctx_get_size(offset, ctx, lttng_chan, event->ctx);
+       offset += ctx_get_size(offset, ctx, lttng_chan, lttng_chan->ctx);
 
        *pre_header_padding = padding;
        return offset - orig_offset;
-- 
2.1.4

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Reply via email to