SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / include / lttng / event-field-value-internal.h
1 /*
2 * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
9 #define LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
10
11 #include <assert.h>
12 #include <stdint.h>
13 #include <lttng/event-field-value.h>
14 #include <common/dynamic-array.h>
15
16 struct lttng_event_field_value {
17 enum lttng_event_field_value_type type;
18 };
19
20 /*
21 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT`.
22 */
23 struct lttng_event_field_value_uint {
24 struct lttng_event_field_value parent;
25 uint64_t val;
26 };
27
28 /*
29 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT`.
30 */
31 struct lttng_event_field_value_int {
32 struct lttng_event_field_value parent;
33 int64_t val;
34 };
35
36 /*
37 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` and
38 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM` (base).
39 */
40 struct lttng_event_field_value_enum {
41 struct lttng_event_field_value parent;
42
43 /*
44 * Array of `char *` (owned by this).
45 */
46 struct lttng_dynamic_pointer_array labels;
47 };
48
49 /*
50 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM`.
51 */
52 struct lttng_event_field_value_enum_uint {
53 struct lttng_event_field_value_enum parent;
54 uint64_t val;
55 };
56
57 /*
58 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
59 */
60 struct lttng_event_field_value_enum_int {
61 struct lttng_event_field_value_enum parent;
62 int64_t val;
63 };
64
65 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_REAL` */
66 struct lttng_event_field_value_real {
67 struct lttng_event_field_value parent;
68 double val;
69 };
70
71 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
72 struct lttng_event_field_value_string {
73 struct lttng_event_field_value parent;
74
75 /* Owned by this */
76 char *val;
77 };
78
79 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
80 struct lttng_event_field_value_array {
81 struct lttng_event_field_value parent;
82
83 /*
84 * Array of `struct lttng_event_field_value *` (owned by this).
85 *
86 * A `NULL` element means it's unavailable
87 * (`LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status).
88 */
89 struct lttng_dynamic_pointer_array elems;
90 };
91
92 /*
93 * NOTE JORAJ: This was previously public. The only slight problem with that is
94 * that as of today (2020-05-26) there is no plan/sessiond for the tracer to
95 * actually provide this information. This was already known in [1]. For now
96 * this code have no value since it only confuse the end user. At upstreaming
97 * time we will need to decide if we want to remove all code pertaining to enum
98 * label, at least on the lttng-tools API.
99 *
100 * [1] https://support.efficios.com/issues/792
101 *
102 * Sets `*count` to the number of labels of the enumeration event field
103 * value `field_val`.
104 *
105 * Returns:
106 *
107 * `LTTNG_EVENT_FIELD_VALUE_STATUS_OK`:
108 * Success.
109 *
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`.
116 */
117 LTTNG_HIDDEN
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);
122
123 /*
124 * NOTE JORAJ: see NOTE JORAJ off lttng_event_field_value_enum_get_label_count
125 *
126 * Returns the label at index `index` of the enumeration event field
127 * value `field_val`, or `NULL` if:
128 *
129 * * `field_val` is `NULL`.
130 * * The type of `field_val` is not
131 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
132 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
133 * * `index` is greater than or equal to the label count of `field_val`,
134 * as returned by lttng_event_field_value_enum_get_label_count().
135 */
136 LTTNG_HIDDEN
137 const char *lttng_event_field_value_enum_get_label_at_index(
138 const struct lttng_event_field_value *field_val,
139 unsigned int index);
140
141 LTTNG_HIDDEN
142 struct lttng_event_field_value *lttng_event_field_value_uint_create(
143 uint64_t val);
144
145 LTTNG_HIDDEN
146 struct lttng_event_field_value *lttng_event_field_value_int_create(
147 int64_t val);
148
149 LTTNG_HIDDEN
150 struct lttng_event_field_value *lttng_event_field_value_enum_uint_create(
151 uint64_t val);
152
153 LTTNG_HIDDEN
154 struct lttng_event_field_value *lttng_event_field_value_enum_int_create(
155 int64_t val);
156
157 LTTNG_HIDDEN
158 struct lttng_event_field_value *lttng_event_field_value_real_create(double val);
159
160 LTTNG_HIDDEN
161 struct lttng_event_field_value *lttng_event_field_value_string_create(
162 const char *val);
163
164 LTTNG_HIDDEN
165 struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(
166 const char *val, size_t size);
167
168 LTTNG_HIDDEN
169 struct lttng_event_field_value *lttng_event_field_value_array_create(void);
170
171 LTTNG_HIDDEN
172 int lttng_event_field_value_enum_append_label(
173 struct lttng_event_field_value *field_val, const char *label);
174
175 LTTNG_HIDDEN
176 int lttng_event_field_value_enum_append_label_with_size(
177 struct lttng_event_field_value *field_val, const char *label,
178 size_t size);
179
180 LTTNG_HIDDEN
181 int lttng_event_field_value_array_append(
182 struct lttng_event_field_value *array_field_val,
183 struct lttng_event_field_value *field_val);
184
185 LTTNG_HIDDEN
186 int lttng_event_field_value_array_append_unavailable(
187 struct lttng_event_field_value *array_field_val);
188
189 LTTNG_HIDDEN
190 void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val);
191
192 #endif /* LTTNG_EVENT_FIELD_VALUE_INTERNAL_H */
This page took 0.033473 seconds and 5 git commands to generate.