2 * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_CONDITION_event_rule_INTERNAL_H
9 #define LTTNG_CONDITION_event_rule_INTERNAL_H
11 #include <lttng/condition/condition-internal.h>
12 #include <common/buffer-view.h>
13 #include <common/macros.h>
14 #include <lttng/condition/evaluation-internal.h>
15 #include <common/dynamic-array.h>
16 #include <lttng/event-field-value.h>
18 struct lttng_capture_descriptor
{
19 /* The index at which the capture for this descriptor in the received
20 * payload from the tracer. This is populated on sessiond side.
21 * -1 is uninitialized.
22 * This is necessary since a single trigger can have multiple notify
23 * action, only an ordered set of capture desciptor is passed to the tracer.
25 int32_t capture_index
;
26 struct lttng_event_expr
*event_expression
;
29 struct lttng_condition_event_rule
{
30 struct lttng_condition parent
;
31 struct lttng_event_rule
*rule
;
33 /* Array of `struct lttng_capture_descriptor *` */
34 struct lttng_dynamic_pointer_array capture_descriptors
;
37 struct lttng_evaluation_event_rule
{
38 struct lttng_evaluation parent
;
41 /* MessagePack-encoded captured event field values */
42 struct lttng_dynamic_buffer capture_payload
;
45 * The content of this array event field value is the decoded
46 * version of `capture_payload` above.
48 * This is a cache: it's not serialized/deserialized in
49 * communications from/to the library and the session daemon.
51 struct lttng_event_field_value
*captured_values
;
54 struct lttng_evaluation_event_rule_comm
{
55 uint32_t trigger_name_length
;
60 struct lttng_condition_event_rule_capture_bytecode_element
62 struct lttng_event_expr
*expression
;
63 struct lttng_bytecode
*bytecode
;
67 ssize_t
lttng_condition_event_rule_create_from_payload(
68 struct lttng_payload_view
*view
,
69 struct lttng_condition
**condition
);
72 enum lttng_condition_status
73 lttng_condition_event_rule_get_rule_mutable(
74 const struct lttng_condition
*condition
,
75 struct lttng_event_rule
**rule
);
78 struct lttng_evaluation
*lttng_evaluation_event_rule_create(
79 const struct lttng_condition_event_rule
*condition
,
80 const char* trigger_name
,
81 const char *capture_payload
, size_t capture_payload_size
,
82 bool decode_capture_payload
);
85 ssize_t
lttng_evaluation_event_rule_create_from_payload(
86 const struct lttng_condition_event_rule
*condition
,
87 struct lttng_payload_view
*view
,
88 struct lttng_evaluation
**_evaluation
);
91 * The returned `lttng_dynamic_pointer_array` contains a index ordered set of
92 * `lttng_condition_event_rule_capture_bytecode_element`.
93 * This ensure that minimal work will be done by the tracer for cases where
94 * multiple identical capture expression are present.
98 lttng_condition_event_rule_generate_capture_descriptor_bytecode_set(
99 struct lttng_condition
*condition
,
100 struct lttng_dynamic_pointer_array
*bytecode_set
);
103 struct lttng_capture_descriptor
*
104 lttng_condition_event_rule_get_internal_capture_descriptor_at_index(
105 const struct lttng_condition
*condition
, unsigned int index
);
107 #endif /* LTTNG_CONDITION_event_rule_INTERNAL_H */