From: Francis Deslauriers Date: Mon, 27 Apr 2020 19:11:38 +0000 (-0400) Subject: Add `interpreter_funcs` to `lttng_bytecode_runtime` X-Git-Tag: v2.13.0-rc1~438 X-Git-Url: http://git.lttng.org/?p=lttng-ust.git;a=commitdiff_plain;h=c42416df21bb28b9b19ca509f7242f660c5469b2 Add `interpreter_funcs` to `lttng_bytecode_runtime` Background ========== The current filter interpreter function signature looks like this: uint64_t lttng_bytecode_filter_interpret(void *filter_data, const char *filter_stack_data); The upcoming capture interpreter function will need an output parameter to extract the top of stack register. It will look like this: uint64_t lttng_bytecode_capture_interpret(void *capture_data, const char *capture_stack_data, struct output_register *output); Problems ======== We can't reuse the same function pointer field in `struct lttng_bytecode_runtime` as the two interpreter functions will have different signatures. We can't change the signature of this existing filter function because it's used in the tracepoint probes. Solution ======== Add a union of callbacks to hold both interpreter functions. This also doesn't change the layout of the `struct lttng_bytecode_runtime` objects. Signed-off-by: Francis Deslauriers Signed-off-by: Mathieu Desnoyers Change-Id: I9fcd6def9ce7783087b9648ddbf5ec71fb7b997a --- diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index ae5ce5f6..41164ac3 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -443,8 +443,10 @@ enum lttng_bytecode_interpreter_ret { struct lttng_bytecode_runtime { /* Associated bytecode */ struct lttng_ust_bytecode_node *bc; - uint64_t (*filter)(void *interpreter_data, - const char *interpreter_stack_data); + union { + uint64_t (*filter)(void *interpreter_data, + const char *interpreter_stack_data); + } interpreter_funcs; int link_failed; struct cds_list_head node; /* list of bytecode runtime in event */ /* diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 00e931a8..1f8be1a9 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -878,7 +878,7 @@ void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) \ __event_prepare_filter_stack__##_provider##___##_name(__stackvar.__filter_stack_data, \ _TP_ARGS_DATA_VAR(_args)); \ tp_list_for_each_entry_rcu(__filter_bc_runtime, &__event->filter_bytecode_runtime_head, node) { \ - if (caa_unlikely(__filter_bc_runtime->filter(__filter_bc_runtime, \ + if (caa_unlikely(__filter_bc_runtime->interpreter_funcs.filter(__filter_bc_runtime, \ __stackvar.__filter_stack_data) & LTTNG_INTERPRETER_RECORD_FLAG)) { \ __filter_record = 1; \ break; \ @@ -960,7 +960,7 @@ void __event_notifier_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) __event_prepare_filter_stack__##_provider##___##_name(__stackvar.__filter_stack_data, \ _TP_ARGS_DATA_VAR(_args)); \ tp_list_for_each_entry_rcu(__filter_bc_runtime, &__event_notifier->filter_bytecode_runtime_head, node) { \ - if (caa_unlikely(__filter_bc_runtime->filter(__filter_bc_runtime, \ + if (caa_unlikely(__filter_bc_runtime->interpreter_funcs.filter(__filter_bc_runtime, \ __stackvar.__filter_stack_data) & LTTNG_INTERPRETER_RECORD_FLAG)) \ __filter_record = 1; \ } \ diff --git a/liblttng-ust/lttng-bytecode.c b/liblttng-ust/lttng-bytecode.c index 47efdeca..bbf8e7e7 100644 --- a/liblttng-ust/lttng-bytecode.c +++ b/liblttng-ust/lttng-bytecode.c @@ -478,14 +478,29 @@ int _lttng_filter_link_bytecode(const struct lttng_event_desc *event_desc, if (ret) { goto link_error; } - runtime->p.filter = lttng_bytecode_filter_interpret; + + switch (bytecode->type) { + case LTTNG_UST_BYTECODE_NODE_TYPE_FILTER: + runtime->p.interpreter_funcs.filter = lttng_bytecode_filter_interpret; + break; + default: + abort(); + } + runtime->p.link_failed = 0; cds_list_add_rcu(&runtime->p.node, insert_loc); dbg_printf("Linking successful.\n"); return 0; link_error: - runtime->p.filter = lttng_bytecode_filter_interpret_false; + switch (bytecode->type) { + case LTTNG_UST_BYTECODE_NODE_TYPE_FILTER: + runtime->p.interpreter_funcs.filter = lttng_bytecode_filter_interpret_false; + break; + default: + abort(); + } + runtime->p.link_failed = 1; cds_list_add_rcu(&runtime->p.node, insert_loc); alloc_error: @@ -498,9 +513,9 @@ void lttng_bytecode_filter_sync_state(struct lttng_bytecode_runtime *runtime) struct lttng_ust_bytecode_node *bc = runtime->bc; if (!bc->enabler->enabled || runtime->link_failed) - runtime->filter = lttng_bytecode_filter_interpret_false; + runtime->interpreter_funcs.filter = lttng_bytecode_filter_interpret_false; else - runtime->filter = lttng_bytecode_filter_interpret; + runtime->interpreter_funcs.filter = lttng_bytecode_filter_interpret; } /*