From b2e37d27accf5e32128b82392dbe1a9522c7dc20 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 22 Apr 2021 08:46:18 -0400 Subject: [PATCH] API refactoring: introduce probe context Introduce a "probe context" to allow passing the "ip" context from the probe function to the get_value callback used by the bytecode interpreter. This enables the "ip" context to be used from the filter bytecode and from the capture bytecode. Also fix signedness of the return type of the get_value context callbacks for cases where the type is unsigned. Signed-off-by: Mathieu Desnoyers Change-Id: I2cb40a9b3bb34c42392bb663368e5af360554dbb --- include/lttng/ust-events.h | 23 ++++++++++++- include/lttng/ust-ringbuffer-context.h | 9 ++--- include/lttng/ust-tracepoint-event.h | 32 +++++++++-------- src/common/events.h | 12 ++++--- src/common/ust-context-provider.h | 12 ++++--- .../jni/common/lttng_ust_context.c | 7 ++-- src/lib/lttng-ust/context-provider-internal.h | 7 ++-- .../lttng-ust/event-notifier-notification.c | 3 +- src/lib/lttng-ust/events.h | 19 +++++++---- .../lttng-ust/lttng-bytecode-interpreter.c | 34 +++++++++++-------- src/lib/lttng-ust/lttng-bytecode.h | 2 ++ src/lib/lttng-ust/lttng-context-cgroup-ns.c | 9 +++-- src/lib/lttng-ust/lttng-context-cpu-id.c | 7 ++-- src/lib/lttng-ust/lttng-context-ip.c | 19 ++++++++--- src/lib/lttng-ust/lttng-context-ipc-ns.c | 9 +++-- src/lib/lttng-ust/lttng-context-mnt-ns.c | 9 +++-- src/lib/lttng-ust/lttng-context-net-ns.c | 9 +++-- .../lttng-ust/lttng-context-perf-counters.c | 9 +++-- src/lib/lttng-ust/lttng-context-pid-ns.c | 9 +++-- src/lib/lttng-ust/lttng-context-procname.c | 7 ++-- src/lib/lttng-ust/lttng-context-pthread-id.c | 9 +++-- src/lib/lttng-ust/lttng-context-time-ns.c | 9 +++-- src/lib/lttng-ust/lttng-context-user-ns.c | 9 +++-- src/lib/lttng-ust/lttng-context-uts-ns.c | 9 +++-- src/lib/lttng-ust/lttng-context-vegid.c | 9 +++-- src/lib/lttng-ust/lttng-context-veuid.c | 9 +++-- src/lib/lttng-ust/lttng-context-vgid.c | 9 +++-- src/lib/lttng-ust/lttng-context-vpid.c | 7 ++-- src/lib/lttng-ust/lttng-context-vsgid.c | 9 +++-- src/lib/lttng-ust/lttng-context-vsuid.c | 9 +++-- src/lib/lttng-ust/lttng-context-vtid.c | 7 ++-- src/lib/lttng-ust/lttng-context-vuid.c | 9 +++-- src/lib/lttng-ust/lttng-context.c | 9 +++-- src/lib/lttng-ust/lttng-events.c | 18 ++++++---- .../lttng-ring-buffer-client-template.h | 11 +++--- src/lib/lttng-ust/lttng-tracer-core.h | 12 ++++--- src/lib/lttng-ust/ust-core.c | 7 ++-- tests/compile/test-app-ctx/hello.c | 6 +++- 38 files changed, 280 insertions(+), 134 deletions(-) diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 5e94bafe..cae9e71a 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -300,6 +300,26 @@ struct lttng_ust_probe_desc { /* Data structures used by the tracer. */ +/* + * IMPORTANT: this structure is part of the ABI between the probe and + * UST. Fields need to be only added at the end, never reordered, never + * removed. + * + * The field @struct_size should be used to determine the size of the + * structure. It should be queried before using additional fields added + * at the end of the structure. + * + * The probe_ctx is not const because it may be extended to add future + * fields which could be modified by callbacks. + */ +struct lttng_ust_probe_ctx { + uint32_t struct_size; /* Size of this structure. */ + + void *ip; /* caller ip address */ + + /* End of base ABI. Fields below should be used after checking struct_size. */ +}; + /* * lttng_event structure is referred to by the tracing fast path. It * must be kept small. @@ -351,6 +371,7 @@ struct lttng_ust_event_common { int eval_filter; /* Need to evaluate filters */ int (*run_filter)(const struct lttng_ust_event_common *event, const char *stack_data, + struct lttng_ust_probe_ctx *probe_ctx, void *filter_ctx); /* End of base ABI. Fields below should be used after checking struct_size. */ @@ -395,7 +416,6 @@ struct lttng_ust_event_recorder { struct lttng_ust_notification_ctx { uint32_t struct_size; /* Size of this structure. */ int eval_capture; /* Capture evaluation available. */ - /* End of base ABI. Fields below should be used after checking struct_size. */ }; @@ -424,6 +444,7 @@ struct lttng_ust_event_notifier { int eval_capture; /* Need to evaluate capture */ void (*notification_send)(const struct lttng_ust_event_notifier *event_notifier, const char *stack_data, + struct lttng_ust_probe_ctx *probe_ctx, struct lttng_ust_notification_ctx *notif_ctx); /* End of base ABI. Fields below should be used after checking struct_size. */ diff --git a/include/lttng/ust-ringbuffer-context.h b/include/lttng/ust-ringbuffer-context.h index 133d802d..70ec2440 100644 --- a/include/lttng/ust-ringbuffer-context.h +++ b/include/lttng/ust-ringbuffer-context.h @@ -23,6 +23,7 @@ struct lttng_ust_ring_buffer; struct lttng_ust_ring_buffer_channel; struct lttng_ust_ring_buffer_ctx; struct lttng_ust_ring_buffer_ctx_private; +struct lttng_ust_probe_ctx; /* * ring buffer context @@ -44,7 +45,7 @@ struct lttng_ust_ring_buffer_ctx { * alignment of the largest element * in the payload */ - void *ip; /* caller ip address */ + struct lttng_ust_probe_ctx *probe_ctx; /* Probe context */ /* Private ring buffer context, set by reserve callback. */ struct lttng_ust_ring_buffer_ctx_private *priv; @@ -63,18 +64,18 @@ struct lttng_ust_ring_buffer_ctx { static inline void lttng_ust_ring_buffer_ctx_init(struct lttng_ust_ring_buffer_ctx *ctx, void *client_priv, size_t data_size, int largest_align, - void *ip) + struct lttng_ust_probe_ctx *probe_ctx) lttng_ust_notrace; static inline void lttng_ust_ring_buffer_ctx_init(struct lttng_ust_ring_buffer_ctx *ctx, void *client_priv, size_t data_size, int largest_align, - void *ip) + struct lttng_ust_probe_ctx *probe_ctx) { ctx->struct_size = sizeof(struct lttng_ust_ring_buffer_ctx); ctx->client_priv = client_priv; ctx->data_size = data_size; ctx->largest_align = largest_align; - ctx->ip = ip; + ctx->probe_ctx = probe_ctx; ctx->priv = NULL; } diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 801ccda4..9678b83c 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -880,16 +880,17 @@ size_t lttng_ust__event_get_align__##_provider##___##_name(LTTNG_UST__TP_ARGS_PR * Perform UNION (||) of filter runtime list. */ #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS -#define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ +#define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ static \ -void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \ +void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \ lttng_ust_notrace; \ static \ -void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \ +void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \ { \ struct lttng_ust_event_common *__event = (struct lttng_ust_event_common *) __tp_data; \ size_t __dynamic_len_idx = 0; \ const size_t __num_fields = LTTNG_UST__TP_ARRAY_SIZE(lttng_ust__event_fields___##_provider##___##_name) - 1; \ + struct lttng_ust_probe_ctx __probe_ctx; \ union { \ size_t __dynamic_len[__num_fields]; \ char __interpreter_stack_data[2 * sizeof(unsigned long) * __num_fields]; \ @@ -906,7 +907,7 @@ void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PRO struct lttng_ust_channel_buffer *__chan = lttng_ust__event_recorder->chan; \ struct lttng_ust_channel_common *__chan_common = __chan->parent; \ \ - if (!LTTNG_UST__TP_SESSION_CHECK(session, __chan_common->session)) \ + if (!LTTNG_UST__TP_SESSION_CHECK(session, __chan_common->session)) \ return; \ if (caa_unlikely(!CMM_ACCESS_ONCE(__chan_common->session->active))) \ return; \ @@ -919,29 +920,31 @@ void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PRO } \ if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \ return; \ - if (caa_unlikely(!LTTNG_UST_TP_RCU_LINK_TEST())) \ + if (caa_unlikely(!LTTNG_UST_TP_RCU_LINK_TEST())) \ return; \ - if (caa_unlikely(CMM_ACCESS_ONCE(__event->eval_filter))) { \ + __probe_ctx.struct_size = sizeof(struct lttng_ust_probe_ctx); \ + __probe_ctx.ip = LTTNG_UST__TP_IP_PARAM(LTTNG_UST_TP_IP_PARAM); \ + if (caa_unlikely(CMM_ACCESS_ONCE(__event->eval_filter))) { \ lttng_ust__event_prepare_interpreter_stack__##_provider##___##_name(__stackvar.__interpreter_stack_data, \ - LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \ + LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \ __interpreter_stack_prepared = true; \ - if (caa_likely(__event->run_filter(__event, \ - __stackvar.__interpreter_stack_data, NULL) != LTTNG_UST_EVENT_FILTER_ACCEPT)) \ + if (caa_likely(__event->run_filter(__event, \ + __stackvar.__interpreter_stack_data, &__probe_ctx, NULL) != LTTNG_UST_EVENT_FILTER_ACCEPT)) \ return; \ } \ switch (__event->type) { \ case LTTNG_UST_EVENT_TYPE_RECORDER: \ { \ - size_t __event_len, lttng_ust__event_align; \ + size_t __event_len, lttng_ust__event_align; \ struct lttng_ust_event_recorder *lttng_ust__event_recorder = (struct lttng_ust_event_recorder *) __event->child; \ struct lttng_ust_channel_buffer *__chan = lttng_ust__event_recorder->chan; \ - struct lttng_ust_ring_buffer_ctx __ctx; \ + struct lttng_ust_ring_buffer_ctx __ctx; \ \ __event_len = lttng_ust__event_get_size__##_provider##___##_name(__stackvar.__dynamic_len, \ LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \ lttng_ust__event_align = lttng_ust__event_get_align__##_provider##___##_name(LTTNG_UST__TP_ARGS_VAR(_args)); \ lttng_ust_ring_buffer_ctx_init(&__ctx, lttng_ust__event_recorder, __event_len, lttng_ust__event_align, \ - LTTNG_UST__TP_IP_PARAM(LTTNG_UST_TP_IP_PARAM)); \ + &__probe_ctx); \ __ret = __chan->ops->event_reserve(&__ctx); \ if (__ret < 0) \ return; \ @@ -959,10 +962,11 @@ void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PRO \ if (caa_unlikely(!__interpreter_stack_prepared && __notif_ctx.eval_capture)) \ lttng_ust__event_prepare_interpreter_stack__##_provider##___##_name(__stackvar.__interpreter_stack_data, \ - LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \ + LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \ \ - lttng_ust__event_notifier->notification_send(lttng_ust__event_notifier, \ + lttng_ust__event_notifier->notification_send(lttng_ust__event_notifier, \ __stackvar.__interpreter_stack_data, \ + &__probe_ctx, \ &__notif_ctx); \ break; \ } \ diff --git a/src/common/events.h b/src/common/events.h index 5fdec870..bba28cc2 100644 --- a/src/common/events.h +++ b/src/common/events.h @@ -305,6 +305,7 @@ struct lttng_ust_bytecode_runtime { int link_failed; int (*interpreter_func)(struct lttng_ust_bytecode_runtime *bytecode_runtime, const char *interpreter_stack_data, + struct lttng_ust_probe_ctx *probe_ctx, void *ctx); struct cds_list_head node; /* list of bytecode runtime in event */ /* @@ -441,10 +442,13 @@ struct lttng_ust_registered_probe { struct lttng_ust_ctx_field { const struct lttng_ust_event_field *event_field; - size_t (*get_size)(void *priv, size_t offset); - void (*record)(void *priv, struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan); - void (*get_value)(void *priv, struct lttng_ust_ctx_value *value); + size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + size_t offset); + void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan); + void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ctx_value *value); void (*destroy)(void *priv); void *priv; }; diff --git a/src/common/ust-context-provider.h b/src/common/ust-context-provider.h index c9362fb1..d8c9a138 100644 --- a/src/common/ust-context-provider.h +++ b/src/common/ust-context-provider.h @@ -17,6 +17,7 @@ #include "common/dynamic-type.h" struct lttng_ust_registered_context_provider; +struct lttng_ust_probe_ctx; /* * Context value @@ -54,10 +55,13 @@ struct lttng_ust_context_provider { uint32_t struct_size; const char *name; - size_t (*get_size)(void *priv, size_t offset); - void (*record)(void *priv, struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan); - void (*get_value)(void *priv, struct lttng_ust_ctx_value *value); + size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + size_t offset); + void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan); + void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ctx_value *value); void *priv; /* End of base ABI. Fields below should be used after checking struct_size. */ diff --git a/src/lib/lttng-ust-java-agent/jni/common/lttng_ust_context.c b/src/lib/lttng-ust-java-agent/jni/common/lttng_ust_context.c index 6f6d0e06..4f4fa9b7 100644 --- a/src/lib/lttng-ust-java-agent/jni/common/lttng_ust_context.c +++ b/src/lib/lttng-ust-java-agent/jni/common/lttng_ust_context.c @@ -79,7 +79,8 @@ static struct lttng_ust_jni_ctx_entry *lookup_ctx_by_name(const char *ctx_name) return NULL; } -static size_t get_size_cb(void *priv, size_t offset) +static size_t get_size_cb(void *priv, struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + size_t offset) { struct lttng_ust_jni_ctx_entry *jctx; size_t size = 0; @@ -142,6 +143,7 @@ static size_t get_size_cb(void *priv, size_t offset) } static void record_cb(void *priv, + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ring_buffer_ctx *ctx, struct lttng_ust_channel_buffer *lttng_chan_buf) { @@ -247,7 +249,8 @@ static void record_cb(void *priv, } } -static void get_value_cb(void *priv, struct lttng_ust_ctx_value *value) +static void get_value_cb(void *priv, struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ctx_value *value) { struct lttng_ust_jni_provider *jni_provider = (struct lttng_ust_jni_provider *) priv; struct lttng_ust_jni_ctx_entry *jctx; diff --git a/src/lib/lttng-ust/context-provider-internal.h b/src/lib/lttng-ust/context-provider-internal.h index f9ee9b29..92de7dff 100644 --- a/src/lib/lttng-ust/context-provider-internal.h +++ b/src/lib/lttng-ust/context-provider-internal.h @@ -11,11 +11,12 @@ #include void lttng_ust_context_set_event_notifier_group_provider(const char *name, - size_t (*get_size)(void *priv, size_t offset), - void (*record)(void *priv, + size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + size_t offset), + void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, struct lttng_ust_ring_buffer_ctx *ctx, struct lttng_ust_channel_buffer *chan), - void (*get_value)(void *priv, + void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, struct lttng_ust_ctx_value *value), void *priv) __attribute__((visibility("hidden"))); diff --git a/src/lib/lttng-ust/event-notifier-notification.c b/src/lib/lttng-ust/event-notifier-notification.c index fe228c5d..d4849421 100644 --- a/src/lib/lttng-ust/event-notifier-notification.c +++ b/src/lib/lttng-ust/event-notifier-notification.c @@ -362,6 +362,7 @@ void notification_send(struct lttng_event_notifier_notification *notif, void lttng_event_notifier_notification_send( const struct lttng_ust_event_notifier *event_notifier, const char *stack_data, + struct lttng_ust_probe_ctx *probe_ctx, struct lttng_ust_notification_ctx *notif_ctx) { /* @@ -386,7 +387,7 @@ void lttng_event_notifier_notification_send( struct lttng_interpreter_output output; if (capture_bc_runtime->interpreter_func(capture_bc_runtime, - stack_data, &output) == LTTNG_UST_BYTECODE_INTERPRETER_OK) + stack_data, probe_ctx, &output) == LTTNG_UST_BYTECODE_INTERPRETER_OK) notification_append_capture(¬if, &output); else notification_append_empty_capture(¬if); diff --git a/src/lib/lttng-ust/events.h b/src/lib/lttng-ust/events.h index bf76d7a3..d928a0e1 100644 --- a/src/lib/lttng-ust/events.h +++ b/src/lib/lttng-ust/events.h @@ -302,6 +302,7 @@ void lttng_ust_free_channel_common(struct lttng_ust_channel_common *chan) int lttng_ust_interpret_event_filter(const struct lttng_ust_event_common *event, const char *interpreter_stack_data, + struct lttng_ust_probe_ctx *probe_ctx, void *filter_ctx) __attribute__((visibility("hidden"))); @@ -321,18 +322,24 @@ int lttng_ust_add_app_context_to_ctx_rcu(const char *name, struct lttng_ust_ctx int lttng_ust_context_set_provider_rcu(struct lttng_ust_ctx **_ctx, const char *name, - size_t (*get_size)(void *priv, size_t offset), - void (*record)(void *priv, struct lttng_ust_ring_buffer_ctx *ctx, + size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + size_t offset), + void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ring_buffer_ctx *ctx, struct lttng_ust_channel_buffer *chan), - void (*get_value)(void *priv, struct lttng_ust_ctx_value *value), + void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ctx_value *value), void *priv) __attribute__((visibility("hidden"))); void lttng_ust_context_set_session_provider(const char *name, - size_t (*get_size)(void *priv, size_t offset), - void (*record)(void *priv, struct lttng_ust_ring_buffer_ctx *ctx, + size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + size_t offset), + void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ring_buffer_ctx *ctx, struct lttng_ust_channel_buffer *chan), - void (*get_value)(void *priv, struct lttng_ust_ctx_value *value), + void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ctx_value *value), void *priv) __attribute__((visibility("hidden"))); diff --git a/src/lib/lttng-ust/lttng-bytecode-interpreter.c b/src/lib/lttng-ust/lttng-bytecode-interpreter.c index 0afa8ae6..d677fb99 100644 --- a/src/lib/lttng-ust/lttng-bytecode-interpreter.c +++ b/src/lib/lttng-ust/lttng-bytecode-interpreter.c @@ -153,6 +153,7 @@ int stack_strcmp(struct estack *stack, int top, const char *cmp_type __attribute int lttng_bytecode_interpret_error( struct lttng_ust_bytecode_runtime *bytecode_runtime __attribute__((unused)), const char *stack_data __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), void *ctx __attribute__((unused))) { return LTTNG_UST_BYTECODE_INTERPRETER_ERROR; @@ -215,6 +216,7 @@ LABEL_##name (reg_type == REG_U64 || reg_type == REG_S64) static int context_get_index(struct lttng_ust_ctx *ctx, + struct lttng_ust_probe_ctx *probe_ctx, struct load_ptr *ptr, uint32_t idx) { @@ -230,7 +232,7 @@ static int context_get_index(struct lttng_ust_ctx *ctx, switch (field->type->type) { case lttng_ust_type_integer: - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); if (lttng_ust_get_type_integer(field->type)->signedness) { ptr->object_type = OBJECT_TYPE_S64; ptr->u.s64 = v.u.s64; @@ -246,7 +248,7 @@ static int context_get_index(struct lttng_ust_ctx *ctx, const struct lttng_ust_type_integer *itype; itype = lttng_ust_get_type_integer(lttng_ust_get_type_enum(field->type)->container_type); - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); if (itype->signedness) { ptr->object_type = OBJECT_TYPE_SIGNED_ENUM; ptr->u.s64 = v.u.s64; @@ -268,7 +270,7 @@ static int context_get_index(struct lttng_ust_ctx *ctx, return -EINVAL; } ptr->object_type = OBJECT_TYPE_STRING; - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); ptr->ptr = v.u.str; break; case lttng_ust_type_sequence: @@ -281,22 +283,22 @@ static int context_get_index(struct lttng_ust_ctx *ctx, return -EINVAL; } ptr->object_type = OBJECT_TYPE_STRING; - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); ptr->ptr = v.u.str; break; case lttng_ust_type_string: ptr->object_type = OBJECT_TYPE_STRING; - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); ptr->ptr = v.u.str; break; case lttng_ust_type_float: ptr->object_type = OBJECT_TYPE_DOUBLE; - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); ptr->u.d = v.u.d; ptr->ptr = &ptr->u.d; break; case lttng_ust_type_dynamic: - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); switch (v.sel) { case LTTNG_UST_DYNAMIC_TYPE_NONE: return -EINVAL; @@ -343,6 +345,7 @@ static int context_get_index(struct lttng_ust_ctx *ctx, } static int dynamic_get_index(struct lttng_ust_ctx *ctx, + struct lttng_ust_probe_ctx *probe_ctx, struct bytecode_runtime *runtime, uint64_t index, struct estack_entry *stack_top) { @@ -403,6 +406,7 @@ static int dynamic_get_index(struct lttng_ust_ctx *ctx, case LOAD_ROOT_APP_CONTEXT: /* Fall-through */ { ret = context_get_index(ctx, + probe_ctx, &stack_top->u.ptr, gid->ctx_index); if (ret) { @@ -711,6 +715,7 @@ again: */ int lttng_bytecode_interpret(struct lttng_ust_bytecode_runtime *ust_bytecode, const char *interpreter_stack_data, + struct lttng_ust_probe_ctx *probe_ctx, void *caller_ctx) { struct bytecode_runtime *bytecode = caa_container_of(ust_bytecode, struct bytecode_runtime, p); @@ -2138,7 +2143,7 @@ int lttng_bytecode_interpret(struct lttng_ust_bytecode_runtime *ust_bytecode, dbg_printf("get context ref offset %u type dynamic\n", ref->offset); ctx_field = &ctx->fields[ref->offset]; - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); estack_push(stack, top, ax, bx, ax_t, bx_t); switch (v.sel) { case LTTNG_UST_DYNAMIC_TYPE_NONE: @@ -2186,7 +2191,7 @@ int lttng_bytecode_interpret(struct lttng_ust_bytecode_runtime *ust_bytecode, dbg_printf("get context ref offset %u type string\n", ref->offset); ctx_field = &ctx->fields[ref->offset]; - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); estack_push(stack, top, ax, bx, ax_t, bx_t); estack_ax(stack, top)->u.s.str = v.u.str; if (unlikely(!estack_ax(stack, top)->u.s.str)) { @@ -2213,7 +2218,7 @@ int lttng_bytecode_interpret(struct lttng_ust_bytecode_runtime *ust_bytecode, dbg_printf("get context ref offset %u type s64\n", ref->offset); ctx_field = &ctx->fields[ref->offset]; - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); estack_push(stack, top, ax, bx, ax_t, bx_t); estack_ax_v = v.u.s64; estack_ax_t = REG_S64; @@ -2232,7 +2237,7 @@ int lttng_bytecode_interpret(struct lttng_ust_bytecode_runtime *ust_bytecode, dbg_printf("get context ref offset %u type double\n", ref->offset); ctx_field = &ctx->fields[ref->offset]; - ctx_field->get_value(ctx_field->priv, &v); + ctx_field->get_value(ctx_field->priv, probe_ctx, &v); estack_push(stack, top, ax, bx, ax_t, bx_t); memcpy(&estack_ax(stack, top)->u.d, &v.u.d, sizeof(struct literal_double)); estack_ax_t = REG_DOUBLE; @@ -2316,7 +2321,7 @@ int lttng_bytecode_interpret(struct lttng_ust_bytecode_runtime *ust_bytecode, struct get_index_u16 *index = (struct get_index_u16 *) insn->data; dbg_printf("op get index u16\n"); - ret = dynamic_get_index(ctx, bytecode, index->index, estack_ax(stack, top)); + ret = dynamic_get_index(ctx, probe_ctx, bytecode, index->index, estack_ax(stack, top)); if (ret) goto end; estack_ax_v = estack_ax(stack, top)->u.v; @@ -2331,7 +2336,7 @@ int lttng_bytecode_interpret(struct lttng_ust_bytecode_runtime *ust_bytecode, struct get_index_u64 *index = (struct get_index_u64 *) insn->data; dbg_printf("op get index u64\n"); - ret = dynamic_get_index(ctx, bytecode, index->index, estack_ax(stack, top)); + ret = dynamic_get_index(ctx, probe_ctx, bytecode, index->index, estack_ax(stack, top)); if (ret) goto end; estack_ax_v = estack_ax(stack, top)->u.v; @@ -2513,6 +2518,7 @@ end: */ int lttng_ust_interpret_event_filter(const struct lttng_ust_event_common *event, const char *interpreter_stack_data, + struct lttng_ust_probe_ctx *probe_ctx, void *event_filter_ctx __attribute__((unused))) { struct lttng_ust_bytecode_runtime *filter_bc_runtime; @@ -2522,7 +2528,7 @@ int lttng_ust_interpret_event_filter(const struct lttng_ust_event_common *event, cds_list_for_each_entry_rcu(filter_bc_runtime, filter_bytecode_runtime_head, node) { if (caa_likely(filter_bc_runtime->interpreter_func(filter_bc_runtime, - interpreter_stack_data, &bytecode_filter_ctx) == LTTNG_UST_BYTECODE_INTERPRETER_OK)) { + interpreter_stack_data, probe_ctx, &bytecode_filter_ctx) == LTTNG_UST_BYTECODE_INTERPRETER_OK)) { if (caa_unlikely(bytecode_filter_ctx.result == LTTNG_UST_BYTECODE_FILTER_ACCEPT)) { filter_record = true; break; diff --git a/src/lib/lttng-ust/lttng-bytecode.h b/src/lib/lttng-ust/lttng-bytecode.h index 46f72120..d8f2413c 100644 --- a/src/lib/lttng-ust/lttng-bytecode.h +++ b/src/lib/lttng-ust/lttng-bytecode.h @@ -330,11 +330,13 @@ int lttng_bytecode_specialize(const struct lttng_ust_event_desc *event_desc, int lttng_bytecode_interpret_error(struct lttng_ust_bytecode_runtime *bytecode_runtime, const char *stack_data, + struct lttng_ust_probe_ctx *probe_ctx, void *ctx) __attribute__((visibility("hidden"))); int lttng_bytecode_interpret(struct lttng_ust_bytecode_runtime *bytecode_runtime, const char *stack_data, + struct lttng_ust_probe_ctx *probe_ctx, void *ctx) __attribute__((visibility("hidden"))); diff --git a/src/lib/lttng-ust/lttng-context-cgroup-ns.c b/src/lib/lttng-ust/lttng-context-cgroup-ns.c index 3f86f175..fa67a64c 100644 --- a/src/lib/lttng-ust/lttng-context-cgroup-ns.c +++ b/src/lib/lttng-ust/lttng-context-cgroup-ns.c @@ -92,6 +92,7 @@ void lttng_context_cgroup_ns_reset(void) static size_t cgroup_ns_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -103,8 +104,9 @@ size_t cgroup_ns_get_size(void *priv __attribute__((unused)), static void cgroup_ns_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { ino_t cgroup_ns; @@ -115,9 +117,10 @@ void cgroup_ns_record(void *priv __attribute__((unused)), static void cgroup_ns_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_cgroup_ns(); + value->u.u64 = get_cgroup_ns(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-cpu-id.c b/src/lib/lttng-ust/lttng-context-cpu-id.c index 0b87bd3c..37e8327f 100644 --- a/src/lib/lttng-ust/lttng-context-cpu-id.c +++ b/src/lib/lttng-ust/lttng-context-cpu-id.c @@ -26,6 +26,7 @@ static size_t cpu_id_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -37,8 +38,9 @@ size_t cpu_id_get_size(void *priv __attribute__((unused)), static void cpu_id_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { int cpu; @@ -48,6 +50,7 @@ void cpu_id_record(void *priv __attribute__((unused)), static void cpu_id_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { value->u.s64 = lttng_ust_get_cpu(); diff --git a/src/lib/lttng-ust/lttng-context-ip.c b/src/lib/lttng-ust/lttng-context-ip.c index 00ed8b06..bc22ce29 100644 --- a/src/lib/lttng-ust/lttng-context-ip.c +++ b/src/lib/lttng-ust/lttng-context-ip.c @@ -19,6 +19,7 @@ static size_t ip_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -30,15 +31,24 @@ size_t ip_get_size(void *priv __attribute__((unused)), static void ip_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { void *ip; - ip = ctx->ip; + ip = probe_ctx->ip; chan->ops->event_write(ctx, &ip, sizeof(ip), lttng_ust_rb_alignof(ip)); } +static +void ip_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ctx_value *value) +{ + value->u.u64 = (unsigned long) probe_ctx->ip; +} + static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( lttng_ust_static_event_field("ip", lttng_ust_static_type_integer(sizeof(void *) * CHAR_BIT, @@ -48,7 +58,8 @@ static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( false, false), ip_get_size, ip_record, - NULL, NULL, NULL); + ip_get_value, + NULL, NULL); int lttng_add_ip_to_ctx(struct lttng_ust_ctx **ctx) { diff --git a/src/lib/lttng-ust/lttng-context-ipc-ns.c b/src/lib/lttng-ust/lttng-context-ipc-ns.c index fcf6b0cc..96267ef9 100644 --- a/src/lib/lttng-ust/lttng-context-ipc-ns.c +++ b/src/lib/lttng-ust/lttng-context-ipc-ns.c @@ -91,6 +91,7 @@ void lttng_context_ipc_ns_reset(void) static size_t ipc_ns_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -102,8 +103,9 @@ size_t ipc_ns_get_size(void *priv __attribute__((unused)), static void ipc_ns_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { ino_t ipc_ns; @@ -113,9 +115,10 @@ void ipc_ns_record(void *priv __attribute__((unused)), static void ipc_ns_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_ipc_ns(); + value->u.u64 = get_ipc_ns(); } const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-mnt-ns.c b/src/lib/lttng-ust/lttng-context-mnt-ns.c index d62bc860..e83b9bbe 100644 --- a/src/lib/lttng-ust/lttng-context-mnt-ns.c +++ b/src/lib/lttng-ust/lttng-context-mnt-ns.c @@ -74,6 +74,7 @@ void lttng_context_mnt_ns_reset(void) static size_t mnt_ns_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -85,8 +86,9 @@ size_t mnt_ns_get_size(void *priv __attribute__((unused)), static void mnt_ns_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { ino_t mnt_ns; @@ -96,9 +98,10 @@ void mnt_ns_record(void *priv __attribute__((unused)), static void mnt_ns_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_mnt_ns(); + value->u.u64 = get_mnt_ns(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-net-ns.c b/src/lib/lttng-ust/lttng-context-net-ns.c index 5b269c61..6982a351 100644 --- a/src/lib/lttng-ust/lttng-context-net-ns.c +++ b/src/lib/lttng-ust/lttng-context-net-ns.c @@ -91,6 +91,7 @@ void lttng_context_net_ns_reset(void) static size_t net_ns_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -102,8 +103,9 @@ size_t net_ns_get_size(void *priv __attribute__((unused)), static void net_ns_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { ino_t net_ns; @@ -113,9 +115,10 @@ void net_ns_record(void *priv __attribute__((unused)), static void net_ns_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_net_ns(); + value->u.u64 = get_net_ns(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-perf-counters.c b/src/lib/lttng-ust/lttng-context-perf-counters.c index 5a7dec4a..1d44a54a 100644 --- a/src/lib/lttng-ust/lttng-context-perf-counters.c +++ b/src/lib/lttng-ust/lttng-context-perf-counters.c @@ -161,6 +161,7 @@ void lttng_perf_unlock(void) static size_t perf_counter_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -442,8 +443,9 @@ uint64_t wrapper_perf_counter_read(void *priv) static void perf_counter_record(void *priv, - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { uint64_t value; @@ -453,9 +455,10 @@ void perf_counter_record(void *priv, static void perf_counter_get_value(void *priv, + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = wrapper_perf_counter_read(priv); + value->u.u64 = wrapper_perf_counter_read(priv); } /* Called with perf lock held */ diff --git a/src/lib/lttng-ust/lttng-context-pid-ns.c b/src/lib/lttng-ust/lttng-context-pid-ns.c index f1bb48fa..e944140e 100644 --- a/src/lib/lttng-ust/lttng-context-pid-ns.c +++ b/src/lib/lttng-ust/lttng-context-pid-ns.c @@ -77,6 +77,7 @@ void lttng_context_pid_ns_reset(void) static size_t pid_ns_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -88,8 +89,9 @@ size_t pid_ns_get_size(void *priv __attribute__((unused)), static void pid_ns_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { ino_t pid_ns; @@ -99,9 +101,10 @@ void pid_ns_record(void *priv __attribute__((unused)), static void pid_ns_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_pid_ns(); + value->u.u64 = get_pid_ns(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-procname.c b/src/lib/lttng-ust/lttng-context-procname.c index 093b50c7..28c8490d 100644 --- a/src/lib/lttng-ust/lttng-context-procname.c +++ b/src/lib/lttng-ust/lttng-context-procname.c @@ -67,6 +67,7 @@ void lttng_ust_context_procname_reset(void) static size_t procname_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset __attribute__((unused))) { return LTTNG_UST_ABI_PROCNAME_LEN; @@ -74,8 +75,9 @@ size_t procname_get_size(void *priv __attribute__((unused)), static void procname_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { const char *procname; @@ -85,6 +87,7 @@ void procname_record(void *priv __attribute__((unused)), static void procname_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { value->u.str = wrapper_getprocname(); diff --git a/src/lib/lttng-ust/lttng-context-pthread-id.c b/src/lib/lttng-ust/lttng-context-pthread-id.c index af98816b..452639e1 100644 --- a/src/lib/lttng-ust/lttng-context-pthread-id.c +++ b/src/lib/lttng-ust/lttng-context-pthread-id.c @@ -18,6 +18,7 @@ static size_t pthread_id_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -29,8 +30,9 @@ size_t pthread_id_get_size(void *priv __attribute__((unused)), static void pthread_id_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { unsigned long pthread_id; @@ -40,9 +42,10 @@ void pthread_id_record(void *priv __attribute__((unused)), static void pthread_id_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = (unsigned long) pthread_self(); + value->u.u64 = (unsigned long) pthread_self(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-time-ns.c b/src/lib/lttng-ust/lttng-context-time-ns.c index 78423298..4f532b48 100644 --- a/src/lib/lttng-ust/lttng-context-time-ns.c +++ b/src/lib/lttng-ust/lttng-context-time-ns.c @@ -90,6 +90,7 @@ void lttng_context_time_ns_reset(void) static size_t time_ns_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -101,8 +102,9 @@ size_t time_ns_get_size(void *priv __attribute__((unused)), static void time_ns_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { ino_t time_ns; @@ -112,9 +114,10 @@ void time_ns_record(void *priv __attribute__((unused)), static void time_ns_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_time_ns(); + value->u.u64 = get_time_ns(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-user-ns.c b/src/lib/lttng-ust/lttng-context-user-ns.c index 97612bc6..813e357b 100644 --- a/src/lib/lttng-ust/lttng-context-user-ns.c +++ b/src/lib/lttng-ust/lttng-context-user-ns.c @@ -74,6 +74,7 @@ void lttng_context_user_ns_reset(void) static size_t user_ns_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -85,8 +86,9 @@ size_t user_ns_get_size(void *priv __attribute__((unused)), static void user_ns_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { ino_t user_ns; @@ -96,9 +98,10 @@ void user_ns_record(void *priv __attribute__((unused)), static void user_ns_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_user_ns(); + value->u.u64 = get_user_ns(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-uts-ns.c b/src/lib/lttng-ust/lttng-context-uts-ns.c index 0ec8ed44..619649b3 100644 --- a/src/lib/lttng-ust/lttng-context-uts-ns.c +++ b/src/lib/lttng-ust/lttng-context-uts-ns.c @@ -92,6 +92,7 @@ void lttng_context_uts_ns_reset(void) static size_t uts_ns_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -103,8 +104,9 @@ size_t uts_ns_get_size(void *priv __attribute__((unused)), static void uts_ns_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { ino_t uts_ns; @@ -114,9 +116,10 @@ void uts_ns_record(void *priv __attribute__((unused)), static void uts_ns_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_uts_ns(); + value->u.u64 = get_uts_ns(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-vegid.c b/src/lib/lttng-ust/lttng-context-vegid.c index 682f7d9a..23b0cd6f 100644 --- a/src/lib/lttng-ust/lttng-context-vegid.c +++ b/src/lib/lttng-ust/lttng-context-vegid.c @@ -63,6 +63,7 @@ void lttng_context_vegid_reset(void) static size_t vegid_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -74,8 +75,9 @@ size_t vegid_get_size(void *priv __attribute__((unused)), static void vegid_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { gid_t vegid; @@ -85,9 +87,10 @@ void vegid_record(void *priv __attribute__((unused)), static void vegid_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_vegid(); + value->u.u64 = get_vegid(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-veuid.c b/src/lib/lttng-ust/lttng-context-veuid.c index 505a1b63..af2bd1a1 100644 --- a/src/lib/lttng-ust/lttng-context-veuid.c +++ b/src/lib/lttng-ust/lttng-context-veuid.c @@ -63,6 +63,7 @@ void lttng_context_veuid_reset(void) static size_t veuid_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -74,8 +75,9 @@ size_t veuid_get_size(void *priv __attribute__((unused)), static void veuid_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { uid_t veuid; @@ -85,9 +87,10 @@ void veuid_record(void *priv __attribute__((unused)), static void veuid_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_veuid(); + value->u.u64 = get_veuid(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-vgid.c b/src/lib/lttng-ust/lttng-context-vgid.c index c19be225..2f62b85d 100644 --- a/src/lib/lttng-ust/lttng-context-vgid.c +++ b/src/lib/lttng-ust/lttng-context-vgid.c @@ -63,6 +63,7 @@ void lttng_context_vgid_reset(void) static size_t vgid_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -74,8 +75,9 @@ size_t vgid_get_size(void *priv __attribute__((unused)), static void vgid_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { gid_t vgid; @@ -85,9 +87,10 @@ void vgid_record(void *priv __attribute__((unused)), static void vgid_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_vgid(); + value->u.u64 = get_vgid(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-vpid.c b/src/lib/lttng-ust/lttng-context-vpid.c index 1558ee98..57174b0a 100644 --- a/src/lib/lttng-ust/lttng-context-vpid.c +++ b/src/lib/lttng-ust/lttng-context-vpid.c @@ -47,6 +47,7 @@ void lttng_context_vpid_reset(void) static size_t vpid_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -58,8 +59,9 @@ size_t vpid_get_size(void *priv __attribute__((unused)), static void vpid_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { pid_t vpid = wrapper_getvpid(); @@ -68,6 +70,7 @@ void vpid_record(void *priv __attribute__((unused)), static void vpid_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { value->u.s64 = wrapper_getvpid(); diff --git a/src/lib/lttng-ust/lttng-context-vsgid.c b/src/lib/lttng-ust/lttng-context-vsgid.c index f66b6b76..37b227d3 100644 --- a/src/lib/lttng-ust/lttng-context-vsgid.c +++ b/src/lib/lttng-ust/lttng-context-vsgid.c @@ -67,6 +67,7 @@ void lttng_context_vsgid_reset(void) static size_t vsgid_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -78,8 +79,9 @@ size_t vsgid_get_size(void *priv __attribute__((unused)), static void vsgid_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { gid_t vsgid; @@ -89,9 +91,10 @@ void vsgid_record(void *priv __attribute__((unused)), static void vsgid_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_vsgid(); + value->u.u64 = get_vsgid(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-vsuid.c b/src/lib/lttng-ust/lttng-context-vsuid.c index 2e442c94..a0428f24 100644 --- a/src/lib/lttng-ust/lttng-context-vsuid.c +++ b/src/lib/lttng-ust/lttng-context-vsuid.c @@ -67,6 +67,7 @@ void lttng_context_vsuid_reset(void) static size_t vsuid_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -78,8 +79,9 @@ size_t vsuid_get_size(void *priv __attribute__((unused)), static void vsuid_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { uid_t vsuid; @@ -89,9 +91,10 @@ void vsuid_record(void *priv __attribute__((unused)), static void vsuid_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_vsuid(); + value->u.u64 = get_vsuid(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context-vtid.c b/src/lib/lttng-ust/lttng-context-vtid.c index 6a206a90..97a023d2 100644 --- a/src/lib/lttng-ust/lttng-context-vtid.c +++ b/src/lib/lttng-ust/lttng-context-vtid.c @@ -38,6 +38,7 @@ void lttng_context_vtid_reset(void) static size_t vtid_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -62,8 +63,9 @@ pid_t wrapper_getvtid(void) static void vtid_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { pid_t vtid = wrapper_getvtid(); @@ -72,6 +74,7 @@ void vtid_record(void *priv __attribute__((unused)), static void vtid_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { value->u.s64 = wrapper_getvtid(); diff --git a/src/lib/lttng-ust/lttng-context-vuid.c b/src/lib/lttng-ust/lttng-context-vuid.c index d96a8c9b..b50d8b9f 100644 --- a/src/lib/lttng-ust/lttng-context-vuid.c +++ b/src/lib/lttng-ust/lttng-context-vuid.c @@ -63,6 +63,7 @@ void lttng_context_vuid_reset(void) static size_t vuid_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -74,8 +75,9 @@ size_t vuid_get_size(void *priv __attribute__((unused)), static void vuid_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { uid_t vuid; @@ -85,9 +87,10 @@ void vuid_record(void *priv __attribute__((unused)), static void vuid_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { - value->u.s64 = get_vuid(); + value->u.u64 = get_vuid(); } static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field( diff --git a/src/lib/lttng-ust/lttng-context.c b/src/lib/lttng-ust/lttng-context.c index 046f2a85..427afe56 100644 --- a/src/lib/lttng-ust/lttng-context.c +++ b/src/lib/lttng-ust/lttng-context.c @@ -254,10 +254,13 @@ void lttng_destroy_context(struct lttng_ust_ctx *ctx) */ int lttng_ust_context_set_provider_rcu(struct lttng_ust_ctx **_ctx, const char *name, - size_t (*get_size)(void *priv, size_t offset), - void (*record)(void *priv, struct lttng_ust_ring_buffer_ctx *ctx, + size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + size_t offset), + void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ring_buffer_ctx *ctx, struct lttng_ust_channel_buffer *chan), - void (*get_value)(void *priv, struct lttng_ust_ctx_value *value), + void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ctx_value *value), void *priv) { int i, ret; diff --git a/src/lib/lttng-ust/lttng-events.c b/src/lib/lttng-ust/lttng-events.c index 38610613..4bacbb95 100644 --- a/src/lib/lttng-ust/lttng-events.c +++ b/src/lib/lttng-ust/lttng-events.c @@ -1997,10 +1997,13 @@ void lttng_session_lazy_sync_event_enablers(struct lttng_ust_session *session) * context (either app context callbacks, or dummy callbacks). */ void lttng_ust_context_set_session_provider(const char *name, - size_t (*get_size)(void *priv, size_t offset), - void (*record)(void *priv, struct lttng_ust_ring_buffer_ctx *ctx, + size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + size_t offset), + void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ring_buffer_ctx *ctx, struct lttng_ust_channel_buffer *chan), - void (*get_value)(void *priv, struct lttng_ust_ctx_value *value), + void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ctx_value *value), void *priv) { struct lttng_ust_session_private *session_priv; @@ -2037,10 +2040,13 @@ void lttng_ust_context_set_session_provider(const char *name, * context (either app context callbacks, or dummy callbacks). */ void lttng_ust_context_set_event_notifier_group_provider(const char *name, - size_t (*get_size)(void *priv, size_t offset), - void (*record)(void *priv, struct lttng_ust_ring_buffer_ctx *ctx, + size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + size_t offset), + void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ring_buffer_ctx *ctx, struct lttng_ust_channel_buffer *chan), - void (*get_value)(void *priv, struct lttng_ust_ctx_value *value), + void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ctx_value *value), void *priv) { struct lttng_event_notifier_group *event_notifier_group; diff --git a/src/lib/lttng-ust/lttng-ring-buffer-client-template.h b/src/lib/lttng-ust/lttng-ring-buffer-client-template.h index 14aa2a48..bc7fc2f2 100644 --- a/src/lib/lttng-ust/lttng-ring-buffer-client-template.h +++ b/src/lib/lttng-ust/lttng-ring-buffer-client-template.h @@ -98,7 +98,8 @@ size_t ctx_get_aligned_size(size_t offset, struct lttng_ust_ctx *ctx, } static inline -void ctx_get_struct_size(struct lttng_ust_ctx *ctx, size_t *ctx_len) +void ctx_get_struct_size(struct lttng_ust_ring_buffer_ctx *bufctx, + struct lttng_ust_ctx *ctx, size_t *ctx_len) { int i; size_t offset = 0; @@ -108,7 +109,7 @@ void ctx_get_struct_size(struct lttng_ust_ctx *ctx, size_t *ctx_len) return; } for (i = 0; i < ctx->nr_fields; i++) - offset += ctx->fields[i].get_size(ctx->fields[i].priv, offset); + offset += ctx->fields[i].get_size(ctx->fields[i].priv, bufctx->probe_ctx, offset); *ctx_len = offset; } @@ -123,7 +124,7 @@ void ctx_record(struct lttng_ust_ring_buffer_ctx *bufctx, return; lttng_ust_ring_buffer_align_ctx(bufctx, ctx->largest_align); for (i = 0; i < ctx->nr_fields; i++) - ctx->fields[i].record(ctx->fields[i].priv, bufctx, chan); + ctx->fields[i].record(ctx->fields[i].priv, bufctx->probe_ctx, bufctx, chan); } /* @@ -690,8 +691,8 @@ int lttng_event_reserve(struct lttng_ust_ring_buffer_ctx *ctx) client_ctx.chan_ctx = lttng_ust_rcu_dereference(lttng_chan->priv->ctx); client_ctx.event_ctx = lttng_ust_rcu_dereference(event_recorder->priv->ctx); /* Compute internal size of context structures. */ - ctx_get_struct_size(client_ctx.chan_ctx, &client_ctx.packet_context_len); - ctx_get_struct_size(client_ctx.event_ctx, &client_ctx.event_context_len); + ctx_get_struct_size(ctx, client_ctx.chan_ctx, &client_ctx.packet_context_len); + ctx_get_struct_size(ctx, client_ctx.event_ctx, &client_ctx.event_context_len); nesting = lib_ring_buffer_nesting_inc(&client_config); if (nesting < 0) diff --git a/src/lib/lttng-ust/lttng-tracer-core.h b/src/lib/lttng-ust/lttng-tracer-core.h index bfead6e5..75765394 100644 --- a/src/lib/lttng-ust/lttng-tracer-core.h +++ b/src/lib/lttng-ust/lttng-tracer-core.h @@ -73,19 +73,23 @@ char* lttng_ust_sockinfo_get_procname(void *owner) void lttng_ust_sockinfo_session_enabled(void *owner) __attribute__((visibility("hidden"))); -size_t lttng_ust_dummy_get_size(void *priv, size_t offset) +size_t lttng_ust_dummy_get_size(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + size_t offset) __attribute__((visibility("hidden"))); -void lttng_ust_dummy_record(void *priv, struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) +void lttng_ust_dummy_record(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) __attribute__((visibility("hidden"))); -void lttng_ust_dummy_get_value(void *priv, struct lttng_ust_ctx_value *value) +void lttng_ust_dummy_get_value(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ctx_value *value) __attribute__((visibility("hidden"))); void lttng_event_notifier_notification_send( const struct lttng_ust_event_notifier *event_notifier, const char *stack_data, + struct lttng_ust_probe_ctx *probe_ctx, struct lttng_ust_notification_ctx *notif_ctx) __attribute__((visibility("hidden"))); diff --git a/src/lib/lttng-ust/ust-core.c b/src/lib/lttng-ust/ust-core.c index ead25295..d070124e 100644 --- a/src/lib/lttng-ust/ust-core.c +++ b/src/lib/lttng-ust/ust-core.c @@ -109,6 +109,7 @@ struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_ust_session *sessio } size_t lttng_ust_dummy_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), size_t offset) { size_t size = 0; @@ -119,8 +120,9 @@ size_t lttng_ust_dummy_get_size(void *priv __attribute__((unused)), } void lttng_ust_dummy_record(void *priv __attribute__((unused)), - struct lttng_ust_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan) + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan) { char sel_char = (char) LTTNG_UST_DYNAMIC_TYPE_NONE; @@ -128,6 +130,7 @@ void lttng_ust_dummy_record(void *priv __attribute__((unused)), } void lttng_ust_dummy_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { value->sel = LTTNG_UST_DYNAMIC_TYPE_NONE; diff --git a/tests/compile/test-app-ctx/hello.c b/tests/compile/test-app-ctx/hello.c index 723f179f..85df9984 100644 --- a/tests/compile/test-app-ctx/hello.c +++ b/tests/compile/test-app-ctx/hello.c @@ -42,7 +42,9 @@ void test_inc_count(void) } static -size_t test_get_size(void *priv __attribute__((unused)), size_t offset) +size_t test_get_size(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), + size_t offset) { int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES; size_t size = 0; @@ -104,6 +106,7 @@ size_t test_get_size(void *priv __attribute__((unused)), size_t offset) static void test_record(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ring_buffer_ctx *ctx, struct lttng_ust_channel_buffer *lttng_chan_buf) { @@ -197,6 +200,7 @@ void test_record(void *priv __attribute__((unused)), static void test_get_value(void *priv __attribute__((unused)), + struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)), struct lttng_ust_ctx_value *value) { int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES; -- 2.34.1