char payload[];
} LTTNG_PACKED;
-
LTTNG_HIDDEN
ssize_t lttng_condition_event_rule_create_from_payload(
struct lttng_payload_view *view,
struct lttng_payload_view *view,
struct lttng_evaluation **_evaluation);
+LTTNG_HIDDEN
+enum lttng_error_code
+lttng_condition_event_rule_generate_capture_descriptor_bytecode(
+ struct lttng_condition *condition);
+
#endif /* LTTNG_CONDITION_EVENT_RULE_INTERNAL_H */
LTTNG_ERR_UNSUPPORTED_DOMAIN = 162, /* Unsupported domain used. */
LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY = 163, /* Operation does not apply to the process attribute tracker's tracking policy */
LTTNG_ERR_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD = 164, /* Error initializing event notifier group notification file descriptor */
+ LTTNG_ERR_INVALID_CAPTURE_EXPRESSION = 165, /* Invalid capture expression. */
/* MUST be last element of the manually-assigned section of the enum */
LTTNG_ERR_NR,
#include <assert.h>
#include <common/error.h>
+#include <common/event-expr-to-bytecode.h>
#include <common/macros.h>
#include <inttypes.h>
#include <lttng/condition/condition-internal.h>
+#include <lttng/event-rule/event-rule-internal.h>
#include <lttng/condition/event-rule-internal.h>
#include <lttng/condition/event-rule.h>
#include <lttng/event-expr-internal.h>
#include <lttng/event-expr.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/lttng-error.h>
#include <stdbool.h>
#include <stdint.h>
#include <vendor/msgpack/msgpack.h>
end:
return status;
}
+
+LTTNG_HIDDEN
+enum lttng_error_code
+lttng_condition_event_rule_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_EVENT_RULE_CONDITION(condition)) {
+ ret = LTTNG_ERR_FATAL;
+ goto end;
+ }
+
+ status = lttng_condition_event_rule_get_capture_descriptor_count(
+ condition, &capture_count);
+ if (status != LTTNG_CONDITION_STATUS_OK) {
+ ret = LTTNG_ERR_FATAL;
+ goto end;
+ }
+
+ for (i = 0; i < capture_count; i++) {
+ struct lttng_capture_descriptor *local_capture_desc =
+ lttng_condition_event_rule_get_internal_capture_descriptor_at_index(
+ condition, i);
+
+ if (local_capture_desc == NULL) {
+ ret = LTTNG_ERR_FATAL;
+ goto end;
+ }
+
+ /* Generate the bytecode. */
+ status = lttng_event_expr_to_bytecode(
+ local_capture_desc->event_expression,
+ &local_capture_desc->bytecode);
+ if (status < 0 || local_capture_desc->bytecode == NULL) {
+ ret = LTTNG_ERR_INVALID_CAPTURE_EXPRESSION;
+ goto end;
+ }
+ }
+
+ /* Everything went better than expected */
+ ret = LTTNG_OK;
+
+end:
+ return ret;
+}
[ ERROR_INDEX(LTTNG_ERR_UNSUPPORTED_DOMAIN) ] = "Unsupported domain used",
[ ERROR_INDEX(LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY) ] = "Operation does not apply to the process attribute tracker's tracking policy",
[ ERROR_INDEX(LTTNG_ERR_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD) ] = "Failed to create an event notifier group notification file descriptor",
+ [ ERROR_INDEX(LTTNG_ERR_INVALID_CAPTURE_EXPRESSION) ] = "Invalid capture expression",
/* Last element */
[ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"