SoW-2019-0002: Dynamic Snapshot
[deliverable/lttng-ust.git] / liblttng-ust / lttng-filter-specialize.c
index 39730f8cd954a0428ff419fe1d9114a70caf7a33..9b38fa69aedda06bf7b9a4e8fe58e5222b9aeebf 100644 (file)
@@ -436,7 +436,7 @@ static int specialize_load_object(const struct lttng_event_field *field,
        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)
@@ -447,11 +447,11 @@ static int specialize_context_lookup(struct lttng_session *session,
        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)
@@ -470,7 +470,7 @@ static int specialize_context_lookup(struct lttng_session *session,
        return 0;
 }
 
-static int specialize_app_context_lookup(struct lttng_session *session,
+static int specialize_app_context_lookup(struct lttng_ctx *ctx,
                struct bytecode_runtime *runtime,
                struct load_op *insn,
                struct vstack_load *load)
@@ -493,19 +493,18 @@ static int specialize_app_context_lookup(struct lttng_session *session,
        }
        strcpy(name, "$app.");
        strcat(name, orig_name);
-       idx = lttng_get_context_index(session->ctx, name);
+       idx = lttng_get_context_index(ctx, name);
        if (idx < 0) {
                assert(lttng_context_is_app(name));
                ret = lttng_ust_add_app_context_to_ctx_rcu(name,
-                               &session->ctx);
+                               &ctx);
                if (ret)
                        return ret;
-               idx = lttng_get_context_index(session->ctx,
-                       name);
+               idx = lttng_get_context_index(ctx, name);
                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)
@@ -528,14 +527,13 @@ end:
        return ret;
 }
 
-static int specialize_event_payload_lookup(struct lttng_event *event,
+static int specialize_payload_lookup(const struct lttng_event_desc *event_desc,
                struct bytecode_runtime *runtime,
                struct load_op *insn,
                struct vstack_load *load)
 {
        const char *name;
        uint16_t offset;
-       const struct lttng_event_desc *desc = event->desc;
        unsigned int i, nr_fields;
        bool found = false;
        uint32_t field_offset = 0;
@@ -544,11 +542,11 @@ static int specialize_event_payload_lookup(struct lttng_event *event,
        struct filter_get_index_data gid;
        ssize_t data_offset;
 
-       nr_fields = desc->nr_fields;
+       nr_fields = event_desc->nr_fields;
        offset = ((struct get_symbol *) insn->data)->offset;
        name = runtime->p.bc->bc.data + runtime->p.bc->bc.reloc_offset + offset;
        for (i = 0; i < nr_fields; i++) {
-               field = &desc->fields[i];
+               field = &event_desc->fields[i];
                if (!strcmp(field->name, name)) {
                        found = true;
                        break;
@@ -601,14 +599,14 @@ end:
        return ret;
 }
 
-int lttng_filter_specialize_bytecode(struct lttng_event *event,
+int lttng_filter_specialize_bytecode(const struct lttng_event_desc *event_desc,
                struct bytecode_runtime *bytecode)
 {
        void *pc, *next_pc, *start_pc;
        int ret = -EINVAL;
        struct vstack _stack;
        struct vstack *stack = &_stack;
-       struct lttng_session *session = bytecode->p.session;
+       struct lttng_ctx *ctx = *bytecode->p.ctx;
 
        vstack_init(stack);
 
@@ -1335,7 +1333,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event,
                                goto end;
                        case LOAD_ROOT_CONTEXT:
                                /* Lookup context field. */
-                               ret = specialize_context_lookup(session,
+                               ret = specialize_context_lookup(ctx,
                                        bytecode, insn,
                                        &vstack_ax(stack)->load);
                                if (ret)
@@ -1343,7 +1341,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event,
                                break;
                        case LOAD_ROOT_APP_CONTEXT:
                                /* Lookup app context field. */
-                               ret = specialize_app_context_lookup(session,
+                               ret = specialize_app_context_lookup(ctx,
                                        bytecode, insn,
                                        &vstack_ax(stack)->load);
                                if (ret)
@@ -1351,7 +1349,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event,
                                break;
                        case LOAD_ROOT_PAYLOAD:
                                /* Lookup event payload field. */
-                               ret = specialize_event_payload_lookup(event,
+                               ret = specialize_payload_lookup(event_desc,
                                        bytecode, insn,
                                        &vstack_ax(stack)->load);
                                if (ret)
This page took 0.027185 seconds and 5 git commands to generate.