X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust%2Flttng-bytecode-interpreter.c;h=947da3eede2d8f86293781c1e74132c50f4079ec;hb=35c1f459092b630dd2825450014e27c84b31ddee;hp=9def26cd4f0e572b3157cc804bd4475f54c34071;hpb=bf617e2041b908520b7e167b3401f277c9d4b4d4;p=lttng-ust.git diff --git a/liblttng-ust/lttng-bytecode-interpreter.c b/liblttng-ust/lttng-bytecode-interpreter.c index 9def26cd..947da3ee 100644 --- a/liblttng-ust/lttng-bytecode-interpreter.c +++ b/liblttng-ust/lttng-bytecode-interpreter.c @@ -13,6 +13,7 @@ #include #include #include +#include "ust-events-internal.h" #include "lttng-bytecode.h" #include "string-utils.h" @@ -216,17 +217,17 @@ LABEL_##name #define IS_INTEGER_REGISTER(reg_type) \ (reg_type == REG_U64 || reg_type == REG_S64) -static int context_get_index(struct lttng_ctx *ctx, +static int context_get_index(struct lttng_ust_ctx *ctx, struct load_ptr *ptr, uint32_t idx) { - struct lttng_ctx_field *ctx_field; - struct lttng_event_field *field; - struct lttng_ctx_value v; + struct lttng_ust_ctx_field *ctx_field; + struct lttng_ust_event_field *field; + struct lttng_ust_ctx_value v; - ctx_field = &ctx->fields[idx]; - field = &ctx_field->event_field; + ctx_field = ctx->fields[idx]; + field = ctx_field->event_field; ptr->type = LOAD_OBJECT; ptr->field = field; @@ -243,16 +244,11 @@ static int context_get_index(struct lttng_ctx *ctx, ptr->ptr = &ptr->u.u64; } break; - case atype_enum: /* Fall-through */ case atype_enum_nestable: { const struct lttng_integer_type *itype; - if (field->type.atype == atype_enum) { - itype = &field->type.u.legacy.basic.enumeration.container_type; - } else { - itype = &field->type.u.enum_nestable.container_type->u.integer; - } + itype = &field->type.u.enum_nestable.container_type->u.integer; ctx_field->get_value(ctx_field, &v); if (itype->signedness) { ptr->object_type = OBJECT_TYPE_SIGNED_ENUM; @@ -265,19 +261,6 @@ static int context_get_index(struct lttng_ctx *ctx, } break; } - case atype_array: - if (field->type.u.legacy.array.elem_type.atype != atype_integer) { - ERR("Array nesting only supports integer types."); - return -EINVAL; - } - if (field->type.u.legacy.array.elem_type.u.basic.integer.encoding == lttng_encode_none) { - ERR("Only string arrays are supported for contexts."); - return -EINVAL; - } - ptr->object_type = OBJECT_TYPE_STRING; - ctx_field->get_value(ctx_field, &v); - ptr->ptr = v.u.str; - break; case atype_array_nestable: if (field->type.u.array_nestable.elem_type->atype != atype_integer) { ERR("Array nesting only supports integer types."); @@ -291,19 +274,6 @@ static int context_get_index(struct lttng_ctx *ctx, ctx_field->get_value(ctx_field, &v); ptr->ptr = v.u.str; break; - case atype_sequence: - if (field->type.u.legacy.sequence.elem_type.atype != atype_integer) { - ERR("Sequence nesting only supports integer types."); - return -EINVAL; - } - if (field->type.u.legacy.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none) { - ERR("Only string sequences are supported for contexts."); - return -EINVAL; - } - ptr->object_type = OBJECT_TYPE_STRING; - ctx_field->get_value(ctx_field, &v); - ptr->ptr = v.u.str; - break; case atype_sequence_nestable: if (field->type.u.sequence_nestable.elem_type->atype != atype_integer) { ERR("Sequence nesting only supports integer types."); @@ -368,9 +338,6 @@ static int context_get_index(struct lttng_ctx *ctx, return -EINVAL; } break; - case atype_struct: - ERR("Structure type cannot be loaded."); - return -EINVAL; default: ERR("Unknown type: %d", (int) field->type.atype); return -EINVAL; @@ -378,7 +345,7 @@ static int context_get_index(struct lttng_ctx *ctx, return 0; } -static int dynamic_get_index(struct lttng_ctx *ctx, +static int dynamic_get_index(struct lttng_ust_ctx *ctx, struct bytecode_runtime *runtime, uint64_t index, struct estack_entry *stack_top) { @@ -400,8 +367,7 @@ static int dynamic_get_index(struct lttng_ctx *ctx, stack_top->u.ptr.ptr = ptr; stack_top->u.ptr.object_type = gid->elem.type; stack_top->u.ptr.rev_bo = gid->elem.rev_bo; - assert(stack_top->u.ptr.field->type.atype == atype_array || - stack_top->u.ptr.field->type.atype == atype_array_nestable); + assert(stack_top->u.ptr.field->type.atype == atype_array_nestable); stack_top->u.ptr.field = NULL; break; } @@ -420,8 +386,7 @@ static int dynamic_get_index(struct lttng_ctx *ctx, stack_top->u.ptr.ptr = ptr; stack_top->u.ptr.object_type = gid->elem.type; stack_top->u.ptr.rev_bo = gid->elem.rev_bo; - assert(stack_top->u.ptr.field->type.atype == atype_sequence || - stack_top->u.ptr.field->type.atype == atype_sequence_nestable); + assert(stack_top->u.ptr.field->type.atype == atype_sequence_nestable); stack_top->u.ptr.field = NULL; break; } @@ -752,7 +717,7 @@ uint64_t bytecode_interpret(void *interpreter_data, struct lttng_interpreter_output *output) { struct bytecode_runtime *bytecode = interpreter_data; - struct lttng_ctx *ctx = lttng_ust_rcu_dereference(*bytecode->p.pctx); + struct lttng_ust_ctx *ctx = lttng_ust_rcu_dereference(*bytecode->p.priv->pctx); void *pc, *next_pc, *start_pc; int ret = -EINVAL; uint64_t retval = 0; @@ -2171,12 +2136,12 @@ uint64_t bytecode_interpret(void *interpreter_data, { struct load_op *insn = (struct load_op *) pc; struct field_ref *ref = (struct field_ref *) insn->data; - struct lttng_ctx_field *ctx_field; - struct lttng_ctx_value v; + struct lttng_ust_ctx_field *ctx_field; + struct lttng_ust_ctx_value v; dbg_printf("get context ref offset %u type dynamic\n", ref->offset); - ctx_field = &ctx->fields[ref->offset]; + ctx_field = ctx->fields[ref->offset]; ctx_field->get_value(ctx_field, &v); estack_push(stack, top, ax, bx, ax_t, bx_t); switch (v.sel) { @@ -2219,12 +2184,12 @@ uint64_t bytecode_interpret(void *interpreter_data, { struct load_op *insn = (struct load_op *) pc; struct field_ref *ref = (struct field_ref *) insn->data; - struct lttng_ctx_field *ctx_field; - struct lttng_ctx_value v; + struct lttng_ust_ctx_field *ctx_field; + struct lttng_ust_ctx_value v; dbg_printf("get context ref offset %u type string\n", ref->offset); - ctx_field = &ctx->fields[ref->offset]; + ctx_field = ctx->fields[ref->offset]; ctx_field->get_value(ctx_field, &v); estack_push(stack, top, ax, bx, ax_t, bx_t); estack_ax(stack, top)->u.s.str = v.u.str; @@ -2246,12 +2211,12 @@ uint64_t bytecode_interpret(void *interpreter_data, { struct load_op *insn = (struct load_op *) pc; struct field_ref *ref = (struct field_ref *) insn->data; - struct lttng_ctx_field *ctx_field; - struct lttng_ctx_value v; + struct lttng_ust_ctx_field *ctx_field; + struct lttng_ust_ctx_value v; dbg_printf("get context ref offset %u type s64\n", ref->offset); - ctx_field = &ctx->fields[ref->offset]; + ctx_field = ctx->fields[ref->offset]; ctx_field->get_value(ctx_field, &v); estack_push(stack, top, ax, bx, ax_t, bx_t); estack_ax_v = v.u.s64; @@ -2265,12 +2230,12 @@ uint64_t bytecode_interpret(void *interpreter_data, { struct load_op *insn = (struct load_op *) pc; struct field_ref *ref = (struct field_ref *) insn->data; - struct lttng_ctx_field *ctx_field; - struct lttng_ctx_value v; + struct lttng_ust_ctx_field *ctx_field; + struct lttng_ust_ctx_value v; dbg_printf("get context ref offset %u type double\n", ref->offset); - ctx_field = &ctx->fields[ref->offset]; + ctx_field = ctx->fields[ref->offset]; ctx_field->get_value(ctx_field, &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));