Fix: uninitialized variable in lib_ring_buffer_reserve_committed
[lttng-ust.git] / liblttng-ust / lttng-filter-interpreter.c
index 5c0cea5a4d2d99c05513b74f44be72bf04fdb7f9..59bc72cdf442027e8e78ba535c91a9e13bd7502f 100644 (file)
@@ -622,8 +622,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 +740,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 */
 
@@ -772,14 +776,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;
@@ -1548,6 +1556,48 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
                        next_pc += sizeof(struct binary_op);
                        PO;
                }
+               OP(FILTER_OP_BIT_RSHIFT):
+               {
+                       int64_t res;
+
+                       /* Dynamic typing. */
+                       if (estack_ax_t != REG_S64 || estack_bx_t != REG_S64) {
+                               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_S64;
+                       next_pc += sizeof(struct binary_op);
+                       PO;
+               }
+               OP(FILTER_OP_BIT_LSHIFT):
+               {
+                       int64_t res;
+
+                       /* Dynamic typing. */
+                       if (estack_ax_t != REG_S64 || estack_bx_t != REG_S64) {
+                               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_S64;
+                       next_pc += sizeof(struct binary_op);
+                       PO;
+               }
                OP(FILTER_OP_BIT_AND):
                {
                        int64_t res;
@@ -1558,7 +1608,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
                                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;
@@ -1575,7 +1625,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
                                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;
@@ -1592,7 +1642,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
                                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;
@@ -1661,6 +1711,19 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
                        PO;
                }
 
+               OP(FILTER_OP_UNARY_BIT_NOT):
+               {
+                       /* Dynamic typing. */
+                       if (estack_ax_t != REG_S64) {
+                               ret = -EINVAL;
+                               goto end;
+                       }
+
+                       estack_ax_v = ~(uint64_t) estack_ax_v;
+                       next_pc += sizeof(struct unary_op);
+                       PO;
+               }
+
                OP(FILTER_OP_UNARY_PLUS_S64):
                OP(FILTER_OP_UNARY_PLUS_DOUBLE):
                {
This page took 0.02547 seconds and 4 git commands to generate.