Rename files for condition event-rule to on-event
[lttng-tools.git] / include / lttng / condition / on-event.h
CommitLineData
683d081a
JR
1/*
2 * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
d602bd6a
JR
8#ifndef LTTNG_CONDITION_ON_EVENT_H
9#define LTTNG_CONDITION_ON_EVENT_H
683d081a
JR
10
11#include <lttng/event-rule/event-rule.h>
12#include <lttng/condition/condition.h>
13#include <lttng/condition/evaluation.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
38114013 19struct lttng_event_expr;
7c920b63 20struct lttng_event_field_value;
38114013 21
683d081a 22/**
d602bd6a
JR
23 * On event conditions allows an action to be taken whenever an event matching
24 * the on event is hit by the tracers.
683d081a 25 *
d602bd6a 26 * An on event condition can also specify a payload to be captured at runtime.
683d081a
JR
27 * This is done via the capture descriptor.
28 *
29 * Note: the dynamic runtime capture of payload is only available for the
30 * trigger notification subsystem.
31 */
32
33/*
d602bd6a 34 * Create a newly allocated on event condition.
683d081a
JR
35 *
36 * Returns a new condition on success, NULL on failure. This condition must be
37 * destroyed using lttng_condition_destroy().
38 */
d602bd6a 39extern struct lttng_condition *lttng_condition_on_event_create(
683d081a
JR
40 struct lttng_event_rule *rule);
41
42/*
d602bd6a 43 * Get the rule property of a on event condition.
683d081a
JR
44 *
45 * The caller does not assume the ownership of the returned rule. The
46 * rule shall only be used for the duration of the condition's
47 * lifetime.
48 *
49 * Returns LTTNG_CONDITION_STATUS_OK and a pointer to the condition's rule
50 * on success, LTTNG_CONDITION_STATUS_INVALID if an invalid
51 * parameter is passed. */
d602bd6a
JR
52extern enum lttng_condition_status lttng_condition_on_event_get_rule(
53 const struct lttng_condition *condition,
683d081a
JR
54 const struct lttng_event_rule **rule);
55
56/**
d602bd6a 57 * lttng_evaluation_on_event_hit are specialised lttng_evaluations which
683d081a
JR
58 * allow users to query a number of properties resulting from the evaluation
59 * of a condition which evaluated to true.
60 *
d602bd6a 61 * The evaluation of a on event hit yields two different results:
683d081a
JR
62 * TEMPORARY - The name of the triggers associated with the condition.
63 * TODO - The captured event payload if any
64 */
65
66/*
d602bd6a 67 * Get the trigger name property of a on event hit evaluation.
683d081a
JR
68 *
69 * Returns LTTNG_EVALUATION_STATUS_OK on success and a trigger name
70 * or LTTNG_EVALUATION_STATUS_INVALID if
71 * an invalid parameter is passed.
72 */
73extern enum lttng_evaluation_status
d602bd6a 74lttng_evaluation_on_event_get_trigger_name(
683d081a
JR
75 const struct lttng_evaluation *evaluation,
76 const char **name);
77
7c920b63 78/*
d602bd6a 79 * Sets `*field_val` to the array event field value of the on event
7c920b63
PP
80 * condition evaluation `evaluation` which contains its captured values.
81 *
82 * Returns:
83 *
84 * `LTTNG_EVALUATION_STATUS_OK`:
85 * Success.
86 *
87 * `*field_val` is an array event field value with a length of at
88 * least one.
89 *
90 * `LTTNG_EVALUATION_STATUS_INVALID`:
91 * * `evaluation` is `NULL`.
92 * * The type of the condition of `evaluation` is not
d602bd6a 93 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
7c920b63
PP
94 * * The condition of `evaluation` has no capture descriptors.
95 * * `field_val` is `NULL`.
96 */
97extern enum lttng_evaluation_status
d602bd6a 98lttng_evaluation_on_event_get_captured_values(
7c920b63
PP
99 const struct lttng_evaluation *evaluation,
100 const struct lttng_event_field_value **field_val);
101
38114013
PP
102/*
103 * Appends (transfering the ownership) the capture descriptor `expr` to
d602bd6a 104 * the on event condition `condition`.
38114013
PP
105 *
106 * Returns:
107 *
108 * `LTTNG_CONDITION_STATUS_OK`:
109 * Success.
110 *
111 * `LTTNG_CONDITION_STATUS_ERROR`:
112 * Memory error.
113 *
114 * `LTTNG_CONDITION_STATUS_INVALID`:
115 * * `condition` is `NULL`.
116 * * The type of `condition` is not
d602bd6a 117 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
38114013
PP
118 * * `expr` is `NULL`.
119 * * `expr` is not a locator expression, that is, its type is not
120 * one of:
121 *
122 * * `LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD`
123 * * `LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD`
124 * * `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD`
125 * * `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT`
81d566c9
JR
126 *
127 * `LTTNG_CONDITION_STATUS_UNSUPPORTED`:
128 * * The associated event-rule does not support runtime capture.
38114013
PP
129 */
130extern enum lttng_condition_status
d602bd6a 131lttng_condition_on_event_append_capture_descriptor(
38114013
PP
132 struct lttng_condition *condition,
133 struct lttng_event_expr *expr);
134
135/*
d602bd6a 136 * Sets `*count` to the number of capture descriptors in the on event
38114013
PP
137 * condition `condition`.
138 *
139 * Returns:
140 *
141 * `LTTNG_CONDITION_STATUS_OK`:
142 * Success.
143 *
144 * `LTTNG_CONDITION_STATUS_INVALID`:
145 * * `condition` is `NULL`.
146 * * The type of `condition` is not
d602bd6a 147 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
38114013
PP
148 * * `count` is `NULL`.
149 */
150extern enum lttng_condition_status
d602bd6a 151lttng_condition_on_event_get_capture_descriptor_count(
38114013
PP
152 const struct lttng_condition *condition, unsigned int *count);
153
154/*
d602bd6a 155 * Returns the capture descriptor (borrowed) of the on event condition
38114013
PP
156 * `condition` at the index `index`, or `NULL` if:
157 *
158 * * `condition` is `NULL`.
159 * * The type of `condition` is not
d602bd6a 160 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
38114013
PP
161 * * `index` is greater than or equal to the number of capture
162 * descriptors in `condition` (as returned by
d602bd6a 163 * lttng_condition_on_event_get_capture_descriptor_count()).
38114013
PP
164 */
165extern const struct lttng_event_expr *
d602bd6a 166lttng_condition_on_event_get_capture_descriptor_at_index(
38114013
PP
167 const struct lttng_condition *condition, unsigned int index);
168
683d081a
JR
169#ifdef __cplusplus
170}
171#endif
172
d602bd6a 173#endif /* LTTNG_CONDITION_ON_EVENT_H */
This page took 0.030956 seconds and 4 git commands to generate.