X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Flttng-filter-specialize.c;h=86f7c536a7bf29a75a4ccb746cac87436d1b2b60;hb=03cb0cdd5c45e758520e1ba9d9300d448314d527;hp=ccc458351e65e145d810797a2da4c0f3e18b29a3;hpb=cfa6cc1d0f01c2cfcc1a679abf3a6572d411c309;p=lttng-modules.git diff --git a/src/lttng-filter-specialize.c b/src/lttng-filter-specialize.c index ccc45835..86f7c536 100644 --- a/src/lttng-filter-specialize.c +++ b/src/lttng-filter-specialize.c @@ -119,7 +119,7 @@ static int specialize_load_field(struct vstack_entry *stack_top, insn->op = FILTER_OP_LOAD_FIELD_U64; break; case OBJECT_TYPE_DOUBLE: - printk(KERN_WARNING "Double type unsupported\n\n"); + printk(KERN_WARNING "LTTng: filter: Double type unsupported\n\n"); ret = -EINVAL; goto end; case OBJECT_TYPE_STRING: @@ -139,7 +139,7 @@ static int specialize_load_field(struct vstack_entry *stack_top, case OBJECT_TYPE_ARRAY: case OBJECT_TYPE_STRUCT: case OBJECT_TYPE_VARIANT: - printk(KERN_WARNING "Sequences, arrays, struct and variant cannot be loaded (nested types).\n"); + printk(KERN_WARNING "LTTng: filter: Sequences, arrays, struct and variant cannot be loaded (nested types).\n"); ret = -EINVAL; goto end; } @@ -260,7 +260,7 @@ static int specialize_get_index(struct bytecode_runtime *runtime, /* Only generated by the specialize phase. */ case OBJECT_TYPE_VARIANT: /* Fall-through */ default: - printk(KERN_WARNING "Unexpected get index type %d", + printk(KERN_WARNING "LTTng: filter: Unexpected get index type %d", (int) stack_top->load.object_type); ret = -EINVAL; goto end; @@ -269,7 +269,7 @@ static int specialize_get_index(struct bytecode_runtime *runtime, case LOAD_ROOT_CONTEXT: case LOAD_ROOT_APP_CONTEXT: case LOAD_ROOT_PAYLOAD: - printk(KERN_WARNING "Index lookup for root field not implemented yet.\n"); + printk(KERN_WARNING "LTTng: filter: Index lookup for root field not implemented yet.\n"); ret = -EINVAL; goto end; } @@ -297,7 +297,8 @@ end: return ret; } -static int specialize_context_lookup_name(struct bytecode_runtime *bytecode, +static int specialize_context_lookup_name(struct lttng_ctx *ctx, + struct bytecode_runtime *bytecode, struct load_op *insn) { uint16_t offset; @@ -305,16 +306,14 @@ static int specialize_context_lookup_name(struct bytecode_runtime *bytecode, offset = ((struct get_symbol *) insn->data)->offset; name = bytecode->p.bc->bc.data + bytecode->p.bc->bc.reloc_offset + offset; - return lttng_get_context_index(lttng_static_ctx, name); + return lttng_get_context_index(ctx, name); } static int specialize_load_object(const struct lttng_event_field *field, struct vstack_load *load, bool is_context) { load->type = LOAD_OBJECT; - /* - * LTTng-UST layout all integer fields as s64 on the stack for the filter. - */ + switch (field->type.atype) { case atype_integer: if (field->type.u.integer.signedness) @@ -337,7 +336,7 @@ static int specialize_load_object(const struct lttng_event_field *field, } case atype_array_nestable: if (!lttng_is_bytewise_integer(field->type.u.array_nestable.elem_type)) { - printk(KERN_WARNING "Array nesting only supports integer types.\n"); + printk(KERN_WARNING "LTTng: filter Array nesting only supports integer types.\n"); return -EINVAL; } if (is_context) { @@ -353,7 +352,7 @@ static int specialize_load_object(const struct lttng_event_field *field, break; case atype_sequence_nestable: if (!lttng_is_bytewise_integer(field->type.u.sequence_nestable.elem_type)) { - printk(KERN_WARNING "Sequence nesting only supports integer types.\n"); + printk(KERN_WARNING "LTTng: filter Sequence nesting only supports integer types.\n"); return -EINVAL; } if (is_context) { @@ -371,19 +370,20 @@ static int specialize_load_object(const struct lttng_event_field *field, load->object_type = OBJECT_TYPE_STRING; break; case atype_struct_nestable: - printk(KERN_WARNING "Structure type cannot be loaded.\n"); + printk(KERN_WARNING "LTTng: filter: Structure type cannot be loaded.\n"); return -EINVAL; case atype_variant_nestable: - printk(KERN_WARNING "Variant type cannot be loaded.\n"); + printk(KERN_WARNING "LTTng: filter: Variant type cannot be loaded.\n"); return -EINVAL; default: - printk(KERN_WARNING "Unknown type: %d", (int) field->type.atype); + printk(KERN_WARNING "LTTng: filter: Unknown type: %d", (int) field->type.atype); return -EINVAL; } return 0; } -static int specialize_context_lookup(struct bytecode_runtime *runtime, +static int specialize_context_lookup(struct lttng_ctx *ctx, + struct bytecode_runtime *runtime, struct load_op *insn, struct vstack_load *load) { @@ -393,7 +393,7 @@ static int specialize_context_lookup(struct bytecode_runtime *runtime, struct filter_get_index_data gid; ssize_t data_offset; - idx = specialize_context_lookup_name(runtime, insn); + idx = specialize_context_lookup_name(ctx, runtime, insn); if (idx < 0) { return -ENOENT; } @@ -407,6 +407,7 @@ static int specialize_context_lookup(struct bytecode_runtime *runtime, memset(&gid, 0, sizeof(gid)); gid.ctx_index = idx; gid.elem.type = load->object_type; + gid.field = field; data_offset = bytecode_push_data(runtime, &gid, __alignof__(gid), sizeof(gid)); if (data_offset < 0) { @@ -416,14 +417,13 @@ static int specialize_context_lookup(struct bytecode_runtime *runtime, return 0; } -static int specialize_event_payload_lookup(struct lttng_event *event, +static int specialize_payload_lookup(const struct lttng_event_desc *event_desc, struct bytecode_runtime *runtime, struct load_op *insn, struct vstack_load *load) { const char *name; uint16_t offset; - const struct lttng_event_desc *desc = event->desc; unsigned int i, nr_fields; bool found = false; uint32_t field_offset = 0; @@ -432,11 +432,11 @@ static int specialize_event_payload_lookup(struct lttng_event *event, struct filter_get_index_data gid; ssize_t data_offset; - nr_fields = desc->nr_fields; + nr_fields = event_desc->nr_fields; offset = ((struct get_symbol *) insn->data)->offset; name = runtime->p.bc->bc.data + runtime->p.bc->bc.reloc_offset + offset; for (i = 0; i < nr_fields; i++) { - field = &desc->fields[i]; + field = &event_desc->fields[i]; if (field->nofilter) { continue; } @@ -477,6 +477,7 @@ static int specialize_event_payload_lookup(struct lttng_event *event, memset(&gid, 0, sizeof(gid)); gid.offset = field_offset; gid.elem.type = load->object_type; + gid.field = field; data_offset = bytecode_push_data(runtime, &gid, __alignof__(gid), sizeof(gid)); if (data_offset < 0) { @@ -489,13 +490,14 @@ end: return ret; } -int lttng_filter_specialize_bytecode(struct lttng_event *event, +int lttng_filter_specialize_bytecode(const struct lttng_event_desc *event_desc, struct bytecode_runtime *bytecode) { void *pc, *next_pc, *start_pc; int ret = -EINVAL; struct vstack _stack; struct vstack *stack = &_stack; + struct lttng_ctx *ctx = bytecode->p.ctx; vstack_init(stack); @@ -505,7 +507,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch (*(filter_opcode_t *) pc) { case FILTER_OP_UNKNOWN: default: - printk(KERN_WARNING "unknown bytecode op %u\n", + printk(KERN_WARNING "LTTng: filter: unknown bytecode op %u\n", (unsigned int) *(filter_opcode_t *) pc); ret = -EINVAL; goto end; @@ -521,7 +523,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, case FILTER_OP_MOD: case FILTER_OP_PLUS: case FILTER_OP_MINUS: - printk(KERN_WARNING "unsupported bytecode op %u\n", + printk(KERN_WARNING "LTTng: filter: unsupported bytecode op %u\n", (unsigned int) *(filter_opcode_t *) pc); ret = -EINVAL; goto end; @@ -532,7 +534,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch(vstack_ax(stack)->type) { default: - printk(KERN_WARNING "unknown register type\n"); + printk(KERN_WARNING "LTTng: filter: unknown register type\n"); ret = -EINVAL; goto end; @@ -574,7 +576,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch(vstack_ax(stack)->type) { default: - printk(KERN_WARNING "unknown register type\n"); + printk(KERN_WARNING "LTTng: filter: unknown register type\n"); ret = -EINVAL; goto end; @@ -616,12 +618,12 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch(vstack_ax(stack)->type) { default: - printk(KERN_WARNING "unknown register type\n"); + printk(KERN_WARNING "LTTng: filter: unknown register type\n"); ret = -EINVAL; goto end; case REG_STAR_GLOB_STRING: - printk(KERN_WARNING "invalid register type for > binary operator\n"); + printk(KERN_WARNING "LTTng: filter: invalid register type for '>' binary operator\n"); ret = -EINVAL; goto end; case REG_STRING: @@ -656,12 +658,12 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch(vstack_ax(stack)->type) { default: - printk(KERN_WARNING "unknown register type\n"); + printk(KERN_WARNING "LTTng: filter: unknown register type\n"); ret = -EINVAL; goto end; case REG_STAR_GLOB_STRING: - printk(KERN_WARNING "invalid register type for < binary operator\n"); + printk(KERN_WARNING "LTTng: filter: invalid register type for '<' binary operator\n"); ret = -EINVAL; goto end; case REG_STRING: @@ -696,12 +698,12 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch(vstack_ax(stack)->type) { default: - printk(KERN_WARNING "unknown register type\n"); + printk(KERN_WARNING "LTTng: filter: unknown register type\n"); ret = -EINVAL; goto end; case REG_STAR_GLOB_STRING: - printk(KERN_WARNING "invalid register type for >= binary operator\n"); + printk(KERN_WARNING "LTTng: filter: invalid register type for '>=' binary operator\n"); ret = -EINVAL; goto end; case REG_STRING: @@ -735,12 +737,12 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch(vstack_ax(stack)->type) { default: - printk(KERN_WARNING "unknown register type\n"); + printk(KERN_WARNING "LTTng: filter: unknown register type\n"); ret = -EINVAL; goto end; case REG_STAR_GLOB_STRING: - printk(KERN_WARNING "invalid register type for <= binary operator\n"); + printk(KERN_WARNING "LTTng: filter: invalid register type for '<=' binary operator\n"); ret = -EINVAL; goto end; case REG_STRING: @@ -819,7 +821,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch(vstack_ax(stack)->type) { default: - printk(KERN_WARNING "unknown register type\n"); + printk(KERN_WARNING "LTTng: filter: unknown register type\n"); ret = -EINVAL; goto end; @@ -841,7 +843,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch(vstack_ax(stack)->type) { default: - printk(KERN_WARNING "unknown register type\n"); + printk(KERN_WARNING "LTTng: filter: unknown register type\n"); ret = -EINVAL; goto end; @@ -863,7 +865,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch(vstack_ax(stack)->type) { default: - printk(KERN_WARNING "unknown register type\n"); + printk(KERN_WARNING "LTTng: filter: unknown register type\n"); ret = -EINVAL; goto end; @@ -915,14 +917,14 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, /* load field ref */ case FILTER_OP_LOAD_FIELD_REF: { - printk(KERN_WARNING "Unknown field ref type\n"); + printk(KERN_WARNING "LTTng: filter: Unknown field ref type\n"); ret = -EINVAL; goto end; } /* get context ref */ case FILTER_OP_GET_CONTEXT_REF: { - printk(KERN_WARNING "Unknown get context ref type\n"); + printk(KERN_WARNING "LTTng: filter: Unknown get context ref type\n"); ret = -EINVAL; goto end; } @@ -1021,13 +1023,13 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, switch (vstack_ax(stack)->type) { default: - printk(KERN_WARNING "unknown register type\n"); + printk(KERN_WARNING "LTTng: filter: unknown register type\n"); ret = -EINVAL; goto end; case REG_STRING: case REG_STAR_GLOB_STRING: - printk(KERN_WARNING "Cast op can only be applied to numeric or floating point registers\n"); + printk(KERN_WARNING "LTTng: filter: Cast op can only be applied to numeric or floating point registers\n"); ret = -EINVAL; goto end; case REG_S64: @@ -1145,12 +1147,12 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, dbg_printk("op get symbol\n"); switch (vstack_ax(stack)->load.type) { case LOAD_OBJECT: - printk(KERN_WARNING "Nested fields not implemented yet.\n"); + printk(KERN_WARNING "LTTng: filter: Nested fields not implemented yet.\n"); ret = -EINVAL; goto end; case LOAD_ROOT_CONTEXT: /* Lookup context field. */ - ret = specialize_context_lookup(bytecode, insn, + ret = specialize_context_lookup(ctx, bytecode, insn, &vstack_ax(stack)->load); if (ret) goto end; @@ -1160,7 +1162,7 @@ int lttng_filter_specialize_bytecode(struct lttng_event *event, goto end; case LOAD_ROOT_PAYLOAD: /* Lookup event payload field. */ - ret = specialize_event_payload_lookup(event, + ret = specialize_payload_lookup(event_desc, bytecode, insn, &vstack_ax(stack)->load); if (ret)