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;
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,
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)
{
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;
}
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;
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;
}
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);
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;
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)
}
static
-int apply_field_reloc(struct lttng_event *event,
+int apply_field_reloc(const struct lttng_event_desc *event_desc,
struct bytecode_runtime *runtime,
uint32_t runtime_len,
uint32_t reloc_offset,
const char *field_name,
enum filter_op filter_op)
{
- const struct lttng_event_desc *desc;
const struct lttng_event_field *fields, *field = NULL;
unsigned int nr_fields, i;
struct load_op *op;
dbg_printk("Apply field reloc: %u %s\n", reloc_offset, field_name);
/* Lookup event by name */
- desc = event->desc;
- if (!desc)
+ if (!event_desc)
return -EINVAL;
- fields = desc->fields;
+ fields = event_desc->fields;
if (!fields)
return -EINVAL;
- nr_fields = desc->nr_fields;
+ nr_fields = event_desc->nr_fields;
for (i = 0; i < nr_fields; i++) {
if (fields[i].nofilter)
continue;
}
static
-int apply_context_reloc(struct lttng_event *event,
- struct bytecode_runtime *runtime,
+int apply_context_reloc(struct bytecode_runtime *runtime,
uint32_t runtime_len,
uint32_t reloc_offset,
const char *context_name,
}
static
-int apply_reloc(struct lttng_event *event,
+int apply_reloc(const struct lttng_event_desc *event_desc,
struct bytecode_runtime *runtime,
uint32_t runtime_len,
uint32_t reloc_offset,
op = (struct load_op *) &runtime->code[reloc_offset];
switch (op->op) {
case FILTER_OP_LOAD_FIELD_REF:
- return apply_field_reloc(event, runtime, runtime_len,
+ return apply_field_reloc(event_desc, runtime, runtime_len,
reloc_offset, name, op->op);
case FILTER_OP_GET_CONTEXT_REF:
- return apply_context_reloc(event, runtime, runtime_len,
+ return apply_context_reloc(runtime, runtime_len,
reloc_offset, name, op->op);
case FILTER_OP_GET_SYMBOL:
case FILTER_OP_GET_SYMBOL_FIELD:
static
int bytecode_is_linked(struct lttng_filter_bytecode_node *filter_bytecode,
- struct lttng_event *event)
+ struct list_head *bytecode_runtime_head)
{
struct lttng_bytecode_runtime *bc_runtime;
- list_for_each_entry(bc_runtime,
- &event->bytecode_runtime_head, node) {
+ list_for_each_entry(bc_runtime, bytecode_runtime_head, node) {
if (bc_runtime->bc == filter_bytecode)
return 1;
}
* bytecode runtime.
*/
static
-int _lttng_filter_event_link_bytecode(struct lttng_event *event,
+int _lttng_filter_link_bytecode(const struct lttng_event_desc *event_desc,
+ struct lttng_ctx *ctx,
struct lttng_filter_bytecode_node *filter_bytecode,
struct list_head *insert_loc)
{
if (!filter_bytecode)
return 0;
/* Bytecode already linked */
- if (bytecode_is_linked(filter_bytecode, event))
+ if (bytecode_is_linked(filter_bytecode, insert_loc))
return 0;
dbg_printk("Linking...\n");
goto alloc_error;
}
runtime->p.bc = filter_bytecode;
- runtime->p.event = event;
+ runtime->p.ctx = ctx;
runtime->len = filter_bytecode->bc.reloc_offset;
/* copy original bytecode */
memcpy(runtime->code, filter_bytecode->bc.data, runtime->len);
const char *name =
(const char *) &filter_bytecode->bc.data[offset + sizeof(uint16_t)];
- ret = apply_reloc(event, runtime, runtime->len, reloc_offset, name);
+ ret = apply_reloc(event_desc, runtime, runtime->len, reloc_offset, name);
if (ret) {
goto link_error;
}
goto link_error;
}
/* Specialize bytecode */
- ret = lttng_filter_specialize_bytecode(event, runtime);
+ ret = lttng_filter_specialize_bytecode(event_desc, runtime);
if (ret) {
goto link_error;
}
/*
* Link bytecode for all enablers referenced by an event.
*/
-void lttng_event_enabler_link_bytecode(struct lttng_event *event,
- struct lttng_event_enabler *event_enabler)
+void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc,
+ struct lttng_ctx *ctx,
+ struct list_head *bytecode_runtime_head,
+ struct lttng_enabler *enabler)
{
struct lttng_filter_bytecode_node *bc;
struct lttng_bytecode_runtime *runtime;
- struct lttng_enabler *base_enabler = lttng_event_enabler_as_enabler(event_enabler);
/* Can only be called for events with desc attached */
- WARN_ON_ONCE(!event->desc);
+ WARN_ON_ONCE(!event_desc);
/* Link each bytecode. */
- list_for_each_entry(bc, &base_enabler->filter_bytecode_head, node) {
+ list_for_each_entry(bc, &enabler->filter_bytecode_head, node) {
int found = 0, ret;
struct list_head *insert_loc;
list_for_each_entry(runtime,
- &event->bytecode_runtime_head, node) {
+ bytecode_runtime_head, node) {
if (runtime->bc == bc) {
found = 1;
break;
* insert the new bytecode right after it.
*/
list_for_each_entry_reverse(runtime,
- &event->bytecode_runtime_head, node) {
+ bytecode_runtime_head, node) {
if (runtime->bc->bc.seqnum <= bc->bc.seqnum) {
/* insert here */
insert_loc = &runtime->node;
}
}
/* Add to head to list */
- insert_loc = &event->bytecode_runtime_head;
+ insert_loc = bytecode_runtime_head;
add_within:
dbg_printk("linking bytecode\n");
- ret = _lttng_filter_event_link_bytecode(event, bc,
- insert_loc);
+ ret = _lttng_filter_link_bytecode(event_desc, ctx, bc,
+ insert_loc);
if (ret) {
dbg_printk("[lttng filter] warning: cannot link event bytecode\n");
}