From: Jonathan Rajotte Date: Tue, 20 Apr 2021 01:22:09 +0000 (-0400) Subject: Rename on-event to event-rule-matches X-Git-Tag: v2.13.0-rc1~34 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8dbb86b8a981917165030d3a7fbbc2cb932888ed;p=lttng-tools.git Rename on-event to event-rule-matches Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: Icb596abdd0c291643f144ce274919b4094828e95 --- diff --git a/include/lttng/condition/condition.h b/include/lttng/condition/condition.h index 5610a7604..7aff1469b 100644 --- a/include/lttng/condition/condition.h +++ b/include/lttng/condition/condition.h @@ -21,7 +21,7 @@ enum lttng_condition_type { LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW = 102, LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING = 103, LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED = 104, - LTTNG_CONDITION_TYPE_ON_EVENT = 105, + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES = 105, }; enum lttng_condition_status { diff --git a/include/lttng/condition/event-rule-matches-internal.h b/include/lttng/condition/event-rule-matches-internal.h index 29a2b27b5..c98ab8c7f 100644 --- a/include/lttng/condition/event-rule-matches-internal.h +++ b/include/lttng/condition/event-rule-matches-internal.h @@ -5,8 +5,8 @@ * */ -#ifndef LTTNG_CONDITION_ON_EVENT_INTERNAL_H -#define LTTNG_CONDITION_ON_EVENT_INTERNAL_H +#ifndef LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H +#define LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H #include #include @@ -21,7 +21,7 @@ struct lttng_capture_descriptor { struct lttng_bytecode *bytecode; }; -struct lttng_condition_on_event { +struct lttng_condition_event_rule_matches { struct lttng_condition parent; struct lttng_event_rule *rule; @@ -35,7 +35,7 @@ struct lttng_condition_on_event { struct lttng_dynamic_pointer_array capture_descriptors; }; -struct lttng_evaluation_on_event { +struct lttng_evaluation_event_rule_matches { struct lttng_evaluation parent; /* MessagePack-encoded captured event field values. */ @@ -52,44 +52,46 @@ struct lttng_evaluation_on_event { }; LTTNG_HIDDEN -ssize_t lttng_condition_on_event_create_from_payload( +ssize_t lttng_condition_event_rule_matches_create_from_payload( struct lttng_payload_view *view, struct lttng_condition **condition); LTTNG_HIDDEN enum lttng_condition_status -lttng_condition_on_event_borrow_rule_mutable( +lttng_condition_event_rule_matches_borrow_rule_mutable( const struct lttng_condition *condition, struct lttng_event_rule **rule); LTTNG_HIDDEN -void lttng_condition_on_event_set_error_counter_index( - struct lttng_condition *condition, uint64_t error_counter_index); +void lttng_condition_event_rule_matches_set_error_counter_index( + struct lttng_condition *condition, + uint64_t error_counter_index); LTTNG_HIDDEN -uint64_t lttng_condition_on_event_get_error_counter_index( +uint64_t lttng_condition_event_rule_matches_get_error_counter_index( const struct lttng_condition *condition); LTTNG_HIDDEN -struct lttng_evaluation *lttng_evaluation_on_event_create( - const struct lttng_condition_on_event *condition, - const char *capture_payload, size_t capture_payload_size, +struct lttng_evaluation *lttng_evaluation_event_rule_matches_create( + const struct lttng_condition_event_rule_matches *condition, + const char *capture_payload, + size_t capture_payload_size, bool decode_capture_payload); LTTNG_HIDDEN -ssize_t lttng_evaluation_on_event_create_from_payload( - const struct lttng_condition_on_event *condition, +ssize_t lttng_evaluation_event_rule_matches_create_from_payload( + const struct lttng_condition_event_rule_matches *condition, struct lttng_payload_view *view, struct lttng_evaluation **_evaluation); LTTNG_HIDDEN enum lttng_error_code -lttng_condition_on_event_generate_capture_descriptor_bytecode( +lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode( struct lttng_condition *condition); LTTNG_HIDDEN const struct lttng_bytecode * -lttng_condition_on_event_get_capture_bytecode_at_index( +lttng_condition_event_rule_matches_get_capture_bytecode_at_index( const struct lttng_condition *condition, unsigned int index); -#endif /* LTTNG_CONDITION_ON_EVENT_INTERNAL_H */ +#endif /* LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H */ diff --git a/include/lttng/condition/event-rule-matches.h b/include/lttng/condition/event-rule-matches.h index 18c4155a2..75d1c88af 100644 --- a/include/lttng/condition/event-rule-matches.h +++ b/include/lttng/condition/event-rule-matches.h @@ -5,8 +5,8 @@ * */ -#ifndef LTTNG_CONDITION_ON_EVENT_H -#define LTTNG_CONDITION_ON_EVENT_H +#ifndef LTTNG_CONDITION_EVENT_RULE_MATCHES_H +#define LTTNG_CONDITION_EVENT_RULE_MATCHES_H #include #include @@ -19,34 +19,34 @@ extern "C" { struct lttng_event_expr; struct lttng_event_field_value; -enum lttng_evaluation_on_event_status { - LTTNG_EVALUATION_ON_EVENT_STATUS_NONE = 1, - LTTNG_EVALUATION_ON_EVENT_STATUS_OK = 0, - LTTNG_EVALUATION_ON_EVENT_STATUS_INVALID = -1, +enum lttng_evaluation_event_rule_matches_status { + LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_NONE = 1, + LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK = 0, + LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_INVALID = -1, }; /** - * On event conditions allows an action to be taken whenever an event matching - * the on event is hit by the tracers. + * Event Rule Matches conditions allows an action to be taken whenever an event + * matching the Event Rule Matches is hit by the tracers. * - * An on event condition can also specify a payload to be captured at runtime. - * This is done via the capture descriptor. + * An Event Rule Matches condition can also specify a payload to be captured at + * runtime. This is done via the capture descriptor. * * Note: the dynamic runtime capture of payload is only available for the * trigger notification subsystem. */ /* - * Create a newly allocated on event condition. + * Create a newly allocated Event Rule Matches condition. * * Returns a new condition on success, NULL on failure. This condition must be * destroyed using lttng_condition_destroy(). */ -extern struct lttng_condition *lttng_condition_on_event_create( +extern struct lttng_condition *lttng_condition_event_rule_matches_create( struct lttng_event_rule *rule); /* - * Get the rule property of a on event condition. + * Get the rule property of an Event Rule Matches condition. * * The caller does not assume the ownership of the returned rule. The * rule shall only be used for the duration of the condition's @@ -55,48 +55,48 @@ extern struct lttng_condition *lttng_condition_on_event_create( * Returns LTTNG_CONDITION_STATUS_OK and a pointer to the condition's rule * on success, LTTNG_CONDITION_STATUS_INVALID if an invalid * parameter is passed. */ -extern enum lttng_condition_status lttng_condition_on_event_get_rule( +extern enum lttng_condition_status lttng_condition_event_rule_matches_get_rule( const struct lttng_condition *condition, const struct lttng_event_rule **rule); /** - * lttng_evaluation_on_event_hit are specialised lttng_evaluations which - * allow users to query a number of properties resulting from the evaluation - * of a condition which evaluated to true. + * lttng_evaluation_event_rule_matches_hit are specialised lttng_evaluations + * which allow users to query a number of properties resulting from the + * evaluation of a condition which evaluated to true. * - * The evaluation of an on event condition contains the captured event + * The evaluation of an Event Rule Matches condition contains the captured event * payload fields that were specified by the condition. */ /* - * Sets `*field_val` to the array event field value of the on event + * Sets `*field_val` to the array event field value of the Event Rule Matches * condition evaluation `evaluation` which contains its captured values. * * Returns: * - * `LTTNG_EVALUATION_ON_EVENT_STATUS_OK`: + * `LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK`: * Success. * * `*field_val` is an array event field value with a length of at * least one. * - * `LTTNG_EVALUATION_ON_EVENT_STATUS_INVALID`: + * `LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_INVALID`: * * `evaluation` is `NULL`. * * The type of the condition of `evaluation` is not - * `LTTNG_CONDITION_TYPE_ON_EVENT`. + * `LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES`. * * `field_val` is `NULL`. * - * `LTTNG_EVALUATION_ON_EVENT_STATUS_NONE`: + * `LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_NONE`: * * The condition of `evaluation` has no capture descriptors. */ -extern enum lttng_evaluation_on_event_status -lttng_evaluation_on_event_get_captured_values( +extern enum lttng_evaluation_event_rule_matches_status +lttng_evaluation_event_rule_matches_get_captured_values( const struct lttng_evaluation *evaluation, const struct lttng_event_field_value **field_val); /* * Appends (transfering the ownership) the capture descriptor `expr` to - * the on event condition `condition`. + * the Event Rule Matches condition `condition`. * * Returns: * @@ -109,7 +109,7 @@ lttng_evaluation_on_event_get_captured_values( * `LTTNG_CONDITION_STATUS_INVALID`: * * `condition` is `NULL`. * * The type of `condition` is not - * `LTTNG_CONDITION_TYPE_ON_EVENT`. + * `LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES`. * * `expr` is `NULL`. * * `expr` is not a locator expression, that is, its type is not * one of: @@ -123,12 +123,12 @@ lttng_evaluation_on_event_get_captured_values( * * The associated event-rule does not support runtime capture. */ extern enum lttng_condition_status -lttng_condition_on_event_append_capture_descriptor( +lttng_condition_event_rule_matches_append_capture_descriptor( struct lttng_condition *condition, struct lttng_event_expr *expr); /* - * Sets `*count` to the number of capture descriptors in the on event + * Sets `*count` to the number of capture descriptors in the Event Rule Matches * condition `condition`. * * Returns: @@ -139,30 +139,30 @@ lttng_condition_on_event_append_capture_descriptor( * `LTTNG_CONDITION_STATUS_INVALID`: * * `condition` is `NULL`. * * The type of `condition` is not - * `LTTNG_CONDITION_TYPE_ON_EVENT`. + * `LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES`. * * `count` is `NULL`. */ extern enum lttng_condition_status -lttng_condition_on_event_get_capture_descriptor_count( +lttng_condition_event_rule_matches_get_capture_descriptor_count( const struct lttng_condition *condition, unsigned int *count); /* - * Returns the capture descriptor (borrowed) of the on event condition + * Returns the capture descriptor (borrowed) of the Event Rule Matches condition * `condition` at the index `index`, or `NULL` if: * * * `condition` is `NULL`. * * The type of `condition` is not - * `LTTNG_CONDITION_TYPE_ON_EVENT`. + * `LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES`. * * `index` is greater than or equal to the number of capture * descriptors in `condition` (as returned by - * lttng_condition_on_event_get_capture_descriptor_count()). + * lttng_condition_event_rule_matches_get_capture_descriptor_count()). */ extern const struct lttng_event_expr * -lttng_condition_on_event_get_capture_descriptor_at_index( +lttng_condition_event_rule_matches_get_capture_descriptor_at_index( const struct lttng_condition *condition, unsigned int index); #ifdef __cplusplus } #endif -#endif /* LTTNG_CONDITION_ON_EVENT_H */ +#endif /* LTTNG_CONDITION_EVENT_RULE_MATCHES_H */ diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c index 4a09c3ec6..d5184a442 100644 --- a/src/bin/lttng-sessiond/agent.c +++ b/src/bin/lttng-sessiond/agent.c @@ -1256,9 +1256,10 @@ struct agent_event *agent_find_event_by_trigger( condition = lttng_trigger_get_const_condition(trigger); assert(lttng_condition_get_type(condition) == - LTTNG_CONDITION_TYPE_ON_EVENT); + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); - c_status = lttng_condition_on_event_get_rule(condition, &rule); + c_status = lttng_condition_event_rule_matches_get_rule( + condition, &rule); assert(c_status == LTTNG_CONDITION_STATUS_OK); assert(lttng_event_rule_get_type(rule) == diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 14c9bbd10..45bf3b78f 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -4315,7 +4315,8 @@ enum lttng_error_code synchronize_tracer_notifier_register( assert(trigger_status == LTTNG_TRIGGER_STATUS_OK); assert(condition); - assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_ON_EVENT); + assert(lttng_condition_get_type(condition) == + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); trigger_status = lttng_trigger_get_name(trigger, &trigger_name); trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? @@ -4497,7 +4498,8 @@ enum lttng_error_code synchronize_tracer_notifier_unregister( trigger); assert(condition); - assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_ON_EVENT); + assert(lttng_condition_get_type(condition) == + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); session_lock_list(); switch (trigger_domain) { diff --git a/src/bin/lttng-sessiond/condition-internal.c b/src/bin/lttng-sessiond/condition-internal.c index 3e9d72c98..c86bf5401 100644 --- a/src/bin/lttng-sessiond/condition-internal.c +++ b/src/bin/lttng-sessiond/condition-internal.c @@ -95,17 +95,16 @@ unsigned long lttng_condition_session_rotation_hash( return hash; } -static -unsigned long lttng_condition_on_event_hash( - const struct lttng_condition *condition) +static unsigned long lttng_condition_event_rule_matches_hash( + const struct lttng_condition *condition) { unsigned long hash, condition_type; enum lttng_condition_status condition_status; const struct lttng_event_rule *event_rule; condition_type = (unsigned long) condition->type; - condition_status = lttng_condition_on_event_get_rule(condition, - &event_rule); + condition_status = lttng_condition_event_rule_matches_get_rule( + condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); hash = hash_key_ulong((void *) condition_type, lttng_ht_seed); @@ -128,8 +127,8 @@ unsigned long lttng_condition_hash(const struct lttng_condition *condition) case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING: case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED: return lttng_condition_session_rotation_hash(condition); - case LTTNG_CONDITION_TYPE_ON_EVENT: - return lttng_condition_on_event_hash(condition); + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: + return lttng_condition_event_rule_matches_hash(condition); default: //ERR("[notification-thread] Unexpected condition type caught"); abort(); diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index c8047c3ec..50d8fd028 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -601,9 +601,10 @@ int trigger_agent_enable(const struct lttng_trigger *trigger, struct agent *agt) condition = lttng_trigger_get_const_condition(trigger); assert(lttng_condition_get_type(condition) == - LTTNG_CONDITION_TYPE_ON_EVENT); + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); - c_status = lttng_condition_on_event_get_rule(condition, &rule); + c_status = lttng_condition_event_rule_matches_get_rule( + condition, &rule); assert(c_status == LTTNG_CONDITION_STATUS_OK); assert(lttng_event_rule_get_type(rule) == diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 988ba9d67..e99d8be44 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -2313,10 +2313,10 @@ static enum lttng_error_code kernel_create_event_notifier_rule( assert(condition); condition_type = lttng_condition_get_type(condition); - assert(condition_type == LTTNG_CONDITION_TYPE_ON_EVENT); + assert(condition_type == LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); /* Does not acquire a reference. */ - condition_status = lttng_condition_on_event_get_rule( + condition_status = lttng_condition_event_rule_matches_get_rule( condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); assert(event_rule); @@ -2325,7 +2325,8 @@ static enum lttng_error_code kernel_create_event_notifier_rule( assert(event_rule_type != LTTNG_EVENT_RULE_TYPE_UNKNOWN); error_code_ret = trace_kernel_create_event_notifier_rule(trigger, token, - lttng_condition_on_event_get_error_counter_index(condition), + lttng_condition_event_rule_matches_get_error_counter_index( + condition), &event_notifier_rule); if (error_code_ret != LTTNG_OK) { goto error; @@ -2339,7 +2340,8 @@ static enum lttng_error_code kernel_create_event_notifier_rule( kernel_event_notifier.event.token = event_notifier_rule->token; kernel_event_notifier.error_counter_idx = - lttng_condition_on_event_get_error_counter_index(condition); + lttng_condition_event_rule_matches_get_error_counter_index( + condition); fd = kernctl_create_event_notifier( kernel_tracer_event_notifier_group_fd, @@ -2402,13 +2404,13 @@ static enum lttng_error_code kernel_create_event_notifier_rule( } /* Set the capture bytecode if any. */ - cond_status = lttng_condition_on_event_get_capture_descriptor_count( + cond_status = lttng_condition_event_rule_matches_get_capture_descriptor_count( condition, &capture_bytecode_count); assert(cond_status == LTTNG_CONDITION_STATUS_OK); for (i = 0; i < capture_bytecode_count; i++) { const struct lttng_bytecode *capture_bytecode = - lttng_condition_on_event_get_capture_bytecode_at_index( + lttng_condition_event_rule_matches_get_capture_bytecode_at_index( condition, i); if (capture_bytecode == NULL) { @@ -2486,7 +2488,7 @@ enum lttng_error_code kernel_register_event_notifier( assert(condition); /* Does not acquire a reference to the event rule. */ - status = lttng_condition_on_event_get_rule( + status = lttng_condition_event_rule_matches_get_rule( condition, &event_rule); assert(status == LTTNG_CONDITION_STATUS_OK); diff --git a/src/bin/lttng-sessiond/notification-thread-events.c b/src/bin/lttng-sessiond/notification-thread-events.c index 72442314b..45e356796 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.c +++ b/src/bin/lttng-sessiond/notification-thread-events.c @@ -471,7 +471,7 @@ enum lttng_object_type get_condition_binding_object( case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING: case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED: return LTTNG_OBJECT_TYPE_SESSION; - case LTTNG_CONDITION_TYPE_ON_EVENT: + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: return LTTNG_OBJECT_TYPE_NONE; default: return LTTNG_OBJECT_TYPE_UNKNOWN; @@ -2336,12 +2336,12 @@ bool condition_is_supported(struct lttng_condition *condition) is_supported = kernel_supports_ring_buffer_snapshot_sample_positions() == 1; break; } - case LTTNG_CONDITION_TYPE_ON_EVENT: + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: { const struct lttng_event_rule *event_rule; enum lttng_domain_type domain; const enum lttng_condition_status status = - lttng_condition_on_event_get_rule( + lttng_condition_event_rule_matches_get_rule( condition, &event_rule); assert(status == LTTNG_CONDITION_STATUS_OK); @@ -2602,7 +2602,7 @@ enum lttng_error_code setup_tracer_notifier( goto error_remove_ht_element; } - lttng_condition_on_event_set_error_counter_index( + lttng_condition_event_rule_matches_set_error_counter_index( condition, error_counter_index); ret = LTTNG_OK; @@ -4569,7 +4569,7 @@ int dispatch_one_event_notifier_notification(struct notification_thread_state *s trigger_status = lttng_trigger_get_name(element->trigger, &trigger_name); assert(trigger_status == LTTNG_TRIGGER_STATUS_OK); - if (lttng_condition_on_event_get_capture_descriptor_count( + if (lttng_condition_event_rule_matches_get_capture_descriptor_count( lttng_trigger_get_const_condition(element->trigger), &capture_count) != LTTNG_CONDITION_STATUS_OK) { ERR("Failed to get capture count"); @@ -4583,10 +4583,10 @@ int dispatch_one_event_notifier_notification(struct notification_thread_state *s goto end; } - evaluation = lttng_evaluation_on_event_create( + evaluation = lttng_evaluation_event_rule_matches_create( container_of(lttng_trigger_get_const_condition( element->trigger), - struct lttng_condition_on_event, + struct lttng_condition_event_rule_matches, parent), notification->capture_buffer, notification->capture_buf_size, false); diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 382902a90..86cbb5e25 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -502,9 +502,9 @@ enum lttng_error_code trace_kernel_create_event_notifier_rule( assert(condition); condition_type = lttng_condition_get_type(condition); - assert(condition_type == LTTNG_CONDITION_TYPE_ON_EVENT); + assert(condition_type == LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); - condition_status = lttng_condition_on_event_get_rule( + condition_status = lttng_condition_event_rule_matches_get_rule( condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); assert(event_rule); diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index eb5c5a2ea..97cb66232 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1266,13 +1266,16 @@ static struct ust_app_event_notifier_rule *alloc_ust_app_event_notifier_rule( condition = lttng_trigger_get_condition(trigger); assert(condition); - assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_ON_EVENT); + assert(lttng_condition_get_type(condition) == + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); - assert(LTTNG_CONDITION_STATUS_OK == lttng_condition_on_event_get_rule(condition, &event_rule)); + assert(LTTNG_CONDITION_STATUS_OK == + lttng_condition_event_rule_matches_get_rule( + condition, &event_rule)); assert(event_rule); ua_event_notifier_rule->error_counter_index = - lttng_condition_on_event_get_error_counter_index(condition); + lttng_condition_event_rule_matches_get_error_counter_index(condition); /* Acquire the event notifier's reference to the trigger. */ lttng_trigger_get(trigger); @@ -2110,9 +2113,10 @@ static int create_ust_event_notifier(struct ust_app *app, condition = lttng_trigger_get_const_condition( ua_event_notifier_rule->trigger); assert(condition); - assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_ON_EVENT); + assert(lttng_condition_get_type(condition) == + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); - condition_status = lttng_condition_on_event_get_rule( + condition_status = lttng_condition_event_rule_matches_get_rule( condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); @@ -2176,13 +2180,13 @@ static int create_ust_event_notifier(struct ust_app *app, } /* Set the capture bytecodes. */ - cond_status = lttng_condition_on_event_get_capture_descriptor_count( + cond_status = lttng_condition_event_rule_matches_get_capture_descriptor_count( condition, &capture_bytecode_count); assert(cond_status == LTTNG_CONDITION_STATUS_OK); for (i = 0; i < capture_bytecode_count; i++) { const struct lttng_bytecode *capture_bytecode = - lttng_condition_on_event_get_capture_bytecode_at_index( + lttng_condition_event_rule_matches_get_capture_bytecode_at_index( condition, i); ret = set_ust_capture(app, capture_bytecode, i, @@ -5697,12 +5701,15 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app) token = lttng_trigger_get_tracer_token(trigger); condition = lttng_trigger_get_condition(trigger); - if (lttng_condition_get_type(condition) != LTTNG_CONDITION_TYPE_ON_EVENT) { + if (lttng_condition_get_type(condition) != + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES) { /* Does not apply */ continue; } - condition_status = lttng_condition_on_event_borrow_rule_mutable(condition, &event_rule); + condition_status = + lttng_condition_event_rule_matches_borrow_rule_mutable( + condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); if (lttng_event_rule_get_domain_type(event_rule) == LTTNG_DOMAIN_KERNEL) { diff --git a/src/bin/lttng/commands/add_trigger.c b/src/bin/lttng/commands/add_trigger.c index 9e70df107..91f849c13 100644 --- a/src/bin/lttng/commands/add_trigger.c +++ b/src/bin/lttng/commands/add_trigger.c @@ -1204,7 +1204,7 @@ struct lttng_condition *handle_condition_event(int *argc, const char ***argv) goto error; } - c = lttng_condition_on_event_create(res.er); + c = lttng_condition_event_rule_matches_create(res.er); lttng_event_rule_destroy(res.er); res.er = NULL; if (!c) { @@ -1220,7 +1220,7 @@ struct lttng_condition *handle_condition_event(int *argc, const char ***argv) assert(expr); assert(*expr); - status = lttng_condition_on_event_append_capture_descriptor( + status = lttng_condition_event_rule_matches_append_capture_descriptor( c, *expr); if (status != LTTNG_CONDITION_STATUS_OK) { if (status == LTTNG_CONDITION_STATUS_UNSUPPORTED) { diff --git a/src/bin/lttng/commands/list_triggers.c b/src/bin/lttng/commands/list_triggers.c index 44fcf2edc..73a740dc3 100644 --- a/src/bin/lttng/commands/list_triggers.c +++ b/src/bin/lttng/commands/list_triggers.c @@ -506,21 +506,21 @@ void print_one_event_expr(const struct lttng_event_expr *event_expr) } } -static -void print_condition_on_event(const struct lttng_condition *condition) +static void print_condition_event_rule_matches( + const struct lttng_condition *condition) { const struct lttng_event_rule *event_rule; enum lttng_condition_status condition_status; unsigned int cap_desc_count, i; - condition_status = - lttng_condition_on_event_get_rule(condition, &event_rule); + condition_status = lttng_condition_event_rule_matches_get_rule( + condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); print_event_rule(event_rule); condition_status = - lttng_condition_on_event_get_capture_descriptor_count( + lttng_condition_event_rule_matches_get_capture_descriptor_count( condition, &cap_desc_count); assert(condition_status == LTTNG_CONDITION_STATUS_OK); @@ -529,7 +529,7 @@ void print_condition_on_event(const struct lttng_condition *condition) for (i = 0; i < cap_desc_count; i++) { const struct lttng_event_expr *cap_desc = - lttng_condition_on_event_get_capture_descriptor_at_index( + lttng_condition_event_rule_matches_get_capture_descriptor_at_index( condition, i); _MSG(" - "); @@ -917,8 +917,8 @@ void print_one_trigger(const struct lttng_trigger *trigger) case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED: print_condition_session_rotation(condition); break; - case LTTNG_CONDITION_TYPE_ON_EVENT: - print_condition_on_event(condition); + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: + print_condition_event_rule_matches(condition); break; default: abort(); diff --git a/src/common/conditions/condition.c b/src/common/conditions/condition.c index 1abb2030b..97598f249 100644 --- a/src/common/conditions/condition.c +++ b/src/common/conditions/condition.c @@ -170,8 +170,9 @@ ssize_t lttng_condition_create_from_payload( case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED: create_from_payload = lttng_condition_session_rotation_completed_create_from_payload; break; - case LTTNG_CONDITION_TYPE_ON_EVENT: - create_from_payload = lttng_condition_on_event_create_from_payload; + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: + create_from_payload = + lttng_condition_event_rule_matches_create_from_payload; break; default: ERR("Attempted to create condition of unknown type (%i)", @@ -230,7 +231,7 @@ const char *lttng_condition_type_str(enum lttng_condition_type type) case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED: return "session rotation completed"; - case LTTNG_CONDITION_TYPE_ON_EVENT: + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: return "event rule hit"; default: diff --git a/src/common/conditions/event-rule-matches.c b/src/common/conditions/event-rule-matches.c index 794c7ccc9..bbde91aeb 100644 --- a/src/common/conditions/event-rule-matches.c +++ b/src/common/conditions/event-rule-matches.c @@ -23,40 +23,41 @@ #include #include -#define IS_ON_EVENT_CONDITION(condition) \ - (lttng_condition_get_type(condition) == \ - LTTNG_CONDITION_TYPE_ON_EVENT) +#define IS_EVENT_RULE_MATCHES_CONDITION(condition) \ + (lttng_condition_get_type(condition) == \ + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES) -static bool is_on_event_evaluation(const struct lttng_evaluation *evaluation) +static bool is_event_rule_matches_evaluation( + const struct lttng_evaluation *evaluation) { enum lttng_condition_type type = lttng_evaluation_get_type(evaluation); - return type == LTTNG_CONDITION_TYPE_ON_EVENT; + return type == LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES; } -static bool lttng_condition_on_event_validate( +static bool lttng_condition_event_rule_matches_validate( const struct lttng_condition *condition); -static int lttng_condition_on_event_serialize( +static int lttng_condition_event_rule_matches_serialize( const struct lttng_condition *condition, struct lttng_payload *payload); -static bool lttng_condition_on_event_is_equal( +static bool lttng_condition_event_rule_matches_is_equal( const struct lttng_condition *_a, const struct lttng_condition *_b); -static void lttng_condition_on_event_destroy( +static void lttng_condition_event_rule_matches_destroy( struct lttng_condition *condition); -static bool lttng_condition_on_event_validate( +static bool lttng_condition_event_rule_matches_validate( const struct lttng_condition *condition) { bool valid = false; - struct lttng_condition_on_event *event_rule; + struct lttng_condition_event_rule_matches *event_rule; if (!condition) { goto end; } - event_rule = container_of( - condition, struct lttng_condition_on_event, parent); + event_rule = container_of(condition, + struct lttng_condition_event_rule_matches, parent); if (!event_rule->rule) { ERR("Invalid on event condition: a rule must be set"); goto end; @@ -242,24 +243,23 @@ end: return ret; } -static -struct lttng_capture_descriptor * -lttng_condition_on_event_get_internal_capture_descriptor_at_index( +static struct lttng_capture_descriptor * +lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index( const struct lttng_condition *condition, unsigned int index) { - const struct lttng_condition_on_event *on_event_cond = - container_of(condition, - const struct lttng_condition_on_event, - parent); + const struct lttng_condition_event_rule_matches + *event_rule_matches_cond = container_of(condition, + const struct lttng_condition_event_rule_matches, + parent); struct lttng_capture_descriptor *desc = NULL; unsigned int count; enum lttng_condition_status status; - if (!condition || !IS_ON_EVENT_CONDITION(condition)) { + if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition)) { goto end; } - status = lttng_condition_on_event_get_capture_descriptor_count( + status = lttng_condition_event_rule_matches_get_capture_descriptor_count( condition, &count); if (status != LTTNG_CONDITION_STATUS_OK) { goto end; @@ -270,37 +270,38 @@ lttng_condition_on_event_get_internal_capture_descriptor_at_index( } desc = lttng_dynamic_pointer_array_get_pointer( - &on_event_cond->capture_descriptors, index); + &event_rule_matches_cond->capture_descriptors, index); end: return desc; } -static int lttng_condition_on_event_serialize( +static int lttng_condition_event_rule_matches_serialize( const struct lttng_condition *condition, struct lttng_payload *payload) { int ret; - struct lttng_condition_on_event *on_event_condition; + struct lttng_condition_event_rule_matches *event_rule_matches_condition; enum lttng_condition_status status; /* Used for iteration and communication (size matters). */ uint32_t i, capture_descr_count; - if (!condition || !IS_ON_EVENT_CONDITION(condition)) { + if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition)) { ret = -1; goto end; } DBG("Serializing on event condition"); - on_event_condition = container_of( - condition, struct lttng_condition_on_event, parent); + event_rule_matches_condition = container_of(condition, + struct lttng_condition_event_rule_matches, parent); DBG("Serializing on event condition's event rule"); - ret = lttng_event_rule_serialize(on_event_condition->rule, payload); + ret = lttng_event_rule_serialize( + event_rule_matches_condition->rule, payload); if (ret) { goto end; } - status = lttng_condition_on_event_get_capture_descriptor_count( + status = lttng_condition_event_rule_matches_get_capture_descriptor_count( condition, &capture_descr_count); if (status != LTTNG_CONDITION_STATUS_OK) { ret = -1; @@ -317,7 +318,7 @@ static int lttng_condition_on_event_serialize( for (i = 0; i < capture_descr_count; i++) { const struct lttng_capture_descriptor *desc = - lttng_condition_on_event_get_internal_capture_descriptor_at_index( + lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index( condition, i); DBG("Serializing on event condition's capture descriptor %" PRIu32, @@ -343,13 +344,13 @@ bool capture_descriptors_are_equal( size_t i; enum lttng_condition_status status; - status = lttng_condition_on_event_get_capture_descriptor_count( + status = lttng_condition_event_rule_matches_get_capture_descriptor_count( condition_a, &capture_descr_count_a); if (status != LTTNG_CONDITION_STATUS_OK) { goto not_equal; } - status = lttng_condition_on_event_get_capture_descriptor_count( + status = lttng_condition_event_rule_matches_get_capture_descriptor_count( condition_b, &capture_descr_count_b); if (status != LTTNG_CONDITION_STATUS_OK) { goto not_equal; @@ -361,13 +362,11 @@ bool capture_descriptors_are_equal( for (i = 0; i < capture_descr_count_a; i++) { const struct lttng_event_expr *expr_a = - lttng_condition_on_event_get_capture_descriptor_at_index( - condition_a, - i); + lttng_condition_event_rule_matches_get_capture_descriptor_at_index( + condition_a, i); const struct lttng_event_expr *expr_b = - lttng_condition_on_event_get_capture_descriptor_at_index( - condition_b, - i); + lttng_condition_event_rule_matches_get_capture_descriptor_at_index( + condition_b, i); if (!lttng_event_expr_is_equal(expr_a, expr_b)) { goto not_equal; @@ -383,15 +382,15 @@ end: return is_equal; } -static bool lttng_condition_on_event_is_equal( +static bool lttng_condition_event_rule_matches_is_equal( const struct lttng_condition *_a, const struct lttng_condition *_b) { bool is_equal = false; - struct lttng_condition_on_event *a, *b; + struct lttng_condition_event_rule_matches *a, *b; - a = container_of(_a, struct lttng_condition_on_event, parent); - b = container_of(_b, struct lttng_condition_on_event, parent); + a = container_of(_a, struct lttng_condition_event_rule_matches, parent); + b = container_of(_b, struct lttng_condition_event_rule_matches, parent); /* Both event rules must be set or both must be unset. */ if ((a->rule && !b->rule) || (!a->rule && b->rule)) { @@ -410,17 +409,18 @@ end: return is_equal; } -static void lttng_condition_on_event_destroy( +static void lttng_condition_event_rule_matches_destroy( struct lttng_condition *condition) { - struct lttng_condition_on_event *on_event_condition; + struct lttng_condition_event_rule_matches *event_rule_matches_condition; - on_event_condition = container_of( - condition, struct lttng_condition_on_event, parent); + event_rule_matches_condition = container_of(condition, + struct lttng_condition_event_rule_matches, parent); - lttng_event_rule_put(on_event_condition->rule); - lttng_dynamic_pointer_array_reset(&on_event_condition->capture_descriptors); - free(on_event_condition); + lttng_event_rule_put(event_rule_matches_condition->rule); + lttng_dynamic_pointer_array_reset( + &event_rule_matches_condition->capture_descriptors); + free(event_rule_matches_condition); } static @@ -434,27 +434,29 @@ void destroy_capture_descriptor(void *ptr) free(desc); } -struct lttng_condition *lttng_condition_on_event_create( +struct lttng_condition *lttng_condition_event_rule_matches_create( struct lttng_event_rule *rule) { struct lttng_condition *parent = NULL; - struct lttng_condition_on_event *condition = NULL; + struct lttng_condition_event_rule_matches *condition = NULL; if (!rule) { goto end; } - condition = zmalloc(sizeof(struct lttng_condition_on_event)); + condition = zmalloc(sizeof(struct lttng_condition_event_rule_matches)); if (!condition) { return NULL; } lttng_condition_init(&condition->parent, - LTTNG_CONDITION_TYPE_ON_EVENT); - condition->parent.validate = lttng_condition_on_event_validate, - condition->parent.serialize = lttng_condition_on_event_serialize, - condition->parent.equal = lttng_condition_on_event_is_equal, - condition->parent.destroy = lttng_condition_on_event_destroy, + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); + condition->parent.validate = + lttng_condition_event_rule_matches_validate, + condition->parent.serialize = + lttng_condition_event_rule_matches_serialize, + condition->parent.equal = lttng_condition_event_rule_matches_is_equal, + condition->parent.destroy = lttng_condition_event_rule_matches_destroy, lttng_event_rule_get(rule); condition->rule = rule; @@ -626,7 +628,7 @@ end: } LTTNG_HIDDEN -ssize_t lttng_condition_on_event_create_from_payload( +ssize_t lttng_condition_event_rule_matches_create_from_payload( struct lttng_payload_view *view, struct lttng_condition **_condition) { @@ -657,7 +659,7 @@ ssize_t lttng_condition_on_event_create_from_payload( offset += event_rule_length; /* Create condition (no capture descriptors yet) at this point */ - condition = lttng_condition_on_event_create(event_rule); + condition = lttng_condition_event_rule_matches_create(event_rule); if (!condition) { goto error; } @@ -680,7 +682,7 @@ ssize_t lttng_condition_on_event_create_from_payload( } /* Move ownership of `expr` to `condition`. */ - status = lttng_condition_on_event_append_capture_descriptor( + status = lttng_condition_event_rule_matches_append_capture_descriptor( condition, expr); if (status != LTTNG_CONDITION_STATUS_OK) { /* `expr` not moved: destroy it. */ @@ -704,20 +706,22 @@ end: } LTTNG_HIDDEN -enum lttng_condition_status lttng_condition_on_event_borrow_rule_mutable( +enum lttng_condition_status +lttng_condition_event_rule_matches_borrow_rule_mutable( const struct lttng_condition *condition, struct lttng_event_rule **rule) { - struct lttng_condition_on_event *event_rule; + struct lttng_condition_event_rule_matches *event_rule; enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK; - if (!condition || !IS_ON_EVENT_CONDITION(condition) || !rule) { + if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) || + !rule) { status = LTTNG_CONDITION_STATUS_INVALID; goto end; } - event_rule = container_of( - condition, struct lttng_condition_on_event, parent); + event_rule = container_of(condition, + struct lttng_condition_event_rule_matches, parent); if (!event_rule->rule) { status = LTTNG_CONDITION_STATUS_UNSET; goto end; @@ -728,62 +732,66 @@ end: return status; } -enum lttng_condition_status lttng_condition_on_event_get_rule( +enum lttng_condition_status lttng_condition_event_rule_matches_get_rule( const struct lttng_condition *condition, const struct lttng_event_rule **rule) { struct lttng_event_rule *mutable_rule = NULL; const enum lttng_condition_status status = - lttng_condition_on_event_borrow_rule_mutable( - condition, &mutable_rule); + lttng_condition_event_rule_matches_borrow_rule_mutable( + condition, &mutable_rule); *rule = mutable_rule; return status; } LTTNG_HIDDEN -void lttng_condition_on_event_set_error_counter_index( +void lttng_condition_event_rule_matches_set_error_counter_index( struct lttng_condition *condition, uint64_t error_counter_index) { - struct lttng_condition_on_event *on_event_cond = + struct lttng_condition_event_rule_matches *event_rule_matches_cond = container_of(condition, - struct lttng_condition_on_event, parent); + struct lttng_condition_event_rule_matches, + parent); - LTTNG_OPTIONAL_SET(&on_event_cond->error_counter_index, error_counter_index); + LTTNG_OPTIONAL_SET(&event_rule_matches_cond->error_counter_index, + error_counter_index); } LTTNG_HIDDEN -uint64_t lttng_condition_on_event_get_error_counter_index( +uint64_t lttng_condition_event_rule_matches_get_error_counter_index( const struct lttng_condition *condition) { - const struct lttng_condition_on_event *on_event_cond = - container_of(condition, - const struct lttng_condition_on_event, parent); + const struct lttng_condition_event_rule_matches + *event_rule_matches_cond = container_of(condition, + const struct lttng_condition_event_rule_matches, + parent); - return LTTNG_OPTIONAL_GET(on_event_cond->error_counter_index); + return LTTNG_OPTIONAL_GET(event_rule_matches_cond->error_counter_index); } enum lttng_condition_status -lttng_condition_on_event_append_capture_descriptor( +lttng_condition_event_rule_matches_append_capture_descriptor( struct lttng_condition *condition, struct lttng_event_expr *expr) { int ret; enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK; - struct lttng_condition_on_event *on_event_cond = + struct lttng_condition_event_rule_matches *event_rule_matches_cond = container_of(condition, - struct lttng_condition_on_event, parent); + struct lttng_condition_event_rule_matches, + parent); struct lttng_capture_descriptor *descriptor = NULL; const struct lttng_event_rule *rule = NULL; /* Only accept l-values. */ - if (!condition || !IS_ON_EVENT_CONDITION(condition) || !expr || - !lttng_event_expr_is_lvalue(expr)) { + if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) || + !expr || !lttng_event_expr_is_lvalue(expr)) { status = LTTNG_CONDITION_STATUS_INVALID; goto end; } - status = lttng_condition_on_event_get_rule(condition, &rule); + status = lttng_condition_event_rule_matches_get_rule(condition, &rule); if (status != LTTNG_CONDITION_STATUS_OK) { goto end; } @@ -816,7 +824,8 @@ lttng_condition_on_event_append_capture_descriptor( descriptor->bytecode = NULL; ret = lttng_dynamic_pointer_array_add_pointer( - &on_event_cond->capture_descriptors, descriptor); + &event_rule_matches_cond->capture_descriptors, + descriptor); if (ret) { status = LTTNG_CONDITION_STATUS_ERROR; goto end; @@ -830,35 +839,36 @@ end: } enum lttng_condition_status -lttng_condition_on_event_get_capture_descriptor_count( +lttng_condition_event_rule_matches_get_capture_descriptor_count( const struct lttng_condition *condition, unsigned int *count) { enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK; - const struct lttng_condition_on_event *on_event_condition = - container_of(condition, - const struct lttng_condition_on_event, - parent); + const struct lttng_condition_event_rule_matches + *event_rule_matches_condition = container_of(condition, + const struct lttng_condition_event_rule_matches, + parent); - if (!condition || !IS_ON_EVENT_CONDITION(condition) || !count) { + if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) || + !count) { status = LTTNG_CONDITION_STATUS_INVALID; goto end; } *count = lttng_dynamic_pointer_array_get_count( - &on_event_condition->capture_descriptors); + &event_rule_matches_condition->capture_descriptors); end: return status; } const struct lttng_event_expr * -lttng_condition_on_event_get_capture_descriptor_at_index( +lttng_condition_event_rule_matches_get_capture_descriptor_at_index( const struct lttng_condition *condition, unsigned int index) { const struct lttng_event_expr *expr = NULL; const struct lttng_capture_descriptor *desc = NULL; - desc = lttng_condition_on_event_get_internal_capture_descriptor_at_index( + desc = lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index( condition, index); if (desc == NULL) { goto end; @@ -870,8 +880,8 @@ end: } LTTNG_HIDDEN -ssize_t lttng_evaluation_on_event_create_from_payload( - const struct lttng_condition_on_event *condition, +ssize_t lttng_evaluation_event_rule_matches_create_from_payload( + const struct lttng_condition_event_rule_matches *condition, struct lttng_payload_view *view, struct lttng_evaluation **_evaluation) { @@ -911,8 +921,8 @@ ssize_t lttng_evaluation_on_event_create_from_payload( capture_payload = current_view.buffer.data; } - evaluation = lttng_evaluation_on_event_create(condition, - capture_payload, capture_payload_size, true); + evaluation = lttng_evaluation_event_rule_matches_create( + condition, capture_payload, capture_payload_size, true); if (!evaluation) { ret = -1; goto error; @@ -928,16 +938,16 @@ error: return ret; } -static int lttng_evaluation_on_event_serialize( +static int lttng_evaluation_event_rule_matches_serialize( const struct lttng_evaluation *evaluation, struct lttng_payload *payload) { int ret = 0; - struct lttng_evaluation_on_event *hit; + struct lttng_evaluation_event_rule_matches *hit; uint32_t capture_payload_size; - hit = container_of( - evaluation, struct lttng_evaluation_on_event, parent); + hit = container_of(evaluation, + struct lttng_evaluation_event_rule_matches, parent); capture_payload_size = (uint32_t) hit->capture_payload.size; ret = lttng_dynamic_buffer_append(&payload->buffer, &capture_payload_size, @@ -1001,13 +1011,13 @@ end: return ret; } -static void lttng_evaluation_on_event_destroy( +static void lttng_evaluation_event_rule_matches_destroy( struct lttng_evaluation *evaluation) { - struct lttng_evaluation_on_event *hit; + struct lttng_evaluation_event_rule_matches *hit; - hit = container_of( - evaluation, struct lttng_evaluation_on_event, parent); + hit = container_of(evaluation, + struct lttng_evaluation_event_rule_matches, parent); lttng_dynamic_buffer_reset(&hit->capture_payload); lttng_event_field_value_destroy(hit->captured_values); free(hit); @@ -1189,10 +1199,10 @@ end: return ret; } -static -struct lttng_event_field_value *event_field_value_from_capture_payload( - const struct lttng_condition_on_event *condition, - const char *capture_payload, size_t capture_payload_size) +static struct lttng_event_field_value *event_field_value_from_capture_payload( + const struct lttng_condition_event_rule_matches *condition, + const char *capture_payload, + size_t capture_payload_size) { struct lttng_event_field_value *ret = NULL; msgpack_unpacked unpacked; @@ -1252,7 +1262,7 @@ struct lttng_event_field_value *event_field_value_from_capture_payload( for (i = 0; i < count; i++) { const struct lttng_capture_descriptor *capture_descriptor = - lttng_condition_on_event_get_internal_capture_descriptor_at_index( + lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index( &condition->parent, i); const msgpack_object *elem_obj; struct lttng_event_field_value *elem_field_val; @@ -1293,15 +1303,16 @@ end: } LTTNG_HIDDEN -struct lttng_evaluation *lttng_evaluation_on_event_create( - const struct lttng_condition_on_event *condition, - const char *capture_payload, size_t capture_payload_size, +struct lttng_evaluation *lttng_evaluation_event_rule_matches_create( + const struct lttng_condition_event_rule_matches *condition, + const char *capture_payload, + size_t capture_payload_size, bool decode_capture_payload) { - struct lttng_evaluation_on_event *hit; + struct lttng_evaluation_event_rule_matches *hit; struct lttng_evaluation *evaluation = NULL; - hit = zmalloc(sizeof(struct lttng_evaluation_on_event)); + hit = zmalloc(sizeof(struct lttng_evaluation_event_rule_matches)); if (!hit) { goto error; } @@ -1331,40 +1342,40 @@ struct lttng_evaluation *lttng_evaluation_on_event_create( } } - hit->parent.type = LTTNG_CONDITION_TYPE_ON_EVENT; - hit->parent.serialize = lttng_evaluation_on_event_serialize; - hit->parent.destroy = lttng_evaluation_on_event_destroy; + hit->parent.type = LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES; + hit->parent.serialize = lttng_evaluation_event_rule_matches_serialize; + hit->parent.destroy = lttng_evaluation_event_rule_matches_destroy; evaluation = &hit->parent; hit = NULL; error: if (hit) { - lttng_evaluation_on_event_destroy(&hit->parent); + lttng_evaluation_event_rule_matches_destroy(&hit->parent); } return evaluation; } -enum lttng_evaluation_on_event_status -lttng_evaluation_on_event_get_captured_values( +enum lttng_evaluation_event_rule_matches_status +lttng_evaluation_event_rule_matches_get_captured_values( const struct lttng_evaluation *evaluation, const struct lttng_event_field_value **field_val) { - struct lttng_evaluation_on_event *hit; - enum lttng_evaluation_on_event_status status = - LTTNG_EVALUATION_ON_EVENT_STATUS_OK; + struct lttng_evaluation_event_rule_matches *hit; + enum lttng_evaluation_event_rule_matches_status status = + LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK; - if (!evaluation || !is_on_event_evaluation(evaluation) || + if (!evaluation || !is_event_rule_matches_evaluation(evaluation) || !field_val) { - status = LTTNG_EVALUATION_ON_EVENT_STATUS_INVALID; + status = LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_INVALID; goto end; } - hit = container_of(evaluation, struct lttng_evaluation_on_event, - parent); + hit = container_of(evaluation, + struct lttng_evaluation_event_rule_matches, parent); if (!hit->captured_values) { - status = LTTNG_EVALUATION_ON_EVENT_STATUS_NONE; + status = LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_NONE; goto end; } @@ -1376,19 +1387,19 @@ end: LTTNG_HIDDEN enum lttng_error_code -lttng_condition_on_event_generate_capture_descriptor_bytecode( +lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode( struct lttng_condition *condition) { enum lttng_error_code ret; enum lttng_condition_status status; unsigned int capture_count, i; - if (!condition || !IS_ON_EVENT_CONDITION(condition)) { + if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition)) { ret = LTTNG_ERR_FATAL; goto end; } - status = lttng_condition_on_event_get_capture_descriptor_count( + status = lttng_condition_event_rule_matches_get_capture_descriptor_count( condition, &capture_count); if (status != LTTNG_CONDITION_STATUS_OK) { ret = LTTNG_ERR_FATAL; @@ -1397,7 +1408,7 @@ lttng_condition_on_event_generate_capture_descriptor_bytecode( for (i = 0; i < capture_count; i++) { struct lttng_capture_descriptor *local_capture_desc = - lttng_condition_on_event_get_internal_capture_descriptor_at_index( + lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index( condition, i); if (local_capture_desc == NULL) { @@ -1424,23 +1435,23 @@ end: LTTNG_HIDDEN const struct lttng_bytecode * -lttng_condition_on_event_get_capture_bytecode_at_index( +lttng_condition_event_rule_matches_get_capture_bytecode_at_index( const struct lttng_condition *condition, unsigned int index) { - const struct lttng_condition_on_event *on_event_cond = - container_of(condition, - const struct lttng_condition_on_event, - parent); + const struct lttng_condition_event_rule_matches + *event_rule_matches_cond = container_of(condition, + const struct lttng_condition_event_rule_matches, + parent); struct lttng_capture_descriptor *desc = NULL; struct lttng_bytecode *bytecode = NULL; unsigned int count; enum lttng_condition_status status; - if (!condition || !IS_ON_EVENT_CONDITION(condition)) { + if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition)) { goto end; } - status = lttng_condition_on_event_get_capture_descriptor_count( + status = lttng_condition_event_rule_matches_get_capture_descriptor_count( condition, &count); if (status != LTTNG_CONDITION_STATUS_OK) { goto end; @@ -1451,7 +1462,7 @@ lttng_condition_on_event_get_capture_bytecode_at_index( } desc = lttng_dynamic_pointer_array_get_pointer( - &on_event_cond->capture_descriptors, index); + &event_rule_matches_cond->capture_descriptors, index); if (desc == NULL) { goto end; } diff --git a/src/common/evaluation.c b/src/common/evaluation.c index eee39ead8..15e4f11ee 100644 --- a/src/common/evaluation.c +++ b/src/common/evaluation.c @@ -117,12 +117,13 @@ ssize_t lttng_evaluation_create_from_payload( } evaluation_size += ret; break; - case LTTNG_CONDITION_TYPE_ON_EVENT: + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: assert(condition); - assert(condition->type == LTTNG_CONDITION_TYPE_ON_EVENT); - ret = lttng_evaluation_on_event_create_from_payload( + assert(condition->type == + LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); + ret = lttng_evaluation_event_rule_matches_create_from_payload( container_of(condition, - const struct lttng_condition_on_event, + const struct lttng_condition_event_rule_matches, parent), &evaluation_view, evaluation); if (ret < 0) { diff --git a/src/common/trigger.c b/src/common/trigger.c index 9dfd74d91..34d420807 100644 --- a/src/common/trigger.c +++ b/src/common/trigger.c @@ -772,9 +772,9 @@ enum lttng_domain_type lttng_trigger_get_underlying_domain_type_restriction( /* Apply to any domain. */ type = LTTNG_DOMAIN_NONE; break; - case LTTNG_CONDITION_TYPE_ON_EVENT: + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: /* Return the domain of the event rule. */ - c_status = lttng_condition_on_event_get_rule( + c_status = lttng_condition_event_rule_matches_get_rule( trigger->condition, &event_rule); assert(c_status == LTTNG_CONDITION_STATUS_OK); type = lttng_event_rule_get_domain_type(event_rule); @@ -812,12 +812,12 @@ enum lttng_error_code lttng_trigger_generate_bytecode( } switch (lttng_condition_get_type(condition)) { - case LTTNG_CONDITION_TYPE_ON_EVENT: + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: { struct lttng_event_rule *event_rule; const enum lttng_condition_status condition_status = - lttng_condition_on_event_borrow_rule_mutable( - condition, &event_rule); + lttng_condition_event_rule_matches_borrow_rule_mutable( + condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); @@ -829,7 +829,7 @@ enum lttng_error_code lttng_trigger_generate_bytecode( } /* Generate the capture bytecode. */ - ret = lttng_condition_on_event_generate_capture_descriptor_bytecode( + ret = lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode( condition); if (ret != LTTNG_OK) { goto end; @@ -885,7 +885,7 @@ bool lttng_trigger_needs_tracer_notifier(const struct lttng_trigger *trigger) lttng_trigger_get_const_condition(trigger); switch (lttng_condition_get_type(condition)) { - case LTTNG_CONDITION_TYPE_ON_EVENT: + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: needs_tracer_notifier = true; goto end; case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE: diff --git a/tests/regression/tools/notification/notification.c b/tests/regression/tools/notification/notification.c index 7e11bc280..ce6f56332 100644 --- a/tests/regression/tools/notification/notification.c +++ b/tests/regression/tools/notification/notification.c @@ -1495,7 +1495,7 @@ static void create_tracepoint_event_rule_trigger(const char *event_pattern, ok(success, "Setting tracepoint event rule exclusions"); } - tmp_condition = lttng_condition_on_event_create(event_rule); + tmp_condition = lttng_condition_event_rule_matches_create(event_rule); ok(tmp_condition, "Condition event rule object creation"); if (capture_desc_cb) { @@ -1863,7 +1863,7 @@ static void test_kprobe_event_rule_notification( ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK, "Setting kprobe event rule name: '%s'", trigger_name); - condition = lttng_condition_on_event_create(event_rule); + condition = lttng_condition_event_rule_matches_create(event_rule); ok(condition, "Condition event rule object creation"); /* Register the trigger for condition. */ @@ -1972,7 +1972,7 @@ static void test_uprobe_event_rule_notification( ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK, "Setting uprobe event rule name: '%s'", trigger_name); - condition = lttng_condition_on_event_create(event_rule); + condition = lttng_condition_event_rule_matches_create(event_rule); ok(condition, "Condition event rule object creation"); /* Register the trigger for condition. */ @@ -2064,7 +2064,7 @@ static void test_syscall_event_rule_notification( ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK, "Setting syscall event rule pattern: '%s'", syscall_name); - condition = lttng_condition_on_event_create(event_rule); + condition = lttng_condition_event_rule_matches_create(event_rule); ok(condition, "Condition syscall event rule object creation"); /* Register the trigger for condition. */ @@ -2159,7 +2159,7 @@ static void test_syscall_event_rule_notification_filter( ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK, "Setting filter: '%s'", filter_pattern); - condition = lttng_condition_on_event_create(event_rule); + condition = lttng_condition_event_rule_matches_create(event_rule); ok(condition, "Condition event rule object creation"); /* Register the triggers for condition */ @@ -2274,7 +2274,7 @@ static int generate_capture_descr(struct lttng_condition *condition) goto end; } - cond_status = lttng_condition_on_event_append_capture_descriptor( + cond_status = lttng_condition_event_rule_matches_append_capture_descriptor( condition, expr); if (cond_status != LTTNG_CONDITION_STATUS_OK) { fail("Failed to append capture descriptor"); @@ -2297,7 +2297,8 @@ static int validator_notification_trigger_capture( { int ret; unsigned int capture_count, i; - enum lttng_evaluation_on_event_status on_event_evaluation_status; + enum lttng_evaluation_event_rule_matches_status + event_rule_matches_evaluation_status; enum lttng_event_field_value_status event_field_value_status; const struct lttng_evaluation *evaluation; const struct lttng_event_field_value *captured_fields; @@ -2310,12 +2311,13 @@ static int validator_notification_trigger_capture( goto end; } - on_event_evaluation_status = - lttng_evaluation_on_event_get_captured_values( + event_rule_matches_evaluation_status = + lttng_evaluation_event_rule_matches_get_captured_values( evaluation, &captured_fields); - if (on_event_evaluation_status != LTTNG_EVALUATION_ON_EVENT_STATUS_OK) { + if (event_rule_matches_evaluation_status != + LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK) { diag("Failed to get event rule evaluation captured values: status = %d", - (int) on_event_evaluation_status); + (int) event_rule_matches_evaluation_status); ret = 1; goto end; } diff --git a/tests/regression/tools/trigger/test_list_triggers_cli b/tests/regression/tools/trigger/test_list_triggers_cli index 4b4b07c43..10e143e95 100755 --- a/tests/regression/tools/trigger/test_list_triggers_cli +++ b/tests/regression/tools/trigger/test_list_triggers_cli @@ -88,7 +88,7 @@ test_top_level_options () lttng_remove_trigger_ok "hello" } -test_on_event_tracepoint () +test_event_rule_matches_tracepoint () { diag "Listing on-event tracepoint" @@ -209,7 +209,7 @@ test_on_event_tracepoint () lttng_remove_trigger_ok "J" } -test_on_event_probe () +test_event_rule_matches_probe () { local channel_enable_addr local channel_disable_addr @@ -270,7 +270,7 @@ test_on_event_probe () lttng_remove_trigger_ok "T2" } -test_on_event_userspace_probe_elf () +test_event_rule_matches_userspace_probe_elf () { local elf_function_name="test_function" @@ -294,7 +294,7 @@ test_on_event_userspace_probe_elf () lttng_remove_trigger_ok "T0" } -test_on_event_userspace_probe_sdt () +test_event_rule_matches_userspace_probe_sdt () { local sdt_provider_name="foobar" local sdt_probe_name="tp1" @@ -319,7 +319,7 @@ test_on_event_userspace_probe_sdt () lttng_remove_trigger_ok "T0" } -test_on_event_syscall () +test_event_rule_matches_syscall () { diag "Listing on-event syscall" @@ -638,11 +638,11 @@ plan_tests $NUM_TESTS start_lttng_sessiond_notap test_top_level_options -test_on_event_tracepoint -skip $ist_root "non-root user: skipping kprobe tests" 9 || test_on_event_probe -skip $ist_root "non-root user: skipping uprobe tests" 5 || test_on_event_userspace_probe_elf -skip $(($ist_root && $hast_sdt_binary)) "skipping userspace probe SDT tests" 5 || test_on_event_userspace_probe_sdt -skip $ist_root "non-root user: skipping syscall tests" 13 || test_on_event_syscall +test_event_rule_matches_tracepoint +skip $ist_root "non-root user: skipping kprobe tests" 9 || test_event_rule_matches_probe +skip $ist_root "non-root user: skipping uprobe tests" 5 || test_event_rule_matches_userspace_probe_elf +skip $(($ist_root && $hast_sdt_binary)) "skipping userspace probe SDT tests" 5 || test_event_rule_matches_userspace_probe_sdt +skip $ist_root "non-root user: skipping syscall tests" 13 || test_event_rule_matches_syscall test_session_consumed_size_condition test_buffer_usage_conditions test_session_rotation_conditions diff --git a/tests/unit/test_condition.c b/tests/unit/test_condition.c index 1a346c292..e94bd084f 100644 --- a/tests/unit/test_condition.c +++ b/tests/unit/test_condition.c @@ -78,10 +78,10 @@ void test_condition_event_rule(void) "Setting exclusion pattern"); } - condition = lttng_condition_on_event_create(tracepoint); + condition = lttng_condition_event_rule_matches_create(tracepoint); ok(condition, "Created condition"); - condition_status = lttng_condition_on_event_get_rule( + condition_status = lttng_condition_event_rule_matches_get_rule( condition, &tracepoint_tmp); ok(condition_status == LTTNG_CONDITION_STATUS_OK, "Getting event rule from event rule condition");