From: Jérémie Galarneau Date: Wed, 17 Mar 2021 05:10:27 +0000 (-0400) Subject: on-event evaluation: introduce on-event evaluation specific status code X-Git-Tag: v2.13.0-rc1~207 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3ce811ee6c6c61a2c2c0909cf27e0dd8eea403fc;p=lttng-tools.git on-event evaluation: introduce on-event evaluation specific status code Before this change, `lttng_evaluation_on_event_get_captured_values` returns `LTTNG_EVALUATION_STATUS_INVALID` when an evaluation's condition has no capture descriptors. That status code is also used to indicate a handful of "invalid parameter" conditions. Not having captured values in an evaluation should not be considered an error. Hence, a status enum that is specific to on-event evaluations is added to introduce a "NONE" status that is not an error (positive value) and wouldn't make sense for all evaluations (it could mean an error in other circumstances). `LTTNG_EVALUATION_ON_EVENT_STATUS_NONE` is returned when the condition of an on-event evaluation has no capture descriptors. Signed-off-by: Jérémie Galarneau Change-Id: Ic2e3e90317a44c7bb3e95630956565690bffd760 --- diff --git a/include/lttng/condition/on-event.h b/include/lttng/condition/on-event.h index 450507613..5114ec1fc 100644 --- a/include/lttng/condition/on-event.h +++ b/include/lttng/condition/on-event.h @@ -19,6 +19,12 @@ 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, +}; + /** * On event conditions allows an action to be taken whenever an event matching * the on event is hit by the tracers. @@ -81,20 +87,22 @@ lttng_evaluation_on_event_get_trigger_name( * * Returns: * - * `LTTNG_EVALUATION_STATUS_OK`: + * `LTTNG_EVALUATION_ON_EVENT_STATUS_OK`: * Success. * * `*field_val` is an array event field value with a length of at * least one. * - * `LTTNG_EVALUATION_STATUS_INVALID`: + * `LTTNG_EVALUATION_ON_EVENT_STATUS_INVALID`: * * `evaluation` is `NULL`. * * The type of the condition of `evaluation` is not * `LTTNG_CONDITION_TYPE_ON_EVENT`. - * * The condition of `evaluation` has no capture descriptors. * * `field_val` is `NULL`. + * + * `LTTNG_EVALUATION_ON_EVENT_STATUS_NONE`: + * * The condition of `evaluation` has no capture descriptors. */ -extern enum lttng_evaluation_status +extern enum lttng_evaluation_on_event_status lttng_evaluation_on_event_get_captured_values( const struct lttng_evaluation *evaluation, const struct lttng_event_field_value **field_val); diff --git a/src/common/conditions/on-event.c b/src/common/conditions/on-event.c index a10df868a..9cc80772c 100644 --- a/src/common/conditions/on-event.c +++ b/src/common/conditions/on-event.c @@ -1380,23 +1380,25 @@ error: return evaluation; } -enum lttng_evaluation_status lttng_evaluation_on_event_get_captured_values( +enum lttng_evaluation_on_event_status +lttng_evaluation_on_event_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_status status = LTTNG_EVALUATION_STATUS_OK; + enum lttng_evaluation_on_event_status status = + LTTNG_EVALUATION_ON_EVENT_STATUS_OK; if (!evaluation || !is_on_event_evaluation(evaluation) || !field_val) { - status = LTTNG_EVALUATION_STATUS_INVALID; + status = LTTNG_EVALUATION_ON_EVENT_STATUS_INVALID; goto end; } hit = container_of(evaluation, struct lttng_evaluation_on_event, parent); if (!hit->captured_values) { - status = LTTNG_EVALUATION_STATUS_INVALID; + status = LTTNG_EVALUATION_ON_EVENT_STATUS_NONE; goto end; } diff --git a/tests/regression/tools/notification/notification.c b/tests/regression/tools/notification/notification.c index 68a76f922..e7101bb9f 100644 --- a/tests/regression/tools/notification/notification.c +++ b/tests/regression/tools/notification/notification.c @@ -2306,7 +2306,7 @@ static int validator_notification_trigger_capture( { int ret; unsigned int capture_count, i; - enum lttng_evaluation_status evaluation_status; + enum lttng_evaluation_on_event_status on_event_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; @@ -2319,11 +2319,12 @@ static int validator_notification_trigger_capture( goto end; } - evaluation_status = lttng_evaluation_on_event_get_captured_values( - evaluation, &captured_fields); - if (evaluation_status != LTTNG_EVALUATION_STATUS_OK) { + on_event_evaluation_status = + lttng_evaluation_on_event_get_captured_values( + evaluation, &captured_fields); + if (on_event_evaluation_status != LTTNG_EVALUATION_ON_EVENT_STATUS_OK) { diag("Failed to get event rule evaluation captured values: status = %d", - (int) evaluation_status); + (int) on_event_evaluation_status); ret = 1; goto end; }