X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=liblttng-ust%2Flttng-filter-interpreter.c;h=6c77cfe983f97fb02eb8e827166ab0d61087f6e7;hb=d97f9b785f05c29dbabb57da9a32c8c4317da8d3;hp=5c0cea5a4d2d99c05513b74f44be72bf04fdb7f9;hpb=47e5f13e885764eecde371627001d26da2a2f41f;p=deliverable%2Flttng-ust.git diff --git a/liblttng-ust/lttng-filter-interpreter.c b/liblttng-ust/lttng-filter-interpreter.c index 5c0cea5a..6c77cfe9 100644 --- a/liblttng-ust/lttng-filter-interpreter.c +++ b/liblttng-ust/lttng-filter-interpreter.c @@ -25,9 +25,10 @@ */ #define _LGPL_SOURCE -#include +#include #include -#include +#include +#include #include "lttng-filter.h" #include "string-utils.h" @@ -163,7 +164,7 @@ int stack_strcmp(struct estack *stack, int top, const char *cmp_type) uint64_t lttng_filter_false(void *filter_data, const char *filter_stack_data) { - return 0; + return LTTNG_FILTER_DISCARD; } #ifdef INTERPRETER_USE_SWITCH @@ -219,6 +220,9 @@ LABEL_##name #endif +#define IS_INTEGER_REGISTER(reg_type) \ + (reg_type == REG_U64 || reg_type == REG_S64) + static int context_get_index(struct lttng_ctx *ctx, struct load_ptr *ptr, uint32_t idx) @@ -237,7 +241,7 @@ static int context_get_index(struct lttng_ctx *ctx, switch (field->type.atype) { case atype_integer: ctx_field->get_value(ctx_field, &v); - if (field->type.u.basic.integer.signedness) { + if (field->type.u.integer.signedness) { ptr->object_type = OBJECT_TYPE_S64; ptr->u.s64 = v.u.s64; ptr->ptr = &ptr->u.s64; @@ -247,11 +251,16 @@ static int context_get_index(struct lttng_ctx *ctx, ptr->ptr = &ptr->u.u64; } break; - case atype_enum: + case atype_enum: /* Fall-through */ + case atype_enum_nestable: { - const struct lttng_integer_type *itype = - &field->type.u.basic.enumeration.container_type; + 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; + } ctx_field->get_value(ctx_field, &v); if (itype->signedness) { ptr->object_type = OBJECT_TYPE_S64; @@ -265,11 +274,24 @@ static int context_get_index(struct lttng_ctx *ctx, break; } case atype_array: - if (field->type.u.array.elem_type.atype != atype_integer) { + if (field->type.u.legacy.array.elem_type.atype != atype_integer) { ERR("Array nesting only supports integer types."); return -EINVAL; } - if (field->type.u.array.elem_type.u.basic.integer.encoding == lttng_encode_none) { + 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."); + return -EINVAL; + } + if (field->type.u.array_nestable.elem_type->u.integer.encoding == lttng_encode_none) { ERR("Only string arrays are supported for contexts."); return -EINVAL; } @@ -278,11 +300,24 @@ static int context_get_index(struct lttng_ctx *ctx, ptr->ptr = v.u.str; break; case atype_sequence: - if (field->type.u.sequence.elem_type.atype != atype_integer) { + 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."); return -EINVAL; } - if (field->type.u.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none) { + if (field->type.u.sequence_nestable.elem_type->u.integer.encoding == lttng_encode_none) { ERR("Only string sequences are supported for contexts."); return -EINVAL; } @@ -297,6 +332,7 @@ static int context_get_index(struct lttng_ctx *ctx, break; case atype_float: ptr->object_type = OBJECT_TYPE_DOUBLE; + ctx_field->get_value(ctx_field, &v); ptr->u.d = v.u.d; ptr->ptr = &ptr->u.d; break; @@ -337,7 +373,7 @@ static int context_get_index(struct lttng_ctx *ctx, 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) { @@ -404,9 +440,6 @@ static int dynamic_get_index(struct lttng_session *session, 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); @@ -491,18 +524,18 @@ static int dynamic_load_field(struct estack_entry *stack_top) case OBJECT_TYPE_U8: dbg_printf("op load field u8\n"); stack_top->u.v = *(uint8_t *) stack_top->u.ptr.ptr; - stack_top->type = REG_S64; + stack_top->type = REG_U64; break; case OBJECT_TYPE_U16: { uint16_t tmp; - dbg_printf("op load field s16\n"); + dbg_printf("op load field u16\n"); tmp = *(uint16_t *) stack_top->u.ptr.ptr; if (stack_top->u.ptr.rev_bo) tmp = bswap_16(tmp); stack_top->u.v = tmp; - stack_top->type = REG_S64; + stack_top->type = REG_U64; break; } case OBJECT_TYPE_U32: @@ -514,7 +547,7 @@ static int dynamic_load_field(struct estack_entry *stack_top) if (stack_top->u.ptr.rev_bo) tmp = bswap_32(tmp); stack_top->u.v = tmp; - stack_top->type = REG_S64; + stack_top->type = REG_U64; break; } case OBJECT_TYPE_U64: @@ -526,7 +559,7 @@ static int dynamic_load_field(struct estack_entry *stack_top) if (stack_top->u.ptr.rev_bo) tmp = bswap_64(tmp); stack_top->u.v = tmp; - stack_top->type = REG_S64; + stack_top->type = REG_U64; break; } case OBJECT_TYPE_DOUBLE: @@ -601,7 +634,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, 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; @@ -622,8 +655,8 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, [ FILTER_OP_MOD ] = &&LABEL_FILTER_OP_MOD, [ FILTER_OP_PLUS ] = &&LABEL_FILTER_OP_PLUS, [ FILTER_OP_MINUS ] = &&LABEL_FILTER_OP_MINUS, - [ FILTER_OP_RSHIFT ] = &&LABEL_FILTER_OP_RSHIFT, - [ FILTER_OP_LSHIFT ] = &&LABEL_FILTER_OP_LSHIFT, + [ FILTER_OP_BIT_RSHIFT ] = &&LABEL_FILTER_OP_BIT_RSHIFT, + [ FILTER_OP_BIT_LSHIFT ] = &&LABEL_FILTER_OP_BIT_LSHIFT, [ FILTER_OP_BIT_AND ] = &&LABEL_FILTER_OP_BIT_AND, [ FILTER_OP_BIT_OR ] = &&LABEL_FILTER_OP_BIT_OR, [ FILTER_OP_BIT_XOR ] = &&LABEL_FILTER_OP_BIT_XOR, @@ -740,6 +773,10 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, [ FILTER_OP_LOAD_FIELD_STRING ] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING, [ FILTER_OP_LOAD_FIELD_SEQUENCE ] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE, [ FILTER_OP_LOAD_FIELD_DOUBLE ] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE, + + [ FILTER_OP_UNARY_BIT_NOT ] = &&LABEL_FILTER_OP_UNARY_BIT_NOT, + + [ FILTER_OP_RETURN_S64 ] = &&LABEL_FILTER_OP_RETURN_S64, }; #endif /* #ifndef INTERPRETER_USE_SWITCH */ @@ -756,10 +793,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, goto end; OP(FILTER_OP_RETURN): - /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */ + /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */ /* Handle dynamic typing. */ switch (estack_ax_t) { case REG_S64: + case REG_U64: retval = !!estack_ax_v; break; case REG_DOUBLE: @@ -772,14 +810,18 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, ret = 0; goto end; + OP(FILTER_OP_RETURN_S64): + /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */ + retval = !!estack_ax_v; + ret = 0; + goto end; + /* binary */ OP(FILTER_OP_MUL): OP(FILTER_OP_DIV): OP(FILTER_OP_MOD): OP(FILTER_OP_PLUS): OP(FILTER_OP_MINUS): - OP(FILTER_OP_RSHIFT): - OP(FILTER_OP_LSHIFT): ERR("unsupported bytecode op %u", (unsigned int) *(filter_opcode_t *) pc); ret = -EINVAL; @@ -789,9 +831,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { /* Dynamic typing. */ switch (estack_ax_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_EQ_S64); case REG_DOUBLE: JUMP_TO(FILTER_OP_EQ_DOUBLE_S64); @@ -808,7 +852,8 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, break; case REG_DOUBLE: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_EQ_S64_DOUBLE); case REG_DOUBLE: JUMP_TO(FILTER_OP_EQ_DOUBLE); @@ -826,6 +871,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, case REG_STRING: switch (estack_bx_t) { case REG_S64: /* Fall-through */ + case REG_U64: /* Fall-through */ case REG_DOUBLE: ret = -EINVAL; goto end; @@ -843,6 +889,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, case REG_STAR_GLOB_STRING: switch (estack_bx_t) { case REG_S64: /* Fall-through */ + case REG_U64: /* Fall-through */ case REG_DOUBLE: ret = -EINVAL; goto end; @@ -869,9 +916,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { /* Dynamic typing. */ switch (estack_ax_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_NE_S64); case REG_DOUBLE: JUMP_TO(FILTER_OP_NE_DOUBLE_S64); @@ -888,7 +937,8 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, break; case REG_DOUBLE: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_NE_S64_DOUBLE); case REG_DOUBLE: JUMP_TO(FILTER_OP_NE_DOUBLE); @@ -906,6 +956,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, case REG_STRING: switch (estack_bx_t) { case REG_S64: /* Fall-through */ + case REG_U64: case REG_DOUBLE: ret = -EINVAL; goto end; @@ -923,6 +974,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, case REG_STAR_GLOB_STRING: switch (estack_bx_t) { case REG_S64: /* Fall-through */ + case REG_U64: case REG_DOUBLE: ret = -EINVAL; goto end; @@ -949,9 +1001,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { /* Dynamic typing. */ switch (estack_ax_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_GT_S64); case REG_DOUBLE: JUMP_TO(FILTER_OP_GT_DOUBLE_S64); @@ -968,7 +1022,8 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, break; case REG_DOUBLE: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_GT_S64_DOUBLE); case REG_DOUBLE: JUMP_TO(FILTER_OP_GT_DOUBLE); @@ -986,6 +1041,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, case REG_STRING: switch (estack_bx_t) { case REG_S64: /* Fall-through */ + case REG_U64: /* Fall-through */ case REG_DOUBLE: /* Fall-through */ case REG_STAR_GLOB_STRING: ret = -EINVAL; @@ -1010,9 +1066,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { /* Dynamic typing. */ switch (estack_ax_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_LT_S64); case REG_DOUBLE: JUMP_TO(FILTER_OP_LT_DOUBLE_S64); @@ -1029,7 +1087,8 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, break; case REG_DOUBLE: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_LT_S64_DOUBLE); case REG_DOUBLE: JUMP_TO(FILTER_OP_LT_DOUBLE); @@ -1047,6 +1106,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, case REG_STRING: switch (estack_bx_t) { case REG_S64: /* Fall-through */ + case REG_U64: /* Fall-through */ case REG_DOUBLE: /* Fall-through */ case REG_STAR_GLOB_STRING: ret = -EINVAL; @@ -1071,9 +1131,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { /* Dynamic typing. */ switch (estack_ax_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_GE_S64); case REG_DOUBLE: JUMP_TO(FILTER_OP_GE_DOUBLE_S64); @@ -1090,7 +1152,8 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, break; case REG_DOUBLE: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_GE_S64_DOUBLE); case REG_DOUBLE: JUMP_TO(FILTER_OP_GE_DOUBLE); @@ -1108,6 +1171,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, case REG_STRING: switch (estack_bx_t) { case REG_S64: /* Fall-through */ + case REG_U64: /* Fall-through */ case REG_DOUBLE: /* Fall-through */ case REG_STAR_GLOB_STRING: ret = -EINVAL; @@ -1132,9 +1196,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { /* Dynamic typing. */ switch (estack_ax_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_LE_S64); case REG_DOUBLE: JUMP_TO(FILTER_OP_LE_DOUBLE_S64); @@ -1151,7 +1217,8 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, break; case REG_DOUBLE: switch (estack_bx_t) { - case REG_S64: + case REG_S64: /* Fall-through */ + case REG_U64: JUMP_TO(FILTER_OP_LE_S64_DOUBLE); case REG_DOUBLE: JUMP_TO(FILTER_OP_LE_DOUBLE); @@ -1169,6 +1236,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, case REG_STRING: switch (estack_bx_t) { case REG_S64: /* Fall-through */ + case REG_U64: /* Fall-through */ case REG_DOUBLE: /* Fall-through */ case REG_STAR_GLOB_STRING: ret = -EINVAL; @@ -1548,20 +1616,61 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, next_pc += sizeof(struct binary_op); PO; } + OP(FILTER_OP_BIT_RSHIFT): + { + int64_t res; + + if (!IS_INTEGER_REGISTER(estack_ax_t) || !IS_INTEGER_REGISTER(estack_bx_t)) { + ret = -EINVAL; + goto end; + } + + /* Catch undefined behavior. */ + if (caa_unlikely(estack_ax_v < 0 || estack_ax_v >= 64)) { + ret = -EINVAL; + goto end; + } + res = ((uint64_t) estack_bx_v >> (uint32_t) estack_ax_v); + estack_pop(stack, top, ax, bx, ax_t, bx_t); + estack_ax_v = res; + estack_ax_t = REG_U64; + next_pc += sizeof(struct binary_op); + PO; + } + OP(FILTER_OP_BIT_LSHIFT): + { + int64_t res; + + if (!IS_INTEGER_REGISTER(estack_ax_t) || !IS_INTEGER_REGISTER(estack_bx_t)) { + ret = -EINVAL; + goto end; + } + + /* Catch undefined behavior. */ + if (caa_unlikely(estack_ax_v < 0 || estack_ax_v >= 64)) { + ret = -EINVAL; + goto end; + } + res = ((uint64_t) estack_bx_v << (uint32_t) estack_ax_v); + estack_pop(stack, top, ax, bx, ax_t, bx_t); + estack_ax_v = res; + estack_ax_t = REG_U64; + next_pc += sizeof(struct binary_op); + PO; + } OP(FILTER_OP_BIT_AND): { int64_t res; - /* Dynamic typing. */ - if (estack_ax_t != REG_S64 || estack_bx_t != REG_S64) { + if (!IS_INTEGER_REGISTER(estack_ax_t) || !IS_INTEGER_REGISTER(estack_bx_t)) { ret = -EINVAL; goto end; } - res = (estack_bx_v & estack_ax_v); + res = ((uint64_t) estack_bx_v & (uint64_t) estack_ax_v); estack_pop(stack, top, ax, bx, ax_t, bx_t); estack_ax_v = res; - estack_ax_t = REG_S64; + estack_ax_t = REG_U64; next_pc += sizeof(struct binary_op); PO; } @@ -1569,16 +1678,15 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { int64_t res; - /* Dynamic typing. */ - if (estack_ax_t != REG_S64 || estack_bx_t != REG_S64) { + if (!IS_INTEGER_REGISTER(estack_ax_t) || !IS_INTEGER_REGISTER(estack_bx_t)) { ret = -EINVAL; goto end; } - res = (estack_bx_v | estack_ax_v); + res = ((uint64_t) estack_bx_v | (uint64_t) estack_ax_v); estack_pop(stack, top, ax, bx, ax_t, bx_t); estack_ax_v = res; - estack_ax_t = REG_S64; + estack_ax_t = REG_U64; next_pc += sizeof(struct binary_op); PO; } @@ -1586,16 +1694,15 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { int64_t res; - /* Dynamic typing. */ - if (estack_ax_t != REG_S64 || estack_bx_t != REG_S64) { + if (!IS_INTEGER_REGISTER(estack_ax_t) || !IS_INTEGER_REGISTER(estack_bx_t)) { ret = -EINVAL; goto end; } - res = (estack_bx_v ^ estack_ax_v); + res = ((uint64_t) estack_bx_v ^ (uint64_t) estack_ax_v); estack_pop(stack, top, ax, bx, ax_t, bx_t); estack_ax_v = res; - estack_ax_t = REG_S64; + estack_ax_t = REG_U64; next_pc += sizeof(struct binary_op); PO; } @@ -1606,6 +1713,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, /* Dynamic typing. */ switch (estack_ax_t) { case REG_S64: /* Fall-through. */ + case REG_U64: JUMP_TO(FILTER_OP_UNARY_PLUS_S64); case REG_DOUBLE: JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE); @@ -1624,7 +1732,8 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { /* Dynamic typing. */ switch (estack_ax_t) { - case REG_S64: + case REG_S64: /* Fall-through. */ + case REG_U64: JUMP_TO(FILTER_OP_UNARY_MINUS_S64); case REG_DOUBLE: JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE); @@ -1643,7 +1752,8 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { /* Dynamic typing. */ switch (estack_ax_t) { - case REG_S64: + case REG_S64: /* Fall-through. */ + case REG_U64: JUMP_TO(FILTER_OP_UNARY_NOT_S64); case REG_DOUBLE: JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE); @@ -1661,6 +1771,20 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, PO; } + OP(FILTER_OP_UNARY_BIT_NOT): + { + /* Dynamic typing. */ + if (!IS_INTEGER_REGISTER(estack_ax_t)) { + ret = -EINVAL; + goto end; + } + + estack_ax_v = ~(uint64_t) estack_ax_v; + estack_ax_t = REG_U64; + next_pc += sizeof(struct unary_op); + PO; + } + OP(FILTER_OP_UNARY_PLUS_S64): OP(FILTER_OP_UNARY_PLUS_DOUBLE): { @@ -1682,6 +1806,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, OP(FILTER_OP_UNARY_NOT_S64): { estack_ax_v = !estack_ax_v; + estack_ax_t = REG_S64; next_pc += sizeof(struct unary_op); PO; } @@ -1698,7 +1823,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { struct logical_op *insn = (struct logical_op *) pc; - if (estack_ax_t != REG_S64) { + if (estack_ax_t != REG_S64 && estack_ax_t != REG_U64) { ret = -EINVAL; goto end; } @@ -1718,7 +1843,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { struct logical_op *insn = (struct logical_op *) pc; - if (estack_ax_t != REG_S64) { + if (estack_ax_t != REG_S64 && estack_ax_t != REG_U64) { ret = -EINVAL; goto end; } @@ -1886,6 +2011,9 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, JUMP_TO(FILTER_OP_CAST_NOP); case REG_DOUBLE: JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64); + case REG_U64: + estack_ax_t = REG_S64; + next_pc += sizeof(struct cast_op); case REG_STRING: /* Fall-through */ case REG_STAR_GLOB_STRING: ret = -EINVAL; @@ -1917,13 +2045,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { 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); @@ -1967,13 +2093,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { 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); @@ -1996,13 +2120,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { 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); @@ -2017,13 +2139,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, { 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); @@ -2109,7 +2229,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, 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; @@ -2124,7 +2244,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, 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; @@ -2186,7 +2306,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, dbg_printf("op load field u8\n"); estack_ax_v = *(uint8_t *) estack_ax(stack, top)->u.ptr.ptr; - estack_ax_t = REG_S64; + estack_ax_t = REG_U64; next_pc += sizeof(struct load_op); PO; } @@ -2195,7 +2315,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, dbg_printf("op load field u16\n"); estack_ax_v = *(uint16_t *) estack_ax(stack, top)->u.ptr.ptr; - estack_ax_t = REG_S64; + estack_ax_t = REG_U64; next_pc += sizeof(struct load_op); PO; } @@ -2204,7 +2324,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, dbg_printf("op load field u32\n"); estack_ax_v = *(uint32_t *) estack_ax(stack, top)->u.ptr.ptr; - estack_ax_t = REG_S64; + estack_ax_t = REG_U64; next_pc += sizeof(struct load_op); PO; } @@ -2213,7 +2333,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, dbg_printf("op load field u64\n"); estack_ax_v = *(uint64_t *) estack_ax(stack, top)->u.ptr.ptr; - estack_ax_t = REG_S64; + estack_ax_t = REG_U64; next_pc += sizeof(struct load_op); PO; } @@ -2271,9 +2391,9 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, END_OP end: - /* return 0 (discard) on error */ + /* Return _DISCARD on error. */ if (ret) - return 0; + return LTTNG_FILTER_DISCARD; return retval; }