Implement lttng_condition_event_rule_get_capture_bytecode_at_index
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 3 Nov 2020 23:04:34 +0000 (18:04 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 11 Mar 2021 20:31:53 +0000 (15:31 -0500)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I0478c3c1a5866f924fa8a5b49fdc61570a802989

include/lttng/condition/event-rule-internal.h
src/common/conditions/event-rule.c

index 1f039c3475f8c5eec77084eee754d70e700aa1f1..0f2f3fbf6c3e7971a587bdb2bcdff3b8a79e3087 100644 (file)
@@ -64,4 +64,9 @@ enum lttng_error_code
 lttng_condition_event_rule_generate_capture_descriptor_bytecode(
                struct lttng_condition *condition);
 
+LTTNG_HIDDEN
+const struct lttng_bytecode *
+lttng_condition_event_rule_get_capture_bytecode_at_index(
+               const struct lttng_condition *condition, unsigned int index);
+
 #endif /* LTTNG_CONDITION_EVENT_RULE_INTERNAL_H */
index 8959652ddda3da8ba23364b73cc3e8b1d0bbc338..dcc31ef8622ccdc823d5f85e2ed382d55666fc12 100644 (file)
@@ -972,3 +972,42 @@ lttng_condition_event_rule_generate_capture_descriptor_bytecode(
 end:
        return ret;
 }
+
+LTTNG_HIDDEN
+const struct lttng_bytecode *
+lttng_condition_event_rule_get_capture_bytecode_at_index(
+               const struct lttng_condition *condition, unsigned int index)
+{
+       const struct lttng_condition_event_rule *event_rule_cond =
+                       container_of(condition,
+                               const struct lttng_condition_event_rule,
+                               parent);
+       struct lttng_capture_descriptor *desc = NULL;
+       struct lttng_bytecode *bytecode = NULL;
+       unsigned int count;
+       enum lttng_condition_status status;
+
+       if (!condition || !IS_EVENT_RULE_CONDITION(condition)) {
+               goto end;
+       }
+
+       status = lttng_condition_event_rule_get_capture_descriptor_count(
+                       condition, &count);
+       if (status != LTTNG_CONDITION_STATUS_OK) {
+               goto end;
+       }
+
+       if (index >= count) {
+               goto end;
+       }
+
+       desc = lttng_dynamic_pointer_array_get_pointer(
+                       &event_rule_cond->capture_descriptors, index);
+       if (desc == NULL) {
+               goto end;
+       }
+
+       bytecode = desc->bytecode;
+end:
+       return bytecode;
+}
This page took 0.031507 seconds and 4 git commands to generate.