+
+/*
+ * Stage 6.1 of tracepoint generation: generate event notifier probes
+ *
+ * Create the probe function. This function evaluates the filter bytecode and
+ * queue a notification to be sent to userspace.
+ */
+
+#include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
+
+#undef TP_PROTO
+#define TP_PROTO(...) __VA_ARGS__
+
+#undef TP_ARGS
+#define TP_ARGS(...) __VA_ARGS__
+
+#undef TP_FIELDS
+#define TP_FIELDS(...) __VA_ARGS__
+
+#undef TP_locvar
+#define TP_locvar(...) __VA_ARGS__
+
+#undef TP_code_pre
+#define TP_code_pre(...) __VA_ARGS__
+
+#undef TP_code_post
+#define TP_code_post(...) __VA_ARGS__
+
+/*
+ * Using twice size for filter stack data to hold size and pointer for
+ * each field (worse case). For integers, max size required is 64-bit.
+ * Same for double-precision floats. Those fit within
+ * 2*sizeof(unsigned long) for all supported architectures.
+ * Perform UNION (||) of filter runtime list.
+ */
+#undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
+static void __event_notifier_probe__##_name(void *__data, _proto) \
+{ \
+ struct probe_local_vars { _locvar }; \
+ struct lttng_event_notifier *__event_notifier = __data; \
+ struct lttng_probe_ctx __lttng_probe_ctx = { \
+ .event = NULL, \
+ .event_notifier = __event_notifier, \
+ .interruptible = !irqs_disabled(), \
+ }; \
+ union { \
+ size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
+ char __interpreter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
+ } __stackvar; \
+ struct probe_local_vars __tp_locvar; \
+ struct probe_local_vars *tp_locvar __attribute__((unused)) = \
+ &__tp_locvar; \
+ struct lttng_kernel_notifier_ctx __notif_ctx; \
+ bool __interpreter_stack_prepared = false; \
+ \
+ if (unlikely(!READ_ONCE(__event_notifier->enabled))) \
+ return; \
+ _code_pre \
+ if (unlikely(!list_empty(&__event_notifier->filter_bytecode_runtime_head))) { \
+ struct lttng_bytecode_runtime *bc_runtime; \
+ int __filter_record = __event_notifier->has_enablers_without_bytecode; \
+ \
+ __event_prepare_interpreter_stack__##_name(__stackvar.__interpreter_stack_data, \
+ tp_locvar, _args); \
+ __interpreter_stack_prepared = true; \
+ lttng_list_for_each_entry_rcu(bc_runtime, &__event_notifier->filter_bytecode_runtime_head, node) { \
+ if (unlikely(bc_runtime->interpreter_funcs.filter(bc_runtime, &__lttng_probe_ctx, \
+ __stackvar.__interpreter_stack_data) & LTTNG_INTERPRETER_RECORD_FLAG)) \
+ __filter_record = 1; \
+ } \
+ if (likely(!__filter_record)) \
+ goto __post; \
+ } \
+ \
+ __notif_ctx.eval_capture = LTTNG_READ_ONCE(__event_notifier->eval_capture); \
+ if (unlikely(!__interpreter_stack_prepared && __notif_ctx.eval_capture)) \
+ __event_prepare_interpreter_stack__##_name( \
+ __stackvar.__interpreter_stack_data, \
+ tp_locvar, _args); \
+ \
+ __event_notifier->send_notification(__event_notifier, \
+ &__lttng_probe_ctx, \
+ __stackvar.__interpreter_stack_data, \
+ &__notif_ctx); \
+ \
+__post: \
+ _code_post \
+ return; \
+}
+
+#undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
+static void __event_notifier_probe__##_name(void *__data) \
+{ \
+ struct probe_local_vars { _locvar }; \
+ struct lttng_event_notifier *__event_notifier = __data; \
+ struct lttng_probe_ctx __lttng_probe_ctx = { \
+ .event = NULL, \
+ .event_notifier = __event_notifier, \
+ .interruptible = !irqs_disabled(), \
+ }; \
+ union { \
+ size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
+ char __interpreter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
+ } __stackvar; \
+ struct probe_local_vars __tp_locvar; \
+ struct probe_local_vars *tp_locvar __attribute__((unused)) = \
+ &__tp_locvar; \
+ struct lttng_kernel_notifier_ctx __notif_ctx; \
+ bool __interpreter_stack_prepared = false; \
+ \
+ if (unlikely(!READ_ONCE(__event_notifier->enabled))) \
+ return; \
+ _code_pre \
+ if (unlikely(!list_empty(&__event_notifier->filter_bytecode_runtime_head))) { \
+ struct lttng_bytecode_runtime *bc_runtime; \
+ int __filter_record = __event_notifier->has_enablers_without_bytecode; \
+ \
+ __event_prepare_interpreter_stack__##_name(__stackvar.__interpreter_stack_data, \
+ tp_locvar); \
+ __interpreter_stack_prepared = true; \
+ lttng_list_for_each_entry_rcu(bc_runtime, &__event_notifier->filter_bytecode_runtime_head, node) { \
+ if (unlikely(bc_runtime->interpreter_funcs.filter(bc_runtime, &__lttng_probe_ctx, \
+ __stackvar.__interpreter_stack_data) & LTTNG_INTERPRETER_RECORD_FLAG)) \
+ __filter_record = 1; \
+ } \
+ if (likely(!__filter_record)) \
+ goto __post; \
+ } \
+ \
+ __notif_ctx.eval_capture = LTTNG_READ_ONCE(__event_notifier->eval_capture); \
+ if (unlikely(!__interpreter_stack_prepared && __notif_ctx.eval_capture)) \
+ __event_prepare_interpreter_stack__##_name( \
+ __stackvar.__interpreter_stack_data, \
+ tp_locvar); \
+ \
+ __event_notifier->send_notification(__event_notifier, \
+ &__lttng_probe_ctx, \
+ __stackvar.__interpreter_stack_data, \
+ &__notif_ctx); \
+__post: \
+ _code_post \
+ return; \
+}
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)