Filter: add FILTER_OP_RETURN_S64 instruction
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 25 Sep 2017 15:37:14 +0000 (11:37 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 6 Jun 2018 20:42:04 +0000 (16:42 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
filter-bytecode.h
lttng-filter-interpreter.c
lttng-filter-specialize.c
lttng-filter-validator.c
lttng-filter.c

index 2aa5c2d08462b6ca23129848b5ea8144d61c32f9..bd83d0891570b01daff304102bd58db7c4aa299b 100644 (file)
@@ -204,6 +204,8 @@ enum filter_op {
 
        FILTER_OP_UNARY_BIT_NOT                 = 98,
 
+       FILTER_OP_RETURN_S64                    = 99,
+
        NR_FILTER_OPS,
 };
 
index 4e6c91a7511715f2292fda00270a3f2e9d85effe..7263ce9636f6ccb3630babe5b348d93954c6ad3f 100644 (file)
@@ -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;
index b9ddfb100225846e889e43b8eaa1cecf1f8bcb92..c0c3e11042fab0db646419807dec340c3330e89a 100644 (file)
@@ -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;
 
index c7b81bb6bbd193187434bd5f2b5f21a48f3fff7a..051db49c87e5f75d7ea5c525ce76fcba90ddef7a 100644 (file)
@@ -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:
index ff9767436fb7dec2ed4a082fc8c586183f505deb..86c21ee421c08562b6694177e2d774493e285ec5 100644 (file)
@@ -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)
This page took 0.029147 seconds and 4 git commands to generate.