X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust%2Flttng-bytecode-interpreter.c;h=a384d61f068c92d2d2e4d0b54eb42ddc42f4fe36;hb=3d3dc207c16d90ecd80eb1e757fe8b94ff317c63;hp=d1f38f2b06665db3c89a90e06505571ce7aeb247;hpb=22c30e27e59035f165bfa0540022eeca113fcd59;p=lttng-ust.git diff --git a/liblttng-ust/lttng-bytecode-interpreter.c b/liblttng-ust/lttng-bytecode-interpreter.c index d1f38f2b..a384d61f 100644 --- a/liblttng-ust/lttng-bytecode-interpreter.c +++ b/liblttng-ust/lttng-bytecode-interpreter.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include "ust-events-internal.h" @@ -698,19 +699,20 @@ again: } /* - * For `output` equal to NULL: - * Return 0 (discard), or raise the 0x1 flag (log event). - * Currently, other flags are kept for future extensions and have no - * effect. - * For `output` not equal to NULL: - * Return 0 on success, negative error value on error. + * Return LTTNG_UST_BYTECODE_INTERPRETER_OK on success. + * Return LTTNG_UST_BYTECODE_INTERPRETER_ERROR on error. + * + * For FILTER bytecode: expect a struct lttng_ust_bytecode_filter_ctx * + * as @ctx argument. + * For CAPTURE bytecode: expect a struct lttng_interpreter_output * + * as @ctx argument. */ int lttng_bytecode_interpret(struct lttng_ust_bytecode_runtime *ust_bytecode, const char *interpreter_stack_data, void *caller_ctx) { struct bytecode_runtime *bytecode = caa_container_of(ust_bytecode, struct bytecode_runtime, p); - struct lttng_ust_ctx *ctx = lttng_ust_rcu_dereference(*ust_bytecode->priv->pctx); + struct lttng_ust_ctx *ctx = lttng_ust_rcu_dereference(*ust_bytecode->pctx); void *pc, *next_pc, *start_pc; int ret = -EINVAL, retval = 0; struct estack _stack; @@ -878,7 +880,7 @@ int lttng_bytecode_interpret(struct lttng_ust_bytecode_runtime *ust_bytecode, case REG_DOUBLE: case REG_STRING: case REG_PTR: - if (ust_bytecode->priv->type != LTTNG_UST_BYTECODE_TYPE_CAPTURE) { + if (ust_bytecode->type != LTTNG_UST_BYTECODE_TYPE_CAPTURE) { ret = -EINVAL; goto end; } @@ -2479,7 +2481,7 @@ end: return LTTNG_UST_BYTECODE_INTERPRETER_ERROR; /* Prepare output. */ - switch (ust_bytecode->priv->type) { + switch (ust_bytecode->type) { case LTTNG_UST_BYTECODE_TYPE_FILTER: { struct lttng_ust_bytecode_filter_ctx *filter_ctx = @@ -2504,6 +2506,33 @@ end: return LTTNG_UST_BYTECODE_INTERPRETER_OK; } +/* + * Return LTTNG_UST_EVENT_FILTER_ACCEPT or LTTNG_UST_EVENT_FILTER_REJECT. + */ +int lttng_ust_interpret_event_filter(struct lttng_ust_event_common *event, + const char *interpreter_stack_data, + void *event_filter_ctx) +{ + struct lttng_ust_bytecode_runtime *filter_bc_runtime; + struct cds_list_head *filter_bytecode_runtime_head = &event->priv->filter_bytecode_runtime_head; + struct lttng_ust_bytecode_filter_ctx bytecode_filter_ctx; + bool filter_record = false; + + cds_list_for_each_entry_rcu(filter_bc_runtime, filter_bytecode_runtime_head, node) { + if (caa_likely(filter_bc_runtime->interpreter_func(filter_bc_runtime, + interpreter_stack_data, &bytecode_filter_ctx) == LTTNG_UST_BYTECODE_INTERPRETER_OK)) { + if (caa_unlikely(bytecode_filter_ctx.result == LTTNG_UST_BYTECODE_FILTER_ACCEPT)) { + filter_record = true; + break; + } + } + } + if (filter_record) + return LTTNG_UST_EVENT_FILTER_ACCEPT; + else + return LTTNG_UST_EVENT_FILTER_REJECT; +} + #undef START_OP #undef OP #undef PO