SoW-2019-0002: Dynamic Snapshot
[deliverable/lttng-modules.git] / lttng-filter-specialize.c
index 4f9a0cd1833da967fdc9fee7fb62cd74d2cb7771..d714109657bd92beba06681c3d553a69f190028c 100644 (file)
@@ -285,7 +285,8 @@ end:
        return ret;
 }
 
-static int specialize_context_lookup_name(struct bytecode_runtime *bytecode,
+static int specialize_context_lookup_name(struct lttng_ctx *ctx,
+               struct bytecode_runtime *bytecode,
                struct load_op *insn)
 {
        uint16_t offset;
@@ -293,7 +294,7 @@ static int specialize_context_lookup_name(struct bytecode_runtime *bytecode,
 
        offset = ((struct get_symbol *) insn->data)->offset;
        name = bytecode->p.bc->bc.data + bytecode->p.bc->bc.reloc_offset + offset;
-       return lttng_get_context_index(lttng_static_ctx, name);
+       return lttng_get_context_index(ctx, name);
 }
 
 static int specialize_load_object(const struct lttng_event_field *field,
@@ -374,7 +375,8 @@ static int specialize_load_object(const struct lttng_event_field *field,
        return 0;
 }
 
-static int specialize_context_lookup(struct bytecode_runtime *runtime,
+static int specialize_context_lookup(struct lttng_ctx *ctx,
+               struct bytecode_runtime *runtime,
                struct load_op *insn,
                struct vstack_load *load)
 {
@@ -384,7 +386,7 @@ static int specialize_context_lookup(struct bytecode_runtime *runtime,
        struct filter_get_index_data gid;
        ssize_t data_offset;
 
-       idx = specialize_context_lookup_name(runtime, insn);
+       idx = specialize_context_lookup_name(ctx, runtime, insn);
        if (idx < 0) {
                return -ENOENT;
        }
@@ -407,14 +409,13 @@ static int specialize_context_lookup(struct bytecode_runtime *runtime,
        return 0;
 }
 
-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;
@@ -423,11 +424,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;
@@ -479,13 +480,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_ctx *ctx = bytecode->p.ctx;
 
        vstack_init(stack);
 
@@ -1140,7 +1142,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event,
                                goto end;
                        case LOAD_ROOT_CONTEXT:
                                /* Lookup context field. */
-                               ret = specialize_context_lookup(bytecode, insn,
+                               ret = specialize_context_lookup(ctx, bytecode, insn,
                                        &vstack_ax(stack)->load);
                                if (ret)
                                        goto end;
@@ -1150,7 +1152,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event,
                                goto end;
                        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.025992 seconds and 5 git commands to generate.