2 * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_EVENT_EXPR_H
9 #define LTTNG_EVENT_EXPR_H
13 struct lttng_event_expr
;
20 * Types of an event expression.
22 enum lttng_event_expr_type
{
24 * Returned by lttng_event_expr_get_type() with an invalid
27 LTTNG_EVENT_EXPR_TYPE_INVALID
= -1,
30 * The named payload field of an event.
32 * Command-line expression example:
36 LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD
= 0,
39 * The named per-channel context field of an event.
41 * Command-line expression example:
45 LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD
= 1,
48 * The named application-specific context field of an event.
50 * Command-line expression example:
52 * $app.iga:active-clients
54 LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD
= 2,
57 * The element of an array field.
59 * Command-line expression example:
62 * $ctx.some_context[5][1]
64 LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT
= 3,
68 * Event expression API status codes.
70 enum lttng_event_expr_status
{
74 LTTNG_EVENT_EXPR_STATUS_INVALID
= -1,
79 LTTNG_EVENT_EXPR_STATUS_OK
= 0,
83 * Returns the type of the event expression `expr`, or
84 * `LTTNG_EVENT_EXPR_TYPE_INVALID` if `expr` is `NULL`.
86 extern enum lttng_event_expr_type
lttng_event_expr_get_type(
87 const struct lttng_event_expr
*expr
);
90 * Creates an event payload field expression for the payload field named
95 * * There's a memory error.
96 * * `field_name` is `NULL`.
98 extern struct lttng_event_expr
*lttng_event_expr_event_payload_field_create(
99 const char *field_name
);
102 * Returns the field name of the event payload field expression `expr`,
105 * * `expr` is `NULL`.
106 * * The type of `expr` is not
107 * `LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD`.
109 extern const char *lttng_event_expr_event_payload_field_get_name(
110 const struct lttng_event_expr
*expr
);
113 * Creates a per-channel context field expression for the per-channel
114 * context field named `field_name`.
118 * * There's a memory error.
119 * * `field_name` is `NULL`.
121 extern struct lttng_event_expr
*
122 lttng_event_expr_channel_context_field_create(const char *field_name
);
125 * Returns the field name of the per-channel context field
126 * expression `expr`, or `NULL` if:
129 * * The type of `expr` is not
130 * `LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD`.
132 extern const char *lttng_event_expr_channel_context_field_get_name(
133 const struct lttng_event_expr
*expr
);
136 * Creates an application-specific context field expression for the
137 * application-specific context field provided by the provider named
138 * `provider_name` and having the type named `type_name`.
142 * * There's a memory error.
143 * * `provider_name` is `NULL`.
144 * * `type_name` is `NULL`.
146 extern struct lttng_event_expr
*
147 lttng_event_expr_app_specific_context_field_create(
148 const char *provider_name
, const char *type_name
);
151 * Returns the provider name of the application-specific context field
152 * expression `expr`, or `NULL` if:
154 * * `expr` is `NULL`.
155 * * The type of `expr` is not
156 * `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD`.
159 lttng_event_expr_app_specific_context_field_get_provider_name(
160 const struct lttng_event_expr
*expr
);
163 * Returns the type name of the application-specific context field
164 * expression `expr`, or `NULL` if:
166 * * `expr` is `NULL`.
167 * * The type of `expr` is not
168 * `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD`.
171 lttng_event_expr_app_specific_context_field_get_type_name(
172 const struct lttng_event_expr
*expr
);
175 * Creates an array field element expression for the parent array field
176 * `array_field_expr` (transfering the ownership) and the index `index`.
180 * * There's a memory error.
181 * * `array_field_expr` is `NULL`.
182 * * `array_field_expr` is not a locator expression, that is, its type
185 * * `LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD`
186 * * `LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD`
187 * * `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD`
188 * * `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT`
190 extern struct lttng_event_expr
*lttng_event_expr_array_field_element_create(
191 struct lttng_event_expr
*array_field_expr
,
195 * Returns the parent array field expression of the array field element
196 * expression `expr`, or `NULL` if:
198 * * `expr` is `NULL`.
199 * * The type of `expr` is not
200 * `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT`.
202 extern const struct lttng_event_expr
*
203 lttng_event_expr_array_field_element_get_parent_expr(
204 const struct lttng_event_expr
*expr
);
207 * Sets `*index` to the index of the array field element expression
212 * `LTTNG_EVENT_EXPR_STATUS_OK`:
215 * `LTTNG_EVENT_EXPR_STATUS_INVALID`:
216 * * `expr` is `NULL`.
217 * * The type of `expr` is not
218 * `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT`.
219 * * `index` is `NULL`.
221 extern enum lttng_event_expr_status
222 lttng_event_expr_array_field_element_get_index(
223 const struct lttng_event_expr
*expr
, unsigned int *index
);
226 * Returns whether or not the event expressions `expr_a` and `expr_b`
229 * `expr_a` and `expr_b` can be `NULL`.
231 extern bool lttng_event_expr_is_equal(const struct lttng_event_expr
*expr_a
,
232 const struct lttng_event_expr
*expr_b
);
235 * Destroys the event expression `expr` if not `NULL`.
237 extern void lttng_event_expr_destroy(struct lttng_event_expr
*expr
);
243 #endif /* LTTNG_EVENT_EXPR_H */