*/
#define _LGPL_SOURCE
-#include <urcu-pointer.h>
+#include <stddef.h>
#include <stdint.h>
-#include <byteswap.h>
+#include <urcu-pointer.h>
+#include <lttng/ust-endian.h>
#include "lttng-filter.h"
#include "string-utils.h"
uint64_t lttng_filter_false(void *filter_data,
const char *filter_stack_data)
{
- return 0;
+ return LTTNG_FILTER_DISCARD;
}
#ifdef INTERPRETER_USE_SWITCH
switch (field->type.atype) {
case atype_integer:
ctx_field->get_value(ctx_field, &v);
- if (field->type.u.basic.integer.signedness) {
+ if (field->type.u.integer.signedness) {
ptr->object_type = OBJECT_TYPE_S64;
ptr->u.s64 = v.u.s64;
ptr->ptr = &ptr->u.s64;
ptr->ptr = &ptr->u.u64;
}
break;
- case atype_enum:
+ case atype_enum: /* Fall-through */
+ case atype_enum_nestable:
{
- const struct lttng_integer_type *itype =
- &field->type.u.basic.enumeration.container_type;
+ const struct lttng_integer_type *itype;
+ if (field->type.atype == atype_enum) {
+ itype = &field->type.u.legacy.basic.enumeration.container_type;
+ } else {
+ itype = &field->type.u.enum_nestable.container_type->u.integer;
+ }
ctx_field->get_value(ctx_field, &v);
if (itype->signedness) {
ptr->object_type = OBJECT_TYPE_S64;
break;
}
case atype_array:
- if (field->type.u.array.elem_type.atype != atype_integer) {
+ if (field->type.u.legacy.array.elem_type.atype != atype_integer) {
+ ERR("Array nesting only supports integer types.");
+ return -EINVAL;
+ }
+ if (field->type.u.legacy.array.elem_type.u.basic.integer.encoding == lttng_encode_none) {
+ ERR("Only string arrays are supported for contexts.");
+ return -EINVAL;
+ }
+ ptr->object_type = OBJECT_TYPE_STRING;
+ ctx_field->get_value(ctx_field, &v);
+ ptr->ptr = v.u.str;
+ break;
+ case atype_array_nestable:
+ if (field->type.u.array_nestable.elem_type->atype != atype_integer) {
ERR("Array nesting only supports integer types.");
return -EINVAL;
}
- if (field->type.u.array.elem_type.u.basic.integer.encoding == lttng_encode_none) {
+ if (field->type.u.array_nestable.elem_type->u.integer.encoding == lttng_encode_none) {
ERR("Only string arrays are supported for contexts.");
return -EINVAL;
}
ptr->ptr = v.u.str;
break;
case atype_sequence:
- if (field->type.u.sequence.elem_type.atype != atype_integer) {
+ if (field->type.u.legacy.sequence.elem_type.atype != atype_integer) {
ERR("Sequence nesting only supports integer types.");
return -EINVAL;
}
- if (field->type.u.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none) {
+ if (field->type.u.legacy.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none) {
+ ERR("Only string sequences are supported for contexts.");
+ return -EINVAL;
+ }
+ ptr->object_type = OBJECT_TYPE_STRING;
+ ctx_field->get_value(ctx_field, &v);
+ ptr->ptr = v.u.str;
+ break;
+ case atype_sequence_nestable:
+ if (field->type.u.sequence_nestable.elem_type->atype != atype_integer) {
+ ERR("Sequence nesting only supports integer types.");
+ return -EINVAL;
+ }
+ if (field->type.u.sequence_nestable.elem_type->u.integer.encoding == lttng_encode_none) {
ERR("Only string sequences are supported for contexts.");
return -EINVAL;
}
break;
case atype_float:
ptr->object_type = OBJECT_TYPE_DOUBLE;
+ ctx_field->get_value(ctx_field, &v);
ptr->u.d = v.u.d;
ptr->ptr = &ptr->u.d;
break;
return 0;
}
-static int dynamic_get_index(struct lttng_session *session,
+static int dynamic_get_index(struct lttng_ctx *ctx,
struct bytecode_runtime *runtime,
uint64_t index, struct estack_entry *stack_top)
{
case LOAD_ROOT_CONTEXT:
case LOAD_ROOT_APP_CONTEXT: /* Fall-through */
{
- struct lttng_ctx *ctx;
-
- ctx = rcu_dereference(session->ctx);
ret = context_get_index(ctx,
&stack_top->u.ptr,
gid->ctx_index);
{
uint16_t tmp;
- dbg_printf("op load field s16\n");
+ dbg_printf("op load field u16\n");
tmp = *(uint16_t *) stack_top->u.ptr.ptr;
if (stack_top->u.ptr.rev_bo)
tmp = bswap_16(tmp);
const char *filter_stack_data)
{
struct bytecode_runtime *bytecode = filter_data;
- struct lttng_session *session = bytecode->p.session;
+ struct lttng_ctx *ctx = rcu_dereference(*bytecode->p.pctx);
void *pc, *next_pc, *start_pc;
int ret = -EINVAL;
uint64_t retval = 0;
goto end;
OP(FILTER_OP_RETURN):
- /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
+ /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
/* Handle dynamic typing. */
switch (estack_ax_t) {
case REG_S64:
goto end;
OP(FILTER_OP_RETURN_S64):
- /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
+ /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
retval = !!estack_ax_v;
ret = 0;
goto end;
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type dynamic\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type string\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type s64\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type double\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
struct get_index_u16 *index = (struct get_index_u16 *) insn->data;
dbg_printf("op get index u16\n");
- ret = dynamic_get_index(session, bytecode, index->index, estack_ax(stack, top));
+ ret = dynamic_get_index(ctx, bytecode, index->index, estack_ax(stack, top));
if (ret)
goto end;
estack_ax_v = estack_ax(stack, top)->u.v;
struct get_index_u64 *index = (struct get_index_u64 *) insn->data;
dbg_printf("op get index u64\n");
- ret = dynamic_get_index(session, bytecode, index->index, estack_ax(stack, top));
+ ret = dynamic_get_index(ctx, bytecode, index->index, estack_ax(stack, top));
if (ret)
goto end;
estack_ax_v = estack_ax(stack, top)->u.v;
END_OP
end:
- /* return 0 (discard) on error */
+ /* Return _DISCARD on error. */
if (ret)
- return 0;
+ return LTTNG_FILTER_DISCARD;
return retval;
}