2 * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_CONDITION_ON_EVENT_H
9 #define LTTNG_CONDITION_ON_EVENT_H
11 #include <lttng/event-rule/event-rule.h>
12 #include <lttng/condition/condition.h>
13 #include <lttng/condition/evaluation.h>
19 struct lttng_event_expr
;
20 struct lttng_event_field_value
;
22 enum lttng_evaluation_on_event_status
{
23 LTTNG_EVALUATION_ON_EVENT_STATUS_NONE
= 1,
24 LTTNG_EVALUATION_ON_EVENT_STATUS_OK
= 0,
25 LTTNG_EVALUATION_ON_EVENT_STATUS_INVALID
= -1,
29 * On event conditions allows an action to be taken whenever an event matching
30 * the on event is hit by the tracers.
32 * An on event condition can also specify a payload to be captured at runtime.
33 * This is done via the capture descriptor.
35 * Note: the dynamic runtime capture of payload is only available for the
36 * trigger notification subsystem.
40 * Create a newly allocated on event condition.
42 * Returns a new condition on success, NULL on failure. This condition must be
43 * destroyed using lttng_condition_destroy().
45 extern struct lttng_condition
*lttng_condition_on_event_create(
46 struct lttng_event_rule
*rule
);
49 * Get the rule property of a on event condition.
51 * The caller does not assume the ownership of the returned rule. The
52 * rule shall only be used for the duration of the condition's
55 * Returns LTTNG_CONDITION_STATUS_OK and a pointer to the condition's rule
56 * on success, LTTNG_CONDITION_STATUS_INVALID if an invalid
57 * parameter is passed. */
58 extern enum lttng_condition_status
lttng_condition_on_event_get_rule(
59 const struct lttng_condition
*condition
,
60 const struct lttng_event_rule
**rule
);
63 * lttng_evaluation_on_event_hit are specialised lttng_evaluations which
64 * allow users to query a number of properties resulting from the evaluation
65 * of a condition which evaluated to true.
67 * The evaluation of an on event condition contains the captured event
68 * payload fields that were specified by the condition.
72 * Sets `*field_val` to the array event field value of the on event
73 * condition evaluation `evaluation` which contains its captured values.
77 * `LTTNG_EVALUATION_ON_EVENT_STATUS_OK`:
80 * `*field_val` is an array event field value with a length of at
83 * `LTTNG_EVALUATION_ON_EVENT_STATUS_INVALID`:
84 * * `evaluation` is `NULL`.
85 * * The type of the condition of `evaluation` is not
86 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
87 * * `field_val` is `NULL`.
89 * `LTTNG_EVALUATION_ON_EVENT_STATUS_NONE`:
90 * * The condition of `evaluation` has no capture descriptors.
92 extern enum lttng_evaluation_on_event_status
93 lttng_evaluation_on_event_get_captured_values(
94 const struct lttng_evaluation
*evaluation
,
95 const struct lttng_event_field_value
**field_val
);
98 * Appends (transfering the ownership) the capture descriptor `expr` to
99 * the on event condition `condition`.
103 * `LTTNG_CONDITION_STATUS_OK`:
106 * `LTTNG_CONDITION_STATUS_ERROR`:
109 * `LTTNG_CONDITION_STATUS_INVALID`:
110 * * `condition` is `NULL`.
111 * * The type of `condition` is not
112 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
113 * * `expr` is `NULL`.
114 * * `expr` is not a locator expression, that is, its type is not
117 * * `LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD`
118 * * `LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD`
119 * * `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD`
120 * * `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT`
122 * `LTTNG_CONDITION_STATUS_UNSUPPORTED`:
123 * * The associated event-rule does not support runtime capture.
125 extern enum lttng_condition_status
126 lttng_condition_on_event_append_capture_descriptor(
127 struct lttng_condition
*condition
,
128 struct lttng_event_expr
*expr
);
131 * Sets `*count` to the number of capture descriptors in the on event
132 * condition `condition`.
136 * `LTTNG_CONDITION_STATUS_OK`:
139 * `LTTNG_CONDITION_STATUS_INVALID`:
140 * * `condition` is `NULL`.
141 * * The type of `condition` is not
142 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
143 * * `count` is `NULL`.
145 extern enum lttng_condition_status
146 lttng_condition_on_event_get_capture_descriptor_count(
147 const struct lttng_condition
*condition
, unsigned int *count
);
150 * Returns the capture descriptor (borrowed) of the on event condition
151 * `condition` at the index `index`, or `NULL` if:
153 * * `condition` is `NULL`.
154 * * The type of `condition` is not
155 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
156 * * `index` is greater than or equal to the number of capture
157 * descriptors in `condition` (as returned by
158 * lttng_condition_on_event_get_capture_descriptor_count()).
160 extern const struct lttng_event_expr
*
161 lttng_condition_on_event_get_capture_descriptor_at_index(
162 const struct lttng_condition
*condition
, unsigned int index
);
168 #endif /* LTTNG_CONDITION_ON_EVENT_H */