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

index f937324d1fd853e236807812d3500994da895293..9a2d4c0a0c04e454be39c96212620f60565237d3 100644 (file)
@@ -206,6 +206,8 @@ enum filter_op {
 
        FILTER_OP_UNARY_BIT_NOT                 = 98,
 
+       FILTER_OP_RETURN_S64                    = 99,
+
        NR_FILTER_OPS,
 };
 
index 753880c3e269692072f9a6c416a22868e86e77ce..59bc72cdf442027e8e78ba535c91a9e13bd7502f 100644 (file)
@@ -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):
index 6de25047787d2b09954d1ce88815f53988463cea..1ade2883005bdc93f4f7b33abeb1bcad4c5a02ee 100644 (file)
@@ -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;
 
index 4fe8e8938d9ccd889d47a50f8d58910c62fdf68a..92455c80a554766830dda045ccd5f73d76dc5b09 100644 (file)
@@ -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:
index b7f058a8dac27d680d82786ef9f9337a7b5b6410..d52658ae14dd7f4e135a5e6e0df306069bd94f4b 100644 (file)
@@ -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)
This page took 0.040555 seconds and 4 git commands to generate.