on-event evaluation: introduce on-event evaluation specific status code
[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
3ce811ee
JG
22enum 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,
26};
27
683d081a 28/**
d602bd6a
JR
29 * On event conditions allows an action to be taken whenever an event matching
30 * the on event is hit by the tracers.
683d081a 31 *
d602bd6a 32 * An on event condition can also specify a payload to be captured at runtime.
683d081a
JR
33 * This is done via the capture descriptor.
34 *
35 * Note: the dynamic runtime capture of payload is only available for the
36 * trigger notification subsystem.
37 */
38
39/*
d602bd6a 40 * Create a newly allocated on event condition.
683d081a
JR
41 *
42 * Returns a new condition on success, NULL on failure. This condition must be
43 * destroyed using lttng_condition_destroy().
44 */
d602bd6a 45extern struct lttng_condition *lttng_condition_on_event_create(
683d081a
JR
46 struct lttng_event_rule *rule);
47
48/*
d602bd6a 49 * Get the rule property of a on event condition.
683d081a
JR
50 *
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
53 * lifetime.
54 *
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. */
d602bd6a
JR
58extern enum lttng_condition_status lttng_condition_on_event_get_rule(
59 const struct lttng_condition *condition,
683d081a
JR
60 const struct lttng_event_rule **rule);
61
62/**
d602bd6a 63 * lttng_evaluation_on_event_hit are specialised lttng_evaluations which
683d081a
JR
64 * allow users to query a number of properties resulting from the evaluation
65 * of a condition which evaluated to true.
66 *
d602bd6a 67 * The evaluation of a on event hit yields two different results:
683d081a
JR
68 * TEMPORARY - The name of the triggers associated with the condition.
69 * TODO - The captured event payload if any
70 */
71
72/*
d602bd6a 73 * Get the trigger name property of a on event hit evaluation.
683d081a
JR
74 *
75 * Returns LTTNG_EVALUATION_STATUS_OK on success and a trigger name
76 * or LTTNG_EVALUATION_STATUS_INVALID if
77 * an invalid parameter is passed.
78 */
79extern enum lttng_evaluation_status
d602bd6a 80lttng_evaluation_on_event_get_trigger_name(
683d081a
JR
81 const struct lttng_evaluation *evaluation,
82 const char **name);
83
7c920b63 84/*
d602bd6a 85 * Sets `*field_val` to the array event field value of the on event
7c920b63
PP
86 * condition evaluation `evaluation` which contains its captured values.
87 *
88 * Returns:
89 *
3ce811ee 90 * `LTTNG_EVALUATION_ON_EVENT_STATUS_OK`:
7c920b63
PP
91 * Success.
92 *
93 * `*field_val` is an array event field value with a length of at
94 * least one.
95 *
3ce811ee 96 * `LTTNG_EVALUATION_ON_EVENT_STATUS_INVALID`:
7c920b63
PP
97 * * `evaluation` is `NULL`.
98 * * The type of the condition of `evaluation` is not
d602bd6a 99 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
7c920b63 100 * * `field_val` is `NULL`.
3ce811ee
JG
101 *
102 * `LTTNG_EVALUATION_ON_EVENT_STATUS_NONE`:
103 * * The condition of `evaluation` has no capture descriptors.
7c920b63 104 */
3ce811ee 105extern enum lttng_evaluation_on_event_status
d602bd6a 106lttng_evaluation_on_event_get_captured_values(
7c920b63
PP
107 const struct lttng_evaluation *evaluation,
108 const struct lttng_event_field_value **field_val);
109
38114013
PP
110/*
111 * Appends (transfering the ownership) the capture descriptor `expr` to
d602bd6a 112 * the on event condition `condition`.
38114013
PP
113 *
114 * Returns:
115 *
116 * `LTTNG_CONDITION_STATUS_OK`:
117 * Success.
118 *
119 * `LTTNG_CONDITION_STATUS_ERROR`:
120 * Memory error.
121 *
122 * `LTTNG_CONDITION_STATUS_INVALID`:
123 * * `condition` is `NULL`.
124 * * The type of `condition` is not
d602bd6a 125 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
38114013
PP
126 * * `expr` is `NULL`.
127 * * `expr` is not a locator expression, that is, its type is not
128 * one of:
129 *
130 * * `LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD`
131 * * `LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD`
132 * * `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD`
133 * * `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT`
81d566c9
JR
134 *
135 * `LTTNG_CONDITION_STATUS_UNSUPPORTED`:
136 * * The associated event-rule does not support runtime capture.
38114013
PP
137 */
138extern enum lttng_condition_status
d602bd6a 139lttng_condition_on_event_append_capture_descriptor(
38114013
PP
140 struct lttng_condition *condition,
141 struct lttng_event_expr *expr);
142
143/*
d602bd6a 144 * Sets `*count` to the number of capture descriptors in the on event
38114013
PP
145 * condition `condition`.
146 *
147 * Returns:
148 *
149 * `LTTNG_CONDITION_STATUS_OK`:
150 * Success.
151 *
152 * `LTTNG_CONDITION_STATUS_INVALID`:
153 * * `condition` is `NULL`.
154 * * The type of `condition` is not
d602bd6a 155 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
38114013
PP
156 * * `count` is `NULL`.
157 */
158extern enum lttng_condition_status
d602bd6a 159lttng_condition_on_event_get_capture_descriptor_count(
38114013
PP
160 const struct lttng_condition *condition, unsigned int *count);
161
162/*
d602bd6a 163 * Returns the capture descriptor (borrowed) of the on event condition
38114013
PP
164 * `condition` at the index `index`, or `NULL` if:
165 *
166 * * `condition` is `NULL`.
167 * * The type of `condition` is not
d602bd6a 168 * `LTTNG_CONDITION_TYPE_ON_EVENT`.
38114013
PP
169 * * `index` is greater than or equal to the number of capture
170 * descriptors in `condition` (as returned by
d602bd6a 171 * lttng_condition_on_event_get_capture_descriptor_count()).
38114013
PP
172 */
173extern const struct lttng_event_expr *
d602bd6a 174lttng_condition_on_event_get_capture_descriptor_at_index(
38114013
PP
175 const struct lttng_condition *condition, unsigned int index);
176
683d081a
JR
177#ifdef __cplusplus
178}
179#endif
180
d602bd6a 181#endif /* LTTNG_CONDITION_ON_EVENT_H */
This page took 0.030736 seconds and 4 git commands to generate.