| 1 | /* |
| 2 | * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.1-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H |
| 9 | #define LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H |
| 10 | |
| 11 | #include <lttng/condition/condition-internal.h> |
| 12 | #include <common/buffer-view.h> |
| 13 | #include <common/macros.h> |
| 14 | #include <common/optional.h> |
| 15 | #include <lttng/condition/evaluation-internal.h> |
| 16 | #include <common/dynamic-array.h> |
| 17 | #include <lttng/event-field-value.h> |
| 18 | |
| 19 | struct lttng_capture_descriptor { |
| 20 | struct lttng_event_expr *event_expression; |
| 21 | struct lttng_bytecode *bytecode; |
| 22 | }; |
| 23 | |
| 24 | struct lttng_condition_event_rule_matches { |
| 25 | struct lttng_condition parent; |
| 26 | struct lttng_event_rule *rule; |
| 27 | |
| 28 | /* |
| 29 | * Internal use only. |
| 30 | * Error accounting counter index. |
| 31 | */ |
| 32 | LTTNG_OPTIONAL(uint64_t) error_counter_index; |
| 33 | |
| 34 | /* Array of `struct lttng_capture_descriptor *`. */ |
| 35 | struct lttng_dynamic_pointer_array capture_descriptors; |
| 36 | }; |
| 37 | |
| 38 | struct lttng_evaluation_event_rule_matches { |
| 39 | struct lttng_evaluation parent; |
| 40 | |
| 41 | /* MessagePack-encoded captured event field values. */ |
| 42 | struct lttng_dynamic_buffer capture_payload; |
| 43 | |
| 44 | /* |
| 45 | * The content of this array event field value is the decoded |
| 46 | * version of `capture_payload` above. |
| 47 | * |
| 48 | * This is a cache: it's not serialized/deserialized in |
| 49 | * communications from/to the library and the session daemon. |
| 50 | */ |
| 51 | struct lttng_event_field_value *captured_values; |
| 52 | }; |
| 53 | |
| 54 | ssize_t lttng_condition_event_rule_matches_create_from_payload( |
| 55 | struct lttng_payload_view *view, |
| 56 | struct lttng_condition **condition); |
| 57 | |
| 58 | enum lttng_condition_status |
| 59 | lttng_condition_event_rule_matches_borrow_rule_mutable( |
| 60 | const struct lttng_condition *condition, |
| 61 | struct lttng_event_rule **rule); |
| 62 | |
| 63 | void lttng_condition_event_rule_matches_set_error_counter_index( |
| 64 | struct lttng_condition *condition, |
| 65 | uint64_t error_counter_index); |
| 66 | |
| 67 | uint64_t lttng_condition_event_rule_matches_get_error_counter_index( |
| 68 | const struct lttng_condition *condition); |
| 69 | |
| 70 | struct lttng_evaluation *lttng_evaluation_event_rule_matches_create( |
| 71 | const struct lttng_condition_event_rule_matches *condition, |
| 72 | const char *capture_payload, |
| 73 | size_t capture_payload_size, |
| 74 | bool decode_capture_payload); |
| 75 | |
| 76 | ssize_t lttng_evaluation_event_rule_matches_create_from_payload( |
| 77 | const struct lttng_condition_event_rule_matches *condition, |
| 78 | struct lttng_payload_view *view, |
| 79 | struct lttng_evaluation **_evaluation); |
| 80 | |
| 81 | enum lttng_error_code |
| 82 | lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode( |
| 83 | struct lttng_condition *condition); |
| 84 | |
| 85 | const struct lttng_bytecode * |
| 86 | lttng_condition_event_rule_matches_get_capture_bytecode_at_index( |
| 87 | const struct lttng_condition *condition, unsigned int index); |
| 88 | |
| 89 | #endif /* LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H */ |