From: Mathieu Desnoyers Date: Mon, 25 Sep 2017 15:37:28 +0000 (-0400) Subject: Filter: add FILTER_OP_RETURN_S64 instruction X-Git-Tag: v2.11.0-rc1~8 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=93c591bb3a90753ce66197f2c1e41c8ef554506f;p=lttng-ust.git Filter: add FILTER_OP_RETURN_S64 instruction Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust/filter-bytecode.h b/liblttng-ust/filter-bytecode.h index f937324d..9a2d4c0a 100644 --- a/liblttng-ust/filter-bytecode.h +++ b/liblttng-ust/filter-bytecode.h @@ -206,6 +206,8 @@ enum filter_op { FILTER_OP_UNARY_BIT_NOT = 98, + FILTER_OP_RETURN_S64 = 99, + NR_FILTER_OPS, }; diff --git a/liblttng-ust/lttng-filter-interpreter.c b/liblttng-ust/lttng-filter-interpreter.c index 753880c3..59bc72cd 100644 --- a/liblttng-ust/lttng-filter-interpreter.c +++ b/liblttng-ust/lttng-filter-interpreter.c @@ -742,6 +742,8 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, [ 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 */ @@ -774,6 +776,12 @@ 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): diff --git a/liblttng-ust/lttng-filter-specialize.c b/liblttng-ust/lttng-filter-specialize.c index 6de25047..1ade2883 100644 --- a/liblttng-ust/lttng-filter-specialize.c +++ b/liblttng-ust/lttng-filter-specialize.c @@ -621,6 +621,17 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, goto end; case FILTER_OP_RETURN: + if (vstack_ax(stack)->type == REG_S64) + *(filter_opcode_t *) pc = FILTER_OP_RETURN_S64; + ret = 0; + goto end; + + case FILTER_OP_RETURN_S64: + if (vstack_ax(stack)->type != REG_S64) { + ERR("Unexpected register type\n"); + ret = -EINVAL; + goto end; + } ret = 0; goto end; diff --git a/liblttng-ust/lttng-filter-validator.c b/liblttng-ust/lttng-filter-validator.c index 4fe8e893..92455c80 100644 --- a/liblttng-ust/lttng-filter-validator.c +++ b/liblttng-ust/lttng-filter-validator.c @@ -296,6 +296,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode, } case FILTER_OP_RETURN: + case FILTER_OP_RETURN_S64: { if (unlikely(pc + sizeof(struct return_op) > start_pc + bytecode->len)) { @@ -578,6 +579,7 @@ int validate_instruction_context(struct bytecode_runtime *bytecode, } case FILTER_OP_RETURN: + case FILTER_OP_RETURN_S64: { goto end; } @@ -1255,6 +1257,27 @@ int exec_insn(struct bytecode_runtime *bytecode, ret = 0; goto end; } + case FILTER_OP_RETURN_S64: + { + if (!vstack_ax(stack)) { + ERR("Empty stack\n"); + ret = -EINVAL; + goto end; + } + switch (vstack_ax(stack)->type) { + case REG_S64: + break; + default: + case REG_UNKNOWN: + ERR("Unexpected register type %d at end of bytecode\n", + (int) vstack_ax(stack)->type); + ret = -EINVAL; + goto end; + } + + ret = 0; + goto end; + } /* binary */ case FILTER_OP_MUL: diff --git a/liblttng-ust/lttng-filter.c b/liblttng-ust/lttng-filter.c index b7f058a8..d52658ae 100644 --- a/liblttng-ust/lttng-filter.c +++ b/liblttng-ust/lttng-filter.c @@ -170,6 +170,8 @@ static const char *opnames[] = { [ FILTER_OP_LOAD_FIELD_DOUBLE ] = "LOAD_FIELD_DOUBLE", [ FILTER_OP_UNARY_BIT_NOT ] = "UNARY_BIT_NOT", + + [ FILTER_OP_RETURN_S64 ] = "RETURN_S64", }; const char *print_op(enum filter_op op)