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
12 #include <lttng/event-field-value.h>
13 #include <common/dynamic-array.hpp>
15 struct lttng_event_field_value {
16 enum lttng_event_field_value_type type;
20 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT`.
22 struct lttng_event_field_value_uint {
23 struct lttng_event_field_value parent;
28 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT`.
30 struct lttng_event_field_value_int {
31 struct lttng_event_field_value parent;
36 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` and
37 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM` (base).
39 struct lttng_event_field_value_enum {
40 struct lttng_event_field_value parent;
43 * Array of `char *` (owned by this).
45 struct lttng_dynamic_pointer_array labels;
49 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM`.
51 struct lttng_event_field_value_enum_uint {
52 struct lttng_event_field_value_enum parent;
57 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
59 struct lttng_event_field_value_enum_int {
60 struct lttng_event_field_value_enum parent;
64 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_REAL` */
65 struct lttng_event_field_value_real {
66 struct lttng_event_field_value parent;
70 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
71 struct lttng_event_field_value_string {
72 struct lttng_event_field_value parent;
78 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
79 struct lttng_event_field_value_array {
80 struct lttng_event_field_value parent;
83 * Array of `struct lttng_event_field_value *` (owned by this).
85 * A `NULL` element means it's unavailable
86 * (`LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status).
88 struct lttng_dynamic_pointer_array elems;
92 * This is internal since the session daemon knows nothing about the
93 * enumeration fields produced by the kernel tracer. Indeed, the kernel tracer
94 * manages its own metadata which remains opaque to the rest of the toolchain.
96 * Enumerations could be supported for the user space tracer, but it is not the
101 * Sets `*count` to the number of labels of the enumeration event field
106 * `LTTNG_EVENT_FIELD_VALUE_STATUS_OK`:
109 * `LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID`:
110 * * `field_val` is `NULL`.
111 * * The type of `field_val` is not
112 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
113 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
114 * * `count` is `NULL`.
116 enum lttng_event_field_value_status
117 lttng_event_field_value_enum_get_label_count(
118 const struct lttng_event_field_value *field_val,
119 unsigned int *count);
122 * Returns the label at index `index` of the enumeration event field
123 * value `field_val`, or `NULL` if:
125 * * `field_val` is `NULL`.
126 * * The type of `field_val` is not
127 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
128 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
129 * * `index` is greater than or equal to the label count of `field_val`,
130 * as returned by lttng_event_field_value_enum_get_label_count().
132 const char *lttng_event_field_value_enum_get_label_at_index(
133 const struct lttng_event_field_value *field_val,
136 struct lttng_event_field_value *lttng_event_field_value_uint_create(
139 struct lttng_event_field_value *lttng_event_field_value_int_create(
142 struct lttng_event_field_value *lttng_event_field_value_enum_uint_create(
145 struct lttng_event_field_value *lttng_event_field_value_enum_int_create(
148 struct lttng_event_field_value *lttng_event_field_value_real_create(double val);
150 struct lttng_event_field_value *lttng_event_field_value_string_create(
153 struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(
154 const char *val, size_t size);
156 struct lttng_event_field_value *lttng_event_field_value_array_create(void);
158 int lttng_event_field_value_enum_append_label(
159 struct lttng_event_field_value *field_val, const char *label);
161 int lttng_event_field_value_enum_append_label_with_size(
162 struct lttng_event_field_value *field_val, const char *label,
165 int lttng_event_field_value_array_append(
166 struct lttng_event_field_value *array_field_val,
167 struct lttng_event_field_value *field_val);
169 int lttng_event_field_value_array_append_unavailable(
170 struct lttng_event_field_value *array_field_val);
172 void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val);
174 #endif /* LTTNG_EVENT_FIELD_VALUE_INTERNAL_H */