From: Mathieu Desnoyers Date: Mon, 25 Sep 2017 15:37:14 +0000 (-0400) Subject: Filter: add FILTER_OP_RETURN_S64 instruction X-Git-Tag: v2.11.0-rc1~45 X-Git-Url: http://git.lttng.org/?p=lttng-modules.git;a=commitdiff_plain;h=57ba4b4152578d463e8642ec0000cd3d6114ee6f Filter: add FILTER_OP_RETURN_S64 instruction Signed-off-by: Mathieu Desnoyers --- diff --git a/filter-bytecode.h b/filter-bytecode.h index 2aa5c2d0..bd83d089 100644 --- a/filter-bytecode.h +++ b/filter-bytecode.h @@ -204,6 +204,8 @@ enum filter_op { FILTER_OP_UNARY_BIT_NOT = 98, + FILTER_OP_RETURN_S64 = 99, + NR_FILTER_OPS, }; diff --git a/lttng-filter-interpreter.c b/lttng-filter-interpreter.c index 4e6c91a7..7263ce96 100644 --- a/lttng-filter-interpreter.c +++ b/lttng-filter-interpreter.c @@ -771,6 +771,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 */ @@ -788,6 +790,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, goto end; OP(FILTER_OP_RETURN): + OP(FILTER_OP_RETURN_S64): /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */ retval = !!estack_ax_v; ret = 0; diff --git a/lttng-filter-specialize.c b/lttng-filter-specialize.c index b9ddfb10..c0c3e110 100644 --- a/lttng-filter-specialize.c +++ b/lttng-filter-specialize.c @@ -518,6 +518,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, goto end; case FILTER_OP_RETURN: + case FILTER_OP_RETURN_S64: ret = 0; goto end; diff --git a/lttng-filter-validator.c b/lttng-filter-validator.c index c7b81bb6..051db49c 100644 --- a/lttng-filter-validator.c +++ b/lttng-filter-validator.c @@ -303,6 +303,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)) { @@ -586,6 +587,7 @@ int validate_instruction_context(struct bytecode_runtime *bytecode, } case FILTER_OP_RETURN: + case FILTER_OP_RETURN_S64: { goto end; } @@ -1183,6 +1185,28 @@ int exec_insn(struct bytecode_runtime *bytecode, goto end; } + case FILTER_OP_RETURN_S64: + { + if (!vstack_ax(stack)) { + printk(KERN_WARNING "Empty stack\n"); + ret = -EINVAL; + goto end; + } + switch (vstack_ax(stack)->type) { + case REG_S64: + break; + default: + case REG_TYPE_UNKNOWN: + printk(KERN_WARNING "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: case FILTER_OP_DIV: diff --git a/lttng-filter.c b/lttng-filter.c index ff976743..86c21ee4 100644 --- a/lttng-filter.c +++ b/lttng-filter.c @@ -171,6 +171,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 *lttng_filter_print_op(enum filter_op op)