uint64_t (*filter)(void *filter_data, const char *filter_stack_data);
int link_failed;
struct cds_list_head node; /* list of bytecode runtime in event */
- struct lttng_session *session;
+ /*
+ * Pointer to a `struct lttng_session`-owned and URCU-protected
+ * pointer.
+ */
+ struct lttng_ctx **pctx;
};
/*
return 0;
}
-static int dynamic_get_index(struct lttng_session *session,
+static int dynamic_get_index(struct lttng_ctx *ctx,
struct bytecode_runtime *runtime,
uint64_t index, struct estack_entry *stack_top)
{
case LOAD_ROOT_CONTEXT:
case LOAD_ROOT_APP_CONTEXT: /* Fall-through */
{
- struct lttng_ctx *ctx;
-
- ctx = rcu_dereference(session->ctx);
ret = context_get_index(ctx,
&stack_top->u.ptr,
gid->ctx_index);
const char *filter_stack_data)
{
struct bytecode_runtime *bytecode = filter_data;
- struct lttng_session *session = bytecode->p.session;
+ struct lttng_ctx *ctx = rcu_dereference(*bytecode->p.pctx);
void *pc, *next_pc, *start_pc;
int ret = -EINVAL;
uint64_t retval = 0;
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type dynamic\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type string\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type s64\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type double\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
struct get_index_u16 *index = (struct get_index_u16 *) insn->data;
dbg_printf("op get index u16\n");
- ret = dynamic_get_index(session, bytecode, index->index, estack_ax(stack, top));
+ ret = dynamic_get_index(ctx, bytecode, index->index, estack_ax(stack, top));
if (ret)
goto end;
estack_ax_v = estack_ax(stack, top)->u.v;
struct get_index_u64 *index = (struct get_index_u64 *) insn->data;
dbg_printf("op get index u64\n");
- ret = dynamic_get_index(session, bytecode, index->index, estack_ax(stack, top));
+ ret = dynamic_get_index(ctx, bytecode, index->index, estack_ax(stack, top));
if (ret)
goto end;
estack_ax_v = estack_ax(stack, top)->u.v;
return 0;
}
-static int specialize_context_lookup(struct lttng_session *session,
+static int specialize_context_lookup(struct lttng_ctx *ctx,
struct bytecode_runtime *runtime,
struct load_op *insn,
struct vstack_load *load)
struct filter_get_index_data gid;
ssize_t data_offset;
- idx = specialize_context_lookup_name(session->ctx, runtime, insn);
+ idx = specialize_context_lookup_name(ctx, runtime, insn);
if (idx < 0) {
return -ENOENT;
}
- ctx_field = &session->ctx->fields[idx];
+ ctx_field = &ctx->fields[idx];
field = &ctx_field->event_field;
ret = specialize_load_object(field, load, true);
if (ret)
return 0;
}
-static int specialize_app_context_lookup(struct lttng_session *session,
+static int specialize_app_context_lookup(struct lttng_ctx **pctx,
struct bytecode_runtime *runtime,
struct load_op *insn,
struct vstack_load *load)
}
strcpy(name, "$app.");
strcat(name, orig_name);
- idx = lttng_get_context_index(session->ctx, name);
+ idx = lttng_get_context_index(*pctx, name);
if (idx < 0) {
assert(lttng_context_is_app(name));
ret = lttng_ust_add_app_context_to_ctx_rcu(name,
- &session->ctx);
+ pctx);
if (ret)
return ret;
- idx = lttng_get_context_index(session->ctx,
- name);
+ idx = lttng_get_context_index(*pctx, name);
if (idx < 0)
return -ENOENT;
}
- ctx_field = &session->ctx->fields[idx];
+ ctx_field = &(*pctx)->fields[idx];
field = &ctx_field->event_field;
ret = specialize_load_object(field, load, true);
if (ret)
int ret = -EINVAL;
struct vstack _stack;
struct vstack *stack = &_stack;
- struct lttng_session *session = bytecode->p.session;
+ struct lttng_ctx **pctx = bytecode->p.pctx;
vstack_init(stack);
goto end;
case LOAD_ROOT_CONTEXT:
/* Lookup context field. */
- ret = specialize_context_lookup(session,
+ ret = specialize_context_lookup(*pctx,
bytecode, insn,
&vstack_ax(stack)->load);
if (ret)
break;
case LOAD_ROOT_APP_CONTEXT:
/* Lookup app context field. */
- ret = specialize_app_context_lookup(session,
+ ret = specialize_app_context_lookup(pctx,
bytecode, insn,
&vstack_ax(stack)->load);
if (ret)
struct load_op *op;
struct lttng_ctx_field *ctx_field;
int idx;
- struct lttng_session *session = runtime->p.session;
+ struct lttng_ctx *ctx = *runtime->p.pctx;
dbg_printf("Apply context reloc: %u %s\n", reloc_offset, context_name);
/* Get context index */
- idx = lttng_get_context_index(session->ctx, context_name);
+ idx = lttng_get_context_index(ctx, context_name);
if (idx < 0) {
if (lttng_context_is_app(context_name)) {
int ret;
ret = lttng_ust_add_app_context_to_ctx_rcu(context_name,
- &session->ctx);
+ &ctx);
if (ret)
return ret;
- idx = lttng_get_context_index(session->ctx,
- context_name);
+ idx = lttng_get_context_index(ctx, context_name);
if (idx < 0)
return -ENOENT;
} else {
return -EINVAL;
/* Get context return type */
- ctx_field = &session->ctx->fields[idx];
+ ctx_field = &ctx->fields[idx];
op = (struct load_op *) &runtime->code[reloc_offset];
switch (filter_op) {
goto alloc_error;
}
runtime->p.bc = filter_bytecode;
- runtime->p.session = event->chan->session;
+ runtime->p.pctx = &event->chan->session->ctx;
runtime->len = filter_bytecode->bc.reloc_offset;
/* copy original bytecode */
memcpy(runtime->code, filter_bytecode->bc.data, runtime->len);
return 0;
}
-void lttng_free_event_filter_runtime(struct lttng_event *event)
+static
+void free_filter_runtime(struct cds_list_head *bytecode_runtime_head)
{
struct bytecode_runtime *runtime, *tmp;
- cds_list_for_each_entry_safe(runtime, tmp,
- &event->bytecode_runtime_head, p.node) {
+ cds_list_for_each_entry_safe(runtime, tmp, bytecode_runtime_head,
+ p.node) {
free(runtime->data);
free(runtime);
}
}
+
+void lttng_free_event_filter_runtime(struct lttng_event *event)
+{
+ free_filter_runtime(&event->bytecode_runtime_head);
+}