2 * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
9 #define LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
13 #include <lttng/event-field-value.h>
14 #include <common/dynamic-array.h>
16 struct lttng_event_field_value
{
17 enum lttng_event_field_value_type type
;
21 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT`.
23 struct lttng_event_field_value_uint
{
24 struct lttng_event_field_value parent
;
29 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT`.
31 struct lttng_event_field_value_int
{
32 struct lttng_event_field_value parent
;
37 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` and
38 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM` (base).
40 struct lttng_event_field_value_enum
{
41 struct lttng_event_field_value parent
;
44 * Array of `char *` (owned by this).
46 struct lttng_dynamic_pointer_array labels
;
50 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM`.
52 struct lttng_event_field_value_enum_uint
{
53 struct lttng_event_field_value_enum parent
;
58 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
60 struct lttng_event_field_value_enum_int
{
61 struct lttng_event_field_value_enum parent
;
65 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_REAL` */
66 struct lttng_event_field_value_real
{
67 struct lttng_event_field_value parent
;
71 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
72 struct lttng_event_field_value_string
{
73 struct lttng_event_field_value parent
;
79 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
80 struct lttng_event_field_value_array
{
81 struct lttng_event_field_value parent
;
84 * Array of `struct lttng_event_field_value *` (owned by this).
86 * A `NULL` element means it's unavailable
87 * (`LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status).
89 struct lttng_dynamic_pointer_array elems
;
93 * This is internal since the session daemon knows nothing about the
94 * enumeration fields produced by the kernel tracer. Indeed, the kernel tracer
95 * manages its own metadata which remains opaque to the rest of the toolchain.
97 * Enumerations could be supported for the user space tracer, but it is not the
102 * Sets `*count` to the number of labels of the enumeration event field
107 * `LTTNG_EVENT_FIELD_VALUE_STATUS_OK`:
110 * `LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID`:
111 * * `field_val` is `NULL`.
112 * * The type of `field_val` is not
113 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
114 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
115 * * `count` is `NULL`.
118 enum lttng_event_field_value_status
119 lttng_event_field_value_enum_get_label_count(
120 const struct lttng_event_field_value
*field_val
,
121 unsigned int *count
);
124 * Returns the label at index `index` of the enumeration event field
125 * value `field_val`, or `NULL` if:
127 * * `field_val` is `NULL`.
128 * * The type of `field_val` is not
129 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
130 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
131 * * `index` is greater than or equal to the label count of `field_val`,
132 * as returned by lttng_event_field_value_enum_get_label_count().
135 const char *lttng_event_field_value_enum_get_label_at_index(
136 const struct lttng_event_field_value
*field_val
,
140 struct lttng_event_field_value
*lttng_event_field_value_uint_create(
144 struct lttng_event_field_value
*lttng_event_field_value_int_create(
148 struct lttng_event_field_value
*lttng_event_field_value_enum_uint_create(
152 struct lttng_event_field_value
*lttng_event_field_value_enum_int_create(
156 struct lttng_event_field_value
*lttng_event_field_value_real_create(double val
);
159 struct lttng_event_field_value
*lttng_event_field_value_string_create(
163 struct lttng_event_field_value
*lttng_event_field_value_string_create_with_size(
164 const char *val
, size_t size
);
167 struct lttng_event_field_value
*lttng_event_field_value_array_create(void);
170 int lttng_event_field_value_enum_append_label(
171 struct lttng_event_field_value
*field_val
, const char *label
);
174 int lttng_event_field_value_enum_append_label_with_size(
175 struct lttng_event_field_value
*field_val
, const char *label
,
179 int lttng_event_field_value_array_append(
180 struct lttng_event_field_value
*array_field_val
,
181 struct lttng_event_field_value
*field_val
);
184 int lttng_event_field_value_array_append_unavailable(
185 struct lttng_event_field_value
*array_field_val
);
188 void lttng_event_field_value_destroy(struct lttng_event_field_value
*field_val
);
190 #endif /* LTTNG_EVENT_FIELD_VALUE_INTERNAL_H */