Commit | Line | Data |
---|---|---|
f611d0c3 MD |
1 | // SPDX-License-Identifier: MIT |
2 | /* | |
3 | * Copyright 2022 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
4 | */ | |
5 | ||
6 | #include <stdint.h> | |
7 | #include <inttypes.h> | |
8 | #include <stdlib.h> | |
9 | #include <stdio.h> | |
4f40d951 | 10 | #include <stdbool.h> |
7a1cb105 | 11 | #include <stddef.h> |
f611d0c3 MD |
12 | |
13 | #include <side/trace.h> | |
14 | #include "tracer.h" | |
15 | ||
16 | /* User code example */ | |
17 | ||
89747802 | 18 | side_static_event(my_provider_event, "myprovider", "myevent", SIDE_LOGLEVEL_DEBUG, |
f611d0c3 | 19 | side_field_list( |
485b800a MD |
20 | side_field_u32("abc", side_attr_list()), |
21 | side_field_s64("def", side_attr_list()), | |
f5e650d7 | 22 | side_field_pointer("ptr", side_attr_list()), |
66de373e MD |
23 | side_field_dynamic("dynamic"), |
24 | side_field_dynamic("dynamic_pointer"), | |
9b641221 | 25 | side_field_null("null", side_attr_list()), |
399c836b MD |
26 | ), |
27 | side_attr_list() | |
f611d0c3 MD |
28 | ); |
29 | ||
30 | static | |
31 | void test_fields(void) | |
32 | { | |
33 | uint32_t uw = 42; | |
34 | int64_t sdw = -500; | |
35 | ||
f5e650d7 MD |
36 | side_event(my_provider_event, |
37 | side_arg_list( | |
38 | side_arg_u32(uw), | |
39 | side_arg_s64(sdw), | |
40 | side_arg_pointer((void *) 0x1), | |
66de373e MD |
41 | side_arg_dynamic_string("zzz", side_attr_list()), |
42 | side_arg_dynamic_pointer((void *) 0x1, side_attr_list()), | |
9b641221 | 43 | side_arg_null(), |
f5e650d7 MD |
44 | ) |
45 | ); | |
f611d0c3 MD |
46 | } |
47 | ||
89747802 MD |
48 | side_hidden_event(my_provider_event_hidden, "myprovider", "myeventhidden", SIDE_LOGLEVEL_DEBUG, |
49 | side_field_list( | |
50 | side_field_u32("abc", side_attr_list()), | |
51 | ), | |
52 | side_attr_list() | |
53 | ); | |
54 | ||
55 | static | |
56 | void test_event_hidden(void) | |
57 | { | |
89747802 MD |
58 | side_event(my_provider_event_hidden, side_arg_list(side_arg_u32(2))); |
59 | } | |
60 | ||
61 | side_declare_event(my_provider_event_export); | |
62 | ||
63 | side_export_event(my_provider_event_export, "myprovider", "myeventexport", SIDE_LOGLEVEL_DEBUG, | |
64 | side_field_list( | |
65 | side_field_u32("abc", side_attr_list()), | |
66 | ), | |
67 | side_attr_list() | |
68 | ); | |
69 | ||
70 | static | |
71 | void test_event_export(void) | |
72 | { | |
89747802 MD |
73 | side_event(my_provider_event_export, side_arg_list(side_arg_u32(2))); |
74 | } | |
75 | ||
76 | side_static_event(my_provider_event_struct_literal, "myprovider", "myeventstructliteral", SIDE_LOGLEVEL_DEBUG, | |
f611d0c3 | 77 | side_field_list( |
c7a14585 MD |
78 | side_field_struct("structliteral", |
79 | side_struct_literal( | |
80 | side_field_list( | |
81 | side_field_u32("x", side_attr_list()), | |
82 | side_field_s64("y", side_attr_list()), | |
83 | ), | |
84 | side_attr_list() | |
85 | ) | |
f611d0c3 | 86 | ), |
485b800a | 87 | side_field_u8("z", side_attr_list()), |
399c836b MD |
88 | ), |
89 | side_attr_list() | |
f611d0c3 MD |
90 | ); |
91 | ||
c7a14585 MD |
92 | static |
93 | void test_struct_literal(void) | |
94 | { | |
c7a14585 MD |
95 | side_event_cond(my_provider_event_struct_literal) { |
96 | side_arg_define_vec(mystruct, side_arg_list(side_arg_u32(21), side_arg_s64(22))); | |
97 | side_event_call(my_provider_event_struct_literal, side_arg_list(side_arg_struct(&mystruct), side_arg_u8(55))); | |
98 | } | |
99 | } | |
100 | ||
101 | static side_define_struct(mystructdef, | |
102 | side_field_list( | |
103 | side_field_u32("x", side_attr_list()), | |
104 | side_field_s64("y", side_attr_list()), | |
105 | ), | |
106 | side_attr_list() | |
107 | ); | |
108 | ||
89747802 | 109 | side_static_event(my_provider_event_struct, "myprovider", "myeventstruct", SIDE_LOGLEVEL_DEBUG, |
c7a14585 MD |
110 | side_field_list( |
111 | side_field_struct("struct", &mystructdef), | |
112 | side_field_u8("z", side_attr_list()), | |
113 | ), | |
114 | side_attr_list() | |
115 | ); | |
116 | ||
f611d0c3 MD |
117 | static |
118 | void test_struct(void) | |
119 | { | |
c7a14585 | 120 | side_event_cond(my_provider_event_struct) { |
f611d0c3 | 121 | side_arg_define_vec(mystruct, side_arg_list(side_arg_u32(21), side_arg_s64(22))); |
c7a14585 | 122 | side_event_call(my_provider_event_struct, side_arg_list(side_arg_struct(&mystruct), side_arg_u8(55))); |
f611d0c3 MD |
123 | } |
124 | } | |
125 | ||
89747802 | 126 | side_static_event(my_provider_event_array, "myprovider", "myarray", SIDE_LOGLEVEL_DEBUG, |
f611d0c3 | 127 | side_field_list( |
9a55f555 | 128 | side_field_array("arr", side_elem(side_type_u32(side_attr_list())), 3, side_attr_list()), |
485b800a | 129 | side_field_s64("v", side_attr_list()), |
399c836b MD |
130 | ), |
131 | side_attr_list() | |
f611d0c3 MD |
132 | ); |
133 | ||
134 | static | |
135 | void test_array(void) | |
136 | { | |
d5cdb129 | 137 | side_event_cond(my_provider_event_array) { |
f611d0c3 | 138 | side_arg_define_vec(myarray, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3))); |
d5cdb129 | 139 | side_event_call(my_provider_event_array, side_arg_list(side_arg_array(&myarray), side_arg_s64(42))); |
f611d0c3 MD |
140 | } |
141 | } | |
142 | ||
89747802 | 143 | side_static_event(my_provider_event_vla, "myprovider", "myvla", SIDE_LOGLEVEL_DEBUG, |
f611d0c3 | 144 | side_field_list( |
9a55f555 | 145 | side_field_vla("vla", side_elem(side_type_u32(side_attr_list())), side_attr_list()), |
485b800a | 146 | side_field_s64("v", side_attr_list()), |
399c836b MD |
147 | ), |
148 | side_attr_list() | |
f611d0c3 MD |
149 | ); |
150 | ||
151 | static | |
152 | void test_vla(void) | |
153 | { | |
d5cdb129 | 154 | side_event_cond(my_provider_event_vla) { |
f611d0c3 | 155 | side_arg_define_vec(myvla, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3))); |
d5cdb129 | 156 | side_event_call(my_provider_event_vla, side_arg_list(side_arg_vla(&myvla), side_arg_s64(42))); |
f611d0c3 MD |
157 | } |
158 | } | |
159 | ||
cdd6e858 MD |
160 | /* 1D array visitor */ |
161 | ||
f611d0c3 MD |
162 | struct app_visitor_ctx { |
163 | const uint32_t *ptr; | |
352a4b77 | 164 | uint32_t length; |
f611d0c3 MD |
165 | }; |
166 | ||
352a4b77 MD |
167 | static |
168 | enum side_visitor_status test_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) | |
f611d0c3 MD |
169 | { |
170 | struct app_visitor_ctx *ctx = (struct app_visitor_ctx *) _ctx; | |
352a4b77 MD |
171 | uint32_t length = ctx->length, i; |
172 | ||
173 | for (i = 0; i < length; i++) { | |
66de373e | 174 | const struct side_arg elem = side_arg_u32(ctx->ptr[i]); |
ffb5c809 | 175 | |
db6ecef9 MD |
176 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
177 | return SIDE_VISITOR_STATUS_ERROR; | |
352a4b77 | 178 | } |
f611d0c3 MD |
179 | return SIDE_VISITOR_STATUS_OK; |
180 | } | |
181 | ||
182 | static uint32_t testarray[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | |
183 | ||
89747802 | 184 | side_static_event(my_provider_event_vla_visitor, "myprovider", "myvlavisit", SIDE_LOGLEVEL_DEBUG, |
f611d0c3 | 185 | side_field_list( |
9a55f555 | 186 | side_field_vla_visitor("vlavisit", side_elem(side_type_u32(side_attr_list())), test_visitor, side_attr_list()), |
485b800a | 187 | side_field_s64("v", side_attr_list()), |
399c836b MD |
188 | ), |
189 | side_attr_list() | |
f611d0c3 MD |
190 | ); |
191 | ||
192 | static | |
193 | void test_vla_visitor(void) | |
194 | { | |
d5cdb129 | 195 | side_event_cond(my_provider_event_vla_visitor) { |
f611d0c3 MD |
196 | struct app_visitor_ctx ctx = { |
197 | .ptr = testarray, | |
352a4b77 | 198 | .length = SIDE_ARRAY_SIZE(testarray), |
f611d0c3 | 199 | }; |
d5cdb129 | 200 | side_event_call(my_provider_event_vla_visitor, side_arg_list(side_arg_vla_visitor(&ctx), side_arg_s64(42))); |
f611d0c3 MD |
201 | } |
202 | } | |
203 | ||
cdd6e858 MD |
204 | /* 2D array visitor */ |
205 | ||
206 | struct app_visitor_2d_inner_ctx { | |
207 | const uint32_t *ptr; | |
208 | uint32_t length; | |
209 | }; | |
210 | ||
211 | static | |
212 | enum side_visitor_status test_inner_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) | |
213 | { | |
214 | struct app_visitor_2d_inner_ctx *ctx = (struct app_visitor_2d_inner_ctx *) _ctx; | |
215 | uint32_t length = ctx->length, i; | |
216 | ||
217 | for (i = 0; i < length; i++) { | |
66de373e | 218 | const struct side_arg elem = side_arg_u32(ctx->ptr[i]); |
ffb5c809 | 219 | |
db6ecef9 MD |
220 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
221 | return SIDE_VISITOR_STATUS_ERROR; | |
cdd6e858 MD |
222 | } |
223 | return SIDE_VISITOR_STATUS_OK; | |
224 | } | |
225 | ||
226 | struct app_visitor_2d_outer_ctx { | |
227 | const uint32_t (*ptr)[2]; | |
228 | uint32_t length; | |
229 | }; | |
230 | ||
231 | static | |
232 | enum side_visitor_status test_outer_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) | |
233 | { | |
234 | struct app_visitor_2d_outer_ctx *ctx = (struct app_visitor_2d_outer_ctx *) _ctx; | |
235 | uint32_t length = ctx->length, i; | |
236 | ||
237 | for (i = 0; i < length; i++) { | |
238 | struct app_visitor_2d_inner_ctx inner_ctx = { | |
239 | .ptr = ctx->ptr[i], | |
240 | .length = 2, | |
241 | }; | |
66de373e | 242 | const struct side_arg elem = side_arg_vla_visitor(&inner_ctx); |
db6ecef9 MD |
243 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
244 | return SIDE_VISITOR_STATUS_ERROR; | |
cdd6e858 MD |
245 | } |
246 | return SIDE_VISITOR_STATUS_OK; | |
247 | } | |
248 | ||
249 | static uint32_t testarray2d[][2] = { | |
250 | { 1, 2 }, | |
251 | { 33, 44 }, | |
252 | { 55, 66 }, | |
253 | }; | |
254 | ||
89747802 | 255 | side_static_event(my_provider_event_vla_visitor2d, "myprovider", "myvlavisit2d", SIDE_LOGLEVEL_DEBUG, |
cdd6e858 MD |
256 | side_field_list( |
257 | side_field_vla_visitor("vlavisit2d", | |
f37a556f | 258 | side_elem( |
32ba58fc | 259 | side_type_vla_visitor( |
9a55f555 | 260 | side_elem(side_type_u32(side_attr_list())), |
f37a556f MD |
261 | test_inner_visitor, |
262 | side_attr_list()) | |
263 | ), test_outer_visitor, side_attr_list()), | |
485b800a | 264 | side_field_s64("v", side_attr_list()), |
399c836b MD |
265 | ), |
266 | side_attr_list() | |
cdd6e858 MD |
267 | ); |
268 | ||
269 | static | |
270 | void test_vla_visitor_2d(void) | |
271 | { | |
d5cdb129 | 272 | side_event_cond(my_provider_event_vla_visitor2d) { |
cdd6e858 MD |
273 | struct app_visitor_2d_outer_ctx ctx = { |
274 | .ptr = testarray2d, | |
275 | .length = SIDE_ARRAY_SIZE(testarray2d), | |
276 | }; | |
d5cdb129 | 277 | side_event_call(my_provider_event_vla_visitor2d, side_arg_list(side_arg_vla_visitor(&ctx), side_arg_s64(42))); |
cdd6e858 MD |
278 | } |
279 | } | |
280 | ||
89747802 | 281 | side_static_event(my_provider_event_dynamic_basic, |
a2e2357e MD |
282 | "myprovider", "mydynamicbasic", SIDE_LOGLEVEL_DEBUG, |
283 | side_field_list( | |
66de373e | 284 | side_field_dynamic("dynamic"), |
399c836b MD |
285 | ), |
286 | side_attr_list() | |
a2e2357e MD |
287 | ); |
288 | ||
289 | static | |
290 | void test_dynamic_basic_type(void) | |
291 | { | |
d5cdb129 | 292 | side_event(my_provider_event_dynamic_basic, |
66de373e | 293 | side_arg_list(side_arg_dynamic_s16(-33, side_attr_list()))); |
a2e2357e MD |
294 | } |
295 | ||
89747802 | 296 | side_static_event(my_provider_event_dynamic_vla, |
a2e2357e MD |
297 | "myprovider", "mydynamicvla", SIDE_LOGLEVEL_DEBUG, |
298 | side_field_list( | |
66de373e | 299 | side_field_dynamic("dynamic"), |
399c836b MD |
300 | ), |
301 | side_attr_list() | |
a2e2357e MD |
302 | ); |
303 | ||
304 | static | |
305 | void test_dynamic_vla(void) | |
306 | { | |
948e3e72 MD |
307 | side_arg_dynamic_define_vec(myvla, |
308 | side_arg_list( | |
808bd9bf MD |
309 | side_arg_dynamic_u32(1, side_attr_list()), |
310 | side_arg_dynamic_u32(2, side_attr_list()), | |
311 | side_arg_dynamic_u32(3, side_attr_list()), | |
8d20e708 MD |
312 | ), |
313 | side_attr_list() | |
df075fa5 | 314 | ); |
d5cdb129 | 315 | side_event(my_provider_event_dynamic_vla, |
66de373e | 316 | side_arg_list(side_arg_dynamic_vla(&myvla))); |
a2e2357e MD |
317 | } |
318 | ||
89747802 | 319 | side_static_event(my_provider_event_dynamic_null, |
465e5e7e MD |
320 | "myprovider", "mydynamicnull", SIDE_LOGLEVEL_DEBUG, |
321 | side_field_list( | |
66de373e | 322 | side_field_dynamic("dynamic"), |
399c836b MD |
323 | ), |
324 | side_attr_list() | |
465e5e7e MD |
325 | ); |
326 | ||
327 | static | |
328 | void test_dynamic_null(void) | |
329 | { | |
d5cdb129 | 330 | side_event(my_provider_event_dynamic_null, |
66de373e | 331 | side_arg_list(side_arg_dynamic_null(side_attr_list()))); |
465e5e7e MD |
332 | } |
333 | ||
89747802 | 334 | side_static_event(my_provider_event_dynamic_struct, |
c208889e | 335 | "myprovider", "mydynamicstruct", SIDE_LOGLEVEL_DEBUG, |
465e5e7e | 336 | side_field_list( |
66de373e | 337 | side_field_dynamic("dynamic"), |
399c836b MD |
338 | ), |
339 | side_attr_list() | |
465e5e7e MD |
340 | ); |
341 | ||
342 | static | |
c208889e | 343 | void test_dynamic_struct(void) |
465e5e7e | 344 | { |
c208889e | 345 | side_arg_dynamic_define_struct(mystruct, |
465e5e7e | 346 | side_arg_list( |
808bd9bf MD |
347 | side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())), |
348 | side_arg_dynamic_field("b", side_arg_dynamic_string("zzz", side_attr_list())), | |
349 | side_arg_dynamic_field("c", side_arg_dynamic_null(side_attr_list())), | |
8d20e708 MD |
350 | ), |
351 | side_attr_list() | |
465e5e7e MD |
352 | ); |
353 | ||
d5cdb129 | 354 | side_event(my_provider_event_dynamic_struct, |
66de373e | 355 | side_arg_list(side_arg_dynamic_struct(&mystruct))); |
465e5e7e MD |
356 | } |
357 | ||
89747802 | 358 | side_static_event(my_provider_event_dynamic_nested_struct, |
c208889e | 359 | "myprovider", "mydynamicnestedstruct", SIDE_LOGLEVEL_DEBUG, |
3222d397 | 360 | side_field_list( |
66de373e | 361 | side_field_dynamic("dynamic"), |
399c836b MD |
362 | ), |
363 | side_attr_list() | |
3222d397 MD |
364 | ); |
365 | ||
366 | static | |
c208889e | 367 | void test_dynamic_nested_struct(void) |
3222d397 | 368 | { |
c208889e | 369 | side_arg_dynamic_define_struct(nested, |
3222d397 | 370 | side_arg_list( |
808bd9bf MD |
371 | side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())), |
372 | side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())), | |
8d20e708 MD |
373 | ), |
374 | side_attr_list() | |
3222d397 | 375 | ); |
c208889e | 376 | side_arg_dynamic_define_struct(nested2, |
3222d397 | 377 | side_arg_list( |
808bd9bf MD |
378 | side_arg_dynamic_field("aa", side_arg_dynamic_u64(128, side_attr_list())), |
379 | side_arg_dynamic_field("bb", side_arg_dynamic_u16(1, side_attr_list())), | |
8d20e708 MD |
380 | ), |
381 | side_attr_list() | |
3222d397 | 382 | ); |
c208889e | 383 | side_arg_dynamic_define_struct(mystruct, |
3222d397 | 384 | side_arg_list( |
8d20e708 MD |
385 | side_arg_dynamic_field("nested", side_arg_dynamic_struct(&nested)), |
386 | side_arg_dynamic_field("nested2", side_arg_dynamic_struct(&nested2)), | |
387 | ), | |
388 | side_attr_list() | |
3222d397 | 389 | ); |
d5cdb129 | 390 | side_event(my_provider_event_dynamic_nested_struct, |
66de373e | 391 | side_arg_list(side_arg_dynamic_struct(&mystruct))); |
3222d397 MD |
392 | } |
393 | ||
89747802 | 394 | side_static_event(my_provider_event_dynamic_vla_struct, |
c208889e | 395 | "myprovider", "mydynamicvlastruct", SIDE_LOGLEVEL_DEBUG, |
7ce1b78f | 396 | side_field_list( |
66de373e | 397 | side_field_dynamic("dynamic"), |
399c836b MD |
398 | ), |
399 | side_attr_list() | |
7ce1b78f MD |
400 | ); |
401 | ||
402 | static | |
c208889e | 403 | void test_dynamic_vla_struct(void) |
7ce1b78f | 404 | { |
c208889e | 405 | side_arg_dynamic_define_struct(nested, |
7ce1b78f | 406 | side_arg_list( |
808bd9bf MD |
407 | side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())), |
408 | side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())), | |
8d20e708 MD |
409 | ), |
410 | side_attr_list() | |
7ce1b78f MD |
411 | ); |
412 | side_arg_dynamic_define_vec(myvla, | |
413 | side_arg_list( | |
8d20e708 MD |
414 | side_arg_dynamic_struct(&nested), |
415 | side_arg_dynamic_struct(&nested), | |
416 | side_arg_dynamic_struct(&nested), | |
417 | side_arg_dynamic_struct(&nested), | |
418 | ), | |
419 | side_attr_list() | |
7ce1b78f | 420 | ); |
d5cdb129 | 421 | side_event(my_provider_event_dynamic_vla_struct, |
66de373e | 422 | side_arg_list(side_arg_dynamic_vla(&myvla))); |
7ce1b78f MD |
423 | } |
424 | ||
89747802 | 425 | side_static_event(my_provider_event_dynamic_struct_vla, |
c208889e | 426 | "myprovider", "mydynamicstructvla", SIDE_LOGLEVEL_DEBUG, |
980bfdc4 | 427 | side_field_list( |
66de373e | 428 | side_field_dynamic("dynamic"), |
399c836b MD |
429 | ), |
430 | side_attr_list() | |
980bfdc4 MD |
431 | ); |
432 | ||
433 | static | |
c208889e | 434 | void test_dynamic_struct_vla(void) |
980bfdc4 MD |
435 | { |
436 | side_arg_dynamic_define_vec(myvla, | |
948e3e72 | 437 | side_arg_list( |
808bd9bf MD |
438 | side_arg_dynamic_u32(1, side_attr_list()), |
439 | side_arg_dynamic_u32(2, side_attr_list()), | |
440 | side_arg_dynamic_u32(3, side_attr_list()), | |
8d20e708 MD |
441 | ), |
442 | side_attr_list() | |
df075fa5 | 443 | ); |
980bfdc4 | 444 | side_arg_dynamic_define_vec(myvla2, |
948e3e72 | 445 | side_arg_list( |
808bd9bf MD |
446 | side_arg_dynamic_u32(4, side_attr_list()), |
447 | side_arg_dynamic_u64(5, side_attr_list()), | |
448 | side_arg_dynamic_u32(6, side_attr_list()), | |
8d20e708 MD |
449 | ), |
450 | side_attr_list() | |
df075fa5 | 451 | ); |
c208889e | 452 | side_arg_dynamic_define_struct(mystruct, |
980bfdc4 | 453 | side_arg_list( |
8d20e708 MD |
454 | side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla)), |
455 | side_arg_dynamic_field("b", side_arg_dynamic_vla(&myvla2)), | |
456 | ), | |
457 | side_attr_list() | |
980bfdc4 | 458 | ); |
d5cdb129 | 459 | side_event(my_provider_event_dynamic_struct_vla, |
66de373e | 460 | side_arg_list(side_arg_dynamic_struct(&mystruct))); |
980bfdc4 MD |
461 | } |
462 | ||
89747802 | 463 | side_static_event(my_provider_event_dynamic_nested_vla, |
948e3e72 MD |
464 | "myprovider", "mydynamicnestedvla", SIDE_LOGLEVEL_DEBUG, |
465 | side_field_list( | |
66de373e | 466 | side_field_dynamic("dynamic"), |
399c836b MD |
467 | ), |
468 | side_attr_list() | |
948e3e72 MD |
469 | ); |
470 | ||
471 | static | |
472 | void test_dynamic_nested_vla(void) | |
473 | { | |
474 | side_arg_dynamic_define_vec(nestedvla, | |
475 | side_arg_list( | |
808bd9bf MD |
476 | side_arg_dynamic_u32(1, side_attr_list()), |
477 | side_arg_dynamic_u16(2, side_attr_list()), | |
478 | side_arg_dynamic_u32(3, side_attr_list()), | |
8d20e708 MD |
479 | ), |
480 | side_attr_list() | |
948e3e72 MD |
481 | ); |
482 | side_arg_dynamic_define_vec(nestedvla2, | |
483 | side_arg_list( | |
808bd9bf MD |
484 | side_arg_dynamic_u8(4, side_attr_list()), |
485 | side_arg_dynamic_u32(5, side_attr_list()), | |
486 | side_arg_dynamic_u32(6, side_attr_list()), | |
8d20e708 MD |
487 | ), |
488 | side_attr_list() | |
948e3e72 MD |
489 | ); |
490 | side_arg_dynamic_define_vec(myvla, | |
491 | side_arg_list( | |
8d20e708 MD |
492 | side_arg_dynamic_vla(&nestedvla), |
493 | side_arg_dynamic_vla(&nestedvla2), | |
494 | ), | |
495 | side_attr_list() | |
948e3e72 | 496 | ); |
d5cdb129 | 497 | side_event(my_provider_event_dynamic_nested_vla, |
66de373e | 498 | side_arg_list(side_arg_dynamic_vla(&myvla))); |
948e3e72 MD |
499 | } |
500 | ||
89747802 | 501 | side_static_event_variadic(my_provider_event_variadic, |
19fa6aa2 | 502 | "myprovider", "myvariadicevent", SIDE_LOGLEVEL_DEBUG, |
399c836b MD |
503 | side_field_list(), |
504 | side_attr_list() | |
19fa6aa2 MD |
505 | ); |
506 | ||
507 | static | |
508 | void test_variadic(void) | |
509 | { | |
d5cdb129 | 510 | side_event_variadic(my_provider_event_variadic, |
19fa6aa2 MD |
511 | side_arg_list(), |
512 | side_arg_list( | |
808bd9bf MD |
513 | side_arg_dynamic_field("a", side_arg_dynamic_u32(55, side_attr_list())), |
514 | side_arg_dynamic_field("b", side_arg_dynamic_s8(-4, side_attr_list())), | |
8d20e708 MD |
515 | ), |
516 | side_attr_list() | |
19fa6aa2 MD |
517 | ); |
518 | } | |
519 | ||
89747802 | 520 | side_static_event_variadic(my_provider_event_static_variadic, |
41c4d119 MD |
521 | "myprovider", "mystaticvariadicevent", SIDE_LOGLEVEL_DEBUG, |
522 | side_field_list( | |
485b800a MD |
523 | side_field_u32("abc", side_attr_list()), |
524 | side_field_u16("def", side_attr_list()), | |
399c836b MD |
525 | ), |
526 | side_attr_list() | |
41c4d119 MD |
527 | ); |
528 | ||
529 | static | |
530 | void test_static_variadic(void) | |
531 | { | |
d5cdb129 | 532 | side_event_variadic(my_provider_event_static_variadic, |
41c4d119 MD |
533 | side_arg_list( |
534 | side_arg_u32(1), | |
535 | side_arg_u16(2), | |
536 | ), | |
537 | side_arg_list( | |
808bd9bf MD |
538 | side_arg_dynamic_field("a", side_arg_dynamic_u32(55, side_attr_list())), |
539 | side_arg_dynamic_field("b", side_arg_dynamic_s8(-4, side_attr_list())), | |
8d20e708 MD |
540 | ), |
541 | side_attr_list() | |
41c4d119 MD |
542 | ); |
543 | } | |
544 | ||
89747802 | 545 | side_static_event(my_provider_event_bool, "myprovider", "myeventbool", SIDE_LOGLEVEL_DEBUG, |
4f40d951 | 546 | side_field_list( |
485b800a MD |
547 | side_field_bool("a_false", side_attr_list()), |
548 | side_field_bool("b_true", side_attr_list()), | |
549 | side_field_bool("c_true", side_attr_list()), | |
550 | side_field_bool("d_true", side_attr_list()), | |
551 | side_field_bool("e_true", side_attr_list()), | |
552 | side_field_bool("f_false", side_attr_list()), | |
553 | side_field_bool("g_true", side_attr_list()), | |
399c836b MD |
554 | ), |
555 | side_attr_list() | |
4f40d951 MD |
556 | ); |
557 | ||
558 | static | |
559 | void test_bool(void) | |
560 | { | |
561 | uint32_t a = 0; | |
562 | uint32_t b = 1; | |
563 | uint64_t c = 0x12345678; | |
564 | int16_t d = -32768; | |
565 | bool e = true; | |
566 | bool f = false; | |
567 | uint32_t g = 256; | |
568 | ||
d5cdb129 | 569 | side_event(my_provider_event_bool, |
4f40d951 MD |
570 | side_arg_list( |
571 | side_arg_bool(a), | |
572 | side_arg_bool(b), | |
573 | side_arg_bool(c), | |
574 | side_arg_bool(d), | |
575 | side_arg_bool(e), | |
576 | side_arg_bool(f), | |
577 | side_arg_bool(g), | |
578 | ) | |
579 | ); | |
580 | } | |
581 | ||
89747802 | 582 | side_static_event_variadic(my_provider_event_dynamic_bool, |
4f40d951 | 583 | "myprovider", "mydynamicbool", SIDE_LOGLEVEL_DEBUG, |
399c836b MD |
584 | side_field_list(), |
585 | side_attr_list() | |
4f40d951 MD |
586 | ); |
587 | ||
588 | static | |
589 | void test_dynamic_bool(void) | |
590 | { | |
d5cdb129 | 591 | side_event_variadic(my_provider_event_dynamic_bool, |
4f40d951 MD |
592 | side_arg_list(), |
593 | side_arg_list( | |
808bd9bf MD |
594 | side_arg_dynamic_field("a_true", side_arg_dynamic_bool(55, side_attr_list())), |
595 | side_arg_dynamic_field("b_true", side_arg_dynamic_bool(-4, side_attr_list())), | |
596 | side_arg_dynamic_field("c_false", side_arg_dynamic_bool(0, side_attr_list())), | |
597 | side_arg_dynamic_field("d_true", side_arg_dynamic_bool(256, side_attr_list())), | |
8d20e708 MD |
598 | ), |
599 | side_attr_list() | |
4f40d951 MD |
600 | ); |
601 | } | |
602 | ||
89747802 | 603 | side_static_event(my_provider_event_dynamic_vla_visitor, |
8ceca0cd MD |
604 | "myprovider", "mydynamicvlavisitor", SIDE_LOGLEVEL_DEBUG, |
605 | side_field_list( | |
66de373e | 606 | side_field_dynamic("dynamic"), |
399c836b MD |
607 | ), |
608 | side_attr_list() | |
8ceca0cd MD |
609 | ); |
610 | ||
611 | struct app_dynamic_vla_visitor_ctx { | |
612 | const uint32_t *ptr; | |
613 | uint32_t length; | |
614 | }; | |
615 | ||
616 | static | |
6a744a79 | 617 | enum side_visitor_status test_dynamic_vla_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) |
8ceca0cd MD |
618 | { |
619 | struct app_dynamic_vla_visitor_ctx *ctx = (struct app_dynamic_vla_visitor_ctx *) _ctx; | |
620 | uint32_t length = ctx->length, i; | |
621 | ||
622 | for (i = 0; i < length; i++) { | |
e623c6a0 | 623 | const struct side_arg elem = side_arg_dynamic_u32(ctx->ptr[i], side_attr_list()); |
8ceca0cd MD |
624 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
625 | return SIDE_VISITOR_STATUS_ERROR; | |
626 | } | |
627 | return SIDE_VISITOR_STATUS_OK; | |
628 | } | |
629 | ||
630 | static uint32_t testarray_dynamic_vla[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | |
631 | ||
632 | static | |
633 | void test_dynamic_vla_with_visitor(void) | |
634 | { | |
d5cdb129 | 635 | side_event_cond(my_provider_event_dynamic_vla_visitor) { |
8ceca0cd MD |
636 | struct app_dynamic_vla_visitor_ctx ctx = { |
637 | .ptr = testarray_dynamic_vla, | |
638 | .length = SIDE_ARRAY_SIZE(testarray_dynamic_vla), | |
639 | }; | |
d5cdb129 | 640 | side_event_call(my_provider_event_dynamic_vla_visitor, |
8ceca0cd | 641 | side_arg_list( |
66de373e | 642 | side_arg_dynamic_vla_visitor(test_dynamic_vla_visitor, &ctx, side_attr_list()) |
8ceca0cd MD |
643 | ) |
644 | ); | |
645 | } | |
646 | } | |
647 | ||
89747802 | 648 | side_static_event(my_provider_event_dynamic_struct_visitor, |
2b359235 MD |
649 | "myprovider", "mydynamicstructvisitor", SIDE_LOGLEVEL_DEBUG, |
650 | side_field_list( | |
66de373e | 651 | side_field_dynamic("dynamic"), |
399c836b MD |
652 | ), |
653 | side_attr_list() | |
2b359235 MD |
654 | ); |
655 | ||
656 | struct struct_visitor_pair { | |
657 | const char *name; | |
658 | uint32_t value; | |
659 | }; | |
660 | ||
661 | struct app_dynamic_struct_visitor_ctx { | |
662 | const struct struct_visitor_pair *ptr; | |
663 | uint32_t length; | |
664 | }; | |
665 | ||
666 | static | |
667 | enum side_visitor_status test_dynamic_struct_visitor(const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx, void *_ctx) | |
668 | { | |
669 | struct app_dynamic_struct_visitor_ctx *ctx = (struct app_dynamic_struct_visitor_ctx *) _ctx; | |
670 | uint32_t length = ctx->length, i; | |
671 | ||
672 | for (i = 0; i < length; i++) { | |
0c7abe2b | 673 | struct side_arg_dynamic_field dynamic_field = { |
2b359235 | 674 | .field_name = ctx->ptr[i].name, |
e623c6a0 | 675 | .elem = side_arg_dynamic_u32(ctx->ptr[i].value, side_attr_list()), |
2b359235 MD |
676 | }; |
677 | if (tracer_ctx->write_field(tracer_ctx, &dynamic_field) != SIDE_VISITOR_STATUS_OK) | |
678 | return SIDE_VISITOR_STATUS_ERROR; | |
679 | } | |
680 | return SIDE_VISITOR_STATUS_OK; | |
681 | } | |
682 | ||
683 | static struct struct_visitor_pair testarray_dynamic_struct[] = { | |
684 | { "a", 1, }, | |
685 | { "b", 2, }, | |
686 | { "c", 3, }, | |
687 | { "d", 4, }, | |
688 | }; | |
689 | ||
690 | static | |
691 | void test_dynamic_struct_with_visitor(void) | |
692 | { | |
d5cdb129 | 693 | side_event_cond(my_provider_event_dynamic_struct_visitor) { |
2b359235 MD |
694 | struct app_dynamic_struct_visitor_ctx ctx = { |
695 | .ptr = testarray_dynamic_struct, | |
696 | .length = SIDE_ARRAY_SIZE(testarray_dynamic_struct), | |
697 | }; | |
d5cdb129 | 698 | side_event_call(my_provider_event_dynamic_struct_visitor, |
2b359235 | 699 | side_arg_list( |
66de373e | 700 | side_arg_dynamic_struct_visitor(test_dynamic_struct_visitor, &ctx, side_attr_list()) |
2b359235 MD |
701 | ) |
702 | ); | |
703 | } | |
704 | } | |
705 | ||
89747802 | 706 | side_static_event(my_provider_event_user_attribute, "myprovider", "myevent_user_attribute", SIDE_LOGLEVEL_DEBUG, |
65010f43 | 707 | side_field_list( |
485b800a MD |
708 | side_field_u32("abc", side_attr_list()), |
709 | side_field_s64("def", side_attr_list()), | |
399c836b MD |
710 | ), |
711 | side_attr_list( | |
bc3c89b3 MD |
712 | side_attr("user_attribute_a", side_attr_string("val1")), |
713 | side_attr("user_attribute_b", side_attr_string("val2")), | |
65010f43 MD |
714 | ) |
715 | ); | |
716 | ||
717 | static | |
718 | void test_event_user_attribute(void) | |
719 | { | |
d5cdb129 | 720 | side_event(my_provider_event_user_attribute, side_arg_list(side_arg_u32(1), side_arg_s64(2))); |
65010f43 MD |
721 | } |
722 | ||
89747802 | 723 | side_static_event(my_provider_field_user_attribute, "myprovider", "myevent_field_attribute", SIDE_LOGLEVEL_DEBUG, |
a848763d | 724 | side_field_list( |
485b800a | 725 | side_field_u32("abc", |
a848763d | 726 | side_attr_list( |
bc3c89b3 MD |
727 | side_attr("user_attribute_a", side_attr_string("val1")), |
728 | side_attr("user_attribute_b", side_attr_u32(2)), | |
a848763d MD |
729 | ) |
730 | ), | |
485b800a | 731 | side_field_s64("def", |
a848763d | 732 | side_attr_list( |
bc3c89b3 MD |
733 | side_attr("user_attribute_c", side_attr_string("val3")), |
734 | side_attr("user_attribute_d", side_attr_s64(-5)), | |
a848763d MD |
735 | ) |
736 | ), | |
737 | ), | |
738 | side_attr_list() | |
739 | ); | |
740 | ||
741 | static | |
742 | void test_field_user_attribute(void) | |
743 | { | |
d5cdb129 | 744 | side_event(my_provider_field_user_attribute, side_arg_list(side_arg_u32(1), side_arg_s64(2))); |
a848763d MD |
745 | } |
746 | ||
89747802 | 747 | side_static_event_variadic(my_provider_event_variadic_attr, |
808bd9bf MD |
748 | "myprovider", "myvariadiceventattr", SIDE_LOGLEVEL_DEBUG, |
749 | side_field_list(), | |
750 | side_attr_list() | |
751 | ); | |
752 | ||
753 | static | |
754 | void test_variadic_attr(void) | |
755 | { | |
d5cdb129 | 756 | side_event_variadic(my_provider_event_variadic_attr, |
808bd9bf MD |
757 | side_arg_list(), |
758 | side_arg_list( | |
759 | side_arg_dynamic_field("a", | |
760 | side_arg_dynamic_u32(55, | |
761 | side_attr_list( | |
bc3c89b3 MD |
762 | side_attr("user_attribute_c", side_attr_string("valX")), |
763 | side_attr("user_attribute_d", side_attr_u8(55)), | |
808bd9bf MD |
764 | ) |
765 | ) | |
766 | ), | |
767 | side_arg_dynamic_field("b", | |
768 | side_arg_dynamic_s8(-4, | |
769 | side_attr_list( | |
bc3c89b3 MD |
770 | side_attr("X", side_attr_u8(1)), |
771 | side_attr("Y", side_attr_s8(2)), | |
808bd9bf MD |
772 | ) |
773 | ) | |
774 | ), | |
8d20e708 MD |
775 | ), |
776 | side_attr_list() | |
808bd9bf MD |
777 | ); |
778 | } | |
779 | ||
89747802 | 780 | side_static_event_variadic(my_provider_event_variadic_vla_attr, |
808bd9bf MD |
781 | "myprovider", "myvariadiceventvlaattr", SIDE_LOGLEVEL_DEBUG, |
782 | side_field_list(), | |
783 | side_attr_list() | |
784 | ); | |
785 | ||
786 | static | |
787 | void test_variadic_vla_attr(void) | |
788 | { | |
789 | side_arg_dynamic_define_vec(myvla, | |
790 | side_arg_list( | |
791 | side_arg_dynamic_u32(1, | |
792 | side_attr_list( | |
bc3c89b3 MD |
793 | side_attr("Z", side_attr_u8(0)), |
794 | side_attr("A", side_attr_u8(123)), | |
808bd9bf MD |
795 | ) |
796 | ), | |
797 | side_arg_dynamic_u32(2, side_attr_list()), | |
798 | side_arg_dynamic_u32(3, side_attr_list()), | |
8d20e708 MD |
799 | ), |
800 | side_attr_list( | |
801 | side_attr("X", side_attr_u8(1)), | |
802 | side_attr("Y", side_attr_u8(2)), | |
808bd9bf MD |
803 | ) |
804 | ); | |
d5cdb129 | 805 | side_event_variadic(my_provider_event_variadic_vla_attr, |
808bd9bf MD |
806 | side_arg_list(), |
807 | side_arg_list( | |
8d20e708 MD |
808 | side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla)), |
809 | ), | |
810 | side_attr_list() | |
808bd9bf MD |
811 | ); |
812 | } | |
813 | ||
89747802 | 814 | side_static_event_variadic(my_provider_event_variadic_struct_attr, |
808bd9bf MD |
815 | "myprovider", "myvariadiceventstructattr", SIDE_LOGLEVEL_DEBUG, |
816 | side_field_list(), | |
817 | side_attr_list() | |
818 | ); | |
819 | ||
820 | static | |
821 | void test_variadic_struct_attr(void) | |
822 | { | |
d5cdb129 | 823 | side_event_cond(my_provider_event_variadic_struct_attr) { |
808bd9bf MD |
824 | side_arg_dynamic_define_struct(mystruct, |
825 | side_arg_list( | |
826 | side_arg_dynamic_field("a", | |
827 | side_arg_dynamic_u32(43, | |
828 | side_attr_list( | |
bc3c89b3 | 829 | side_attr("A", side_attr_bool(true)), |
808bd9bf MD |
830 | ) |
831 | ) | |
832 | ), | |
833 | side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())), | |
8d20e708 MD |
834 | ), |
835 | side_attr_list( | |
836 | side_attr("X", side_attr_u8(1)), | |
837 | side_attr("Y", side_attr_u8(2)), | |
808bd9bf MD |
838 | ) |
839 | ); | |
d5cdb129 | 840 | side_event_call_variadic(my_provider_event_variadic_struct_attr, |
808bd9bf MD |
841 | side_arg_list(), |
842 | side_arg_list( | |
8d20e708 MD |
843 | side_arg_dynamic_field("a", side_arg_dynamic_struct(&mystruct)), |
844 | ), | |
845 | side_attr_list() | |
808bd9bf MD |
846 | ); |
847 | } | |
848 | } | |
849 | ||
89747802 | 850 | side_static_event(my_provider_event_float, "myprovider", "myeventfloat", SIDE_LOGLEVEL_DEBUG, |
fb25b355 MD |
851 | side_field_list( |
852 | #if __HAVE_FLOAT16 | |
485b800a | 853 | side_field_float_binary16("binary16", side_attr_list()), |
8bdd5c12 MD |
854 | side_field_float_binary16_le("binary16_le", side_attr_list()), |
855 | side_field_float_binary16_be("binary16_be", side_attr_list()), | |
fb25b355 MD |
856 | #endif |
857 | #if __HAVE_FLOAT32 | |
485b800a | 858 | side_field_float_binary32("binary32", side_attr_list()), |
8bdd5c12 MD |
859 | side_field_float_binary32_le("binary32_le", side_attr_list()), |
860 | side_field_float_binary32_be("binary32_be", side_attr_list()), | |
fb25b355 MD |
861 | #endif |
862 | #if __HAVE_FLOAT64 | |
485b800a | 863 | side_field_float_binary64("binary64", side_attr_list()), |
8bdd5c12 MD |
864 | side_field_float_binary64_le("binary64_le", side_attr_list()), |
865 | side_field_float_binary64_be("binary64_be", side_attr_list()), | |
fb25b355 MD |
866 | #endif |
867 | #if __HAVE_FLOAT128 | |
485b800a | 868 | side_field_float_binary128("binary128", side_attr_list()), |
8bdd5c12 MD |
869 | side_field_float_binary128_le("binary128_le", side_attr_list()), |
870 | side_field_float_binary128_be("binary128_be", side_attr_list()), | |
fb25b355 MD |
871 | #endif |
872 | ), | |
873 | side_attr_list() | |
874 | ); | |
875 | ||
876 | static | |
877 | void test_float(void) | |
878 | { | |
8bdd5c12 MD |
879 | #if __HAVE_FLOAT16 |
880 | union { | |
881 | _Float16 f; | |
882 | uint16_t u; | |
883 | } float16 = { | |
884 | .f = 1.1, | |
885 | }; | |
886 | #endif | |
887 | #if __HAVE_FLOAT32 | |
888 | union { | |
889 | _Float32 f; | |
890 | uint32_t u; | |
891 | } float32 = { | |
892 | .f = 2.2, | |
893 | }; | |
894 | #endif | |
895 | #if __HAVE_FLOAT64 | |
896 | union { | |
897 | _Float64 f; | |
898 | uint64_t u; | |
899 | } float64 = { | |
900 | .f = 3.3, | |
901 | }; | |
902 | #endif | |
903 | #if __HAVE_FLOAT128 | |
904 | union { | |
905 | _Float128 f; | |
906 | char arr[16]; | |
907 | } float128 = { | |
908 | .f = 4.4, | |
909 | }; | |
910 | #endif | |
911 | ||
912 | #if __HAVE_FLOAT16 | |
913 | float16.u = side_bswap_16(float16.u); | |
914 | #endif | |
915 | #if __HAVE_FLOAT32 | |
916 | float32.u = side_bswap_32(float32.u); | |
917 | #endif | |
918 | #if __HAVE_FLOAT64 | |
919 | float64.u = side_bswap_64(float64.u); | |
920 | #endif | |
921 | #if __HAVE_FLOAT128 | |
922 | side_bswap_128p(float128.arr); | |
923 | #endif | |
924 | ||
d5cdb129 | 925 | side_event(my_provider_event_float, |
fb25b355 MD |
926 | side_arg_list( |
927 | #if __HAVE_FLOAT16 | |
928 | side_arg_float_binary16(1.1), | |
8bdd5c12 MD |
929 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN |
930 | side_arg_float_binary16(1.1), | |
931 | side_arg_float_binary16(float16.f), | |
932 | # else | |
933 | side_arg_float_binary16(float16.f), | |
934 | side_arg_float_binary16(1.1), | |
935 | # endif | |
fb25b355 MD |
936 | #endif |
937 | #if __HAVE_FLOAT32 | |
938 | side_arg_float_binary32(2.2), | |
8bdd5c12 MD |
939 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN |
940 | side_arg_float_binary32(2.2), | |
941 | side_arg_float_binary32(float32.f), | |
942 | # else | |
943 | side_arg_float_binary32(float32.f), | |
944 | side_arg_float_binary32(2.2), | |
945 | # endif | |
fb25b355 MD |
946 | #endif |
947 | #if __HAVE_FLOAT64 | |
948 | side_arg_float_binary64(3.3), | |
8bdd5c12 MD |
949 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN |
950 | side_arg_float_binary64(3.3), | |
951 | side_arg_float_binary64(float64.f), | |
952 | # else | |
953 | side_arg_float_binary64(float64.f), | |
954 | side_arg_float_binary64(3.3), | |
955 | # endif | |
fb25b355 MD |
956 | #endif |
957 | #if __HAVE_FLOAT128 | |
958 | side_arg_float_binary128(4.4), | |
8bdd5c12 MD |
959 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN |
960 | side_arg_float_binary128(4.4), | |
961 | side_arg_float_binary128(float128.f), | |
962 | # else | |
963 | side_arg_float_binary128(float128.f), | |
964 | side_arg_float_binary128(4.4), | |
965 | # endif | |
fb25b355 MD |
966 | #endif |
967 | ) | |
968 | ); | |
969 | } | |
970 | ||
89747802 | 971 | side_static_event_variadic(my_provider_event_variadic_float, |
fb25b355 MD |
972 | "myprovider", "myvariadicfloat", SIDE_LOGLEVEL_DEBUG, |
973 | side_field_list(), | |
974 | side_attr_list() | |
975 | ); | |
976 | ||
977 | static | |
978 | void test_variadic_float(void) | |
979 | { | |
8bdd5c12 MD |
980 | #if __HAVE_FLOAT16 |
981 | union { | |
982 | _Float16 f; | |
983 | uint16_t u; | |
984 | } float16 = { | |
985 | .f = 1.1, | |
986 | }; | |
987 | #endif | |
988 | #if __HAVE_FLOAT32 | |
989 | union { | |
990 | _Float32 f; | |
991 | uint32_t u; | |
992 | } float32 = { | |
993 | .f = 2.2, | |
994 | }; | |
995 | #endif | |
996 | #if __HAVE_FLOAT64 | |
997 | union { | |
998 | _Float64 f; | |
999 | uint64_t u; | |
1000 | } float64 = { | |
1001 | .f = 3.3, | |
1002 | }; | |
1003 | #endif | |
1004 | #if __HAVE_FLOAT128 | |
1005 | union { | |
1006 | _Float128 f; | |
1007 | char arr[16]; | |
1008 | } float128 = { | |
1009 | .f = 4.4, | |
1010 | }; | |
1011 | #endif | |
1012 | ||
1013 | #if __HAVE_FLOAT16 | |
1014 | float16.u = side_bswap_16(float16.u); | |
1015 | #endif | |
1016 | #if __HAVE_FLOAT32 | |
1017 | float32.u = side_bswap_32(float32.u); | |
1018 | #endif | |
1019 | #if __HAVE_FLOAT64 | |
1020 | float64.u = side_bswap_64(float64.u); | |
1021 | #endif | |
1022 | #if __HAVE_FLOAT128 | |
1023 | side_bswap_128p(float128.arr); | |
1024 | #endif | |
1025 | ||
d5cdb129 | 1026 | side_event_variadic(my_provider_event_variadic_float, |
fb25b355 MD |
1027 | side_arg_list(), |
1028 | side_arg_list( | |
1029 | #if __HAVE_FLOAT16 | |
8bdd5c12 MD |
1030 | side_arg_dynamic_field("binary16", side_arg_dynamic_float_binary16(1.1, side_attr_list())), |
1031 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN | |
1032 | side_arg_dynamic_field("binary16_le", side_arg_dynamic_float_binary16_le(1.1, side_attr_list())), | |
1033 | side_arg_dynamic_field("binary16_be", side_arg_dynamic_float_binary16_be(float16.f, side_attr_list())), | |
1034 | # else | |
1035 | side_arg_dynamic_field("binary16_le", side_arg_dynamic_float_binary16_le(float16.f, side_attr_list())), | |
1036 | side_arg_dynamic_field("binary16_be", side_arg_dynamic_float_binary16_be(1.1, side_attr_list())), | |
1037 | # endif | |
fb25b355 MD |
1038 | #endif |
1039 | #if __HAVE_FLOAT32 | |
8bdd5c12 MD |
1040 | side_arg_dynamic_field("binary32", side_arg_dynamic_float_binary32(2.2, side_attr_list())), |
1041 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN | |
1042 | side_arg_dynamic_field("binary32_le", side_arg_dynamic_float_binary32_le(2.2, side_attr_list())), | |
1043 | side_arg_dynamic_field("binary32_be", side_arg_dynamic_float_binary32_be(float32.f, side_attr_list())), | |
1044 | # else | |
1045 | side_arg_dynamic_field("binary32_le", side_arg_dynamic_float_binary32_le(float32.f, side_attr_list())), | |
1046 | side_arg_dynamic_field("binary32_be", side_arg_dynamic_float_binary32_be(2.2, side_attr_list())), | |
1047 | # endif | |
fb25b355 MD |
1048 | #endif |
1049 | #if __HAVE_FLOAT64 | |
8bdd5c12 MD |
1050 | side_arg_dynamic_field("binary64", side_arg_dynamic_float_binary64(3.3, side_attr_list())), |
1051 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN | |
1052 | side_arg_dynamic_field("binary64_le", side_arg_dynamic_float_binary64_le(3.3, side_attr_list())), | |
1053 | side_arg_dynamic_field("binary64_be", side_arg_dynamic_float_binary64_be(float64.f, side_attr_list())), | |
1054 | # else | |
1055 | side_arg_dynamic_field("binary64_le", side_arg_dynamic_float_binary64_le(float64.f, side_attr_list())), | |
1056 | side_arg_dynamic_field("binary64_be", side_arg_dynamic_float_binary64_be(3.3, side_attr_list())), | |
1057 | # endif | |
fb25b355 MD |
1058 | #endif |
1059 | #if __HAVE_FLOAT128 | |
8bdd5c12 MD |
1060 | side_arg_dynamic_field("binary128", side_arg_dynamic_float_binary128(4.4, side_attr_list())), |
1061 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN | |
1062 | side_arg_dynamic_field("binary128_le", side_arg_dynamic_float_binary128_le(4.4, side_attr_list())), | |
1063 | side_arg_dynamic_field("binary128_be", side_arg_dynamic_float_binary128_be(float128.f, side_attr_list())), | |
1064 | # else | |
1065 | side_arg_dynamic_field("binary128_le", side_arg_dynamic_float_binary128_le(float128.f, side_attr_list())), | |
1066 | side_arg_dynamic_field("binary128_be", side_arg_dynamic_float_binary128_be(4.4, side_attr_list())), | |
1067 | # endif | |
fb25b355 | 1068 | #endif |
8d20e708 MD |
1069 | ), |
1070 | side_attr_list() | |
fb25b355 MD |
1071 | ); |
1072 | } | |
1073 | ||
79f677ba | 1074 | static side_define_enum(myenum, |
66cff328 | 1075 | side_enum_mapping_list( |
79f677ba MD |
1076 | side_enum_mapping_range("one-ten", 1, 10), |
1077 | side_enum_mapping_range("100-200", 100, 200), | |
1078 | side_enum_mapping_value("200", 200), | |
1079 | side_enum_mapping_value("300", 300), | |
d4328528 MD |
1080 | ), |
1081 | side_attr_list() | |
79f677ba MD |
1082 | ); |
1083 | ||
89747802 | 1084 | side_static_event(my_provider_event_enum, "myprovider", "myeventenum", SIDE_LOGLEVEL_DEBUG, |
79f677ba | 1085 | side_field_list( |
f89c4ad1 MD |
1086 | side_field_enum("5", &myenum, side_elem(side_type_u32(side_attr_list()))), |
1087 | side_field_enum("400", &myenum, side_elem(side_type_u64(side_attr_list()))), | |
1088 | side_field_enum("200", &myenum, side_elem(side_type_u8(side_attr_list()))), | |
1089 | side_field_enum("-100", &myenum, side_elem(side_type_s8(side_attr_list()))), | |
8bdd5c12 MD |
1090 | side_field_enum("6_be", &myenum, side_elem(side_type_u32_be(side_attr_list()))), |
1091 | side_field_enum("6_le", &myenum, side_elem(side_type_u32_le(side_attr_list()))), | |
79f677ba MD |
1092 | ), |
1093 | side_attr_list() | |
1094 | ); | |
1095 | ||
1096 | static | |
1097 | void test_enum(void) | |
1098 | { | |
d5cdb129 | 1099 | side_event(my_provider_event_enum, |
79f677ba | 1100 | side_arg_list( |
d8be25de MD |
1101 | side_arg_u32(5), |
1102 | side_arg_u64(400), | |
1103 | side_arg_u8(200), | |
1104 | side_arg_s8(-100), | |
8bdd5c12 MD |
1105 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN |
1106 | side_arg_u32(side_bswap_32(6)), | |
1107 | side_arg_u32(6), | |
1108 | #else | |
8bdd5c12 | 1109 | side_arg_u32(6), |
7a4ac0e2 | 1110 | side_arg_u32(side_bswap_32(6)), |
8bdd5c12 | 1111 | #endif |
79f677ba MD |
1112 | ) |
1113 | ); | |
1114 | } | |
1115 | ||
ea32e5fc | 1116 | /* A bitmap enum maps bits to labels. */ |
66cff328 MD |
1117 | static side_define_enum_bitmap(myenum_bitmap, |
1118 | side_enum_bitmap_mapping_list( | |
1119 | side_enum_bitmap_mapping_value("0", 0), | |
1120 | side_enum_bitmap_mapping_range("1-2", 1, 2), | |
1121 | side_enum_bitmap_mapping_range("2-4", 2, 4), | |
1122 | side_enum_bitmap_mapping_value("3", 3), | |
1123 | side_enum_bitmap_mapping_value("30", 30), | |
1124 | side_enum_bitmap_mapping_value("63", 63), | |
af6aa6e1 MD |
1125 | side_enum_bitmap_mapping_range("158-160", 158, 160), |
1126 | side_enum_bitmap_mapping_value("159", 159), | |
1127 | side_enum_bitmap_mapping_range("500-700", 500, 700), | |
d4328528 MD |
1128 | ), |
1129 | side_attr_list() | |
ea32e5fc MD |
1130 | ); |
1131 | ||
89747802 | 1132 | side_static_event(my_provider_event_enum_bitmap, "myprovider", "myeventenumbitmap", SIDE_LOGLEVEL_DEBUG, |
ea32e5fc | 1133 | side_field_list( |
f89c4ad1 MD |
1134 | side_field_enum_bitmap("bit_0", &myenum_bitmap, side_elem(side_type_u32(side_attr_list()))), |
1135 | side_field_enum_bitmap("bit_1", &myenum_bitmap, side_elem(side_type_u32(side_attr_list()))), | |
1136 | side_field_enum_bitmap("bit_2", &myenum_bitmap, side_elem(side_type_u8(side_attr_list()))), | |
1137 | side_field_enum_bitmap("bit_3", &myenum_bitmap, side_elem(side_type_u8(side_attr_list()))), | |
1138 | side_field_enum_bitmap("bit_30", &myenum_bitmap, side_elem(side_type_u32(side_attr_list()))), | |
1139 | side_field_enum_bitmap("bit_31", &myenum_bitmap, side_elem(side_type_u32(side_attr_list()))), | |
1140 | side_field_enum_bitmap("bit_63", &myenum_bitmap, side_elem(side_type_u64(side_attr_list()))), | |
1141 | side_field_enum_bitmap("bits_1+63", &myenum_bitmap, side_elem(side_type_u64(side_attr_list()))), | |
4cc2880b | 1142 | side_field_enum_bitmap("byte_bit_2", &myenum_bitmap, side_elem(side_type_byte(side_attr_list()))), |
f89c4ad1 MD |
1143 | side_field_enum_bitmap("bit_159", &myenum_bitmap, |
1144 | side_elem(side_type_array(side_elem(side_type_u32(side_attr_list())), 5, side_attr_list()))), | |
1145 | side_field_enum_bitmap("bit_159", &myenum_bitmap, | |
1146 | side_elem(side_type_vla(side_elem(side_type_u32(side_attr_list())), side_attr_list()))), | |
8bdd5c12 MD |
1147 | side_field_enum_bitmap("bit_2_be", &myenum_bitmap, side_elem(side_type_u32_be(side_attr_list()))), |
1148 | side_field_enum_bitmap("bit_2_le", &myenum_bitmap, side_elem(side_type_u32_le(side_attr_list()))), | |
ea32e5fc MD |
1149 | ), |
1150 | side_attr_list() | |
1151 | ); | |
1152 | ||
1153 | static | |
1154 | void test_enum_bitmap(void) | |
1155 | { | |
af6aa6e1 MD |
1156 | side_event_cond(my_provider_event_enum_bitmap) { |
1157 | side_arg_define_vec(myarray, | |
1158 | side_arg_list( | |
1159 | side_arg_u32(0), | |
1160 | side_arg_u32(0), | |
1161 | side_arg_u32(0), | |
1162 | side_arg_u32(0), | |
1163 | side_arg_u32(0x80000000), /* bit 159 */ | |
1164 | ) | |
1165 | ); | |
1166 | side_event_call(my_provider_event_enum_bitmap, | |
1167 | side_arg_list( | |
44abda1a MD |
1168 | side_arg_u32(1U << 0), |
1169 | side_arg_u32(1U << 1), | |
1170 | side_arg_u8(1U << 2), | |
1171 | side_arg_u8(1U << 3), | |
1172 | side_arg_u32(1U << 30), | |
1173 | side_arg_u32(1U << 31), | |
bab5d6e4 MD |
1174 | side_arg_u64(1ULL << 63), |
1175 | side_arg_u64((1ULL << 1) | (1ULL << 63)), | |
44abda1a | 1176 | side_arg_byte(1U << 2), |
bab5d6e4 MD |
1177 | side_arg_array(&myarray), |
1178 | side_arg_vla(&myarray), | |
8bdd5c12 | 1179 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN |
44abda1a MD |
1180 | side_arg_u32(side_bswap_32(1U << 2)), |
1181 | side_arg_u32(1U << 2), | |
8bdd5c12 | 1182 | #else |
7a4ac0e2 | 1183 | side_arg_u32(1U << 2), |
44abda1a | 1184 | side_arg_u32(side_bswap_32(1U << 2)), |
8bdd5c12 | 1185 | #endif |
af6aa6e1 MD |
1186 | ) |
1187 | ); | |
1188 | } | |
ea32e5fc MD |
1189 | } |
1190 | ||
89747802 | 1191 | side_static_event_variadic(my_provider_event_blob, "myprovider", "myeventblob", SIDE_LOGLEVEL_DEBUG, |
7aec0d09 | 1192 | side_field_list( |
f7653b43 MD |
1193 | side_field_byte("blobfield", side_attr_list()), |
1194 | side_field_array("arrayblob", side_elem(side_type_byte(side_attr_list())), 3, side_attr_list()), | |
7aec0d09 MD |
1195 | ), |
1196 | side_attr_list() | |
1197 | ); | |
1198 | ||
1199 | static | |
1200 | void test_blob(void) | |
1201 | { | |
d5cdb129 | 1202 | side_event_cond(my_provider_event_blob) { |
f7653b43 | 1203 | side_arg_define_vec(myarray, side_arg_list(side_arg_byte(1), side_arg_byte(2), side_arg_byte(3))); |
199e7aa9 MD |
1204 | side_arg_dynamic_define_vec(myvla, |
1205 | side_arg_list( | |
f7653b43 MD |
1206 | side_arg_dynamic_byte(0x22, side_attr_list()), |
1207 | side_arg_dynamic_byte(0x33, side_attr_list()), | |
8d20e708 MD |
1208 | ), |
1209 | side_attr_list() | |
199e7aa9 | 1210 | ); |
d5cdb129 | 1211 | side_event_call_variadic(my_provider_event_blob, |
7aec0d09 | 1212 | side_arg_list( |
f7653b43 | 1213 | side_arg_byte(0x55), |
7aec0d09 | 1214 | side_arg_array(&myarray), |
199e7aa9 MD |
1215 | ), |
1216 | side_arg_list( | |
1217 | side_arg_dynamic_field("varblobfield", | |
f7653b43 | 1218 | side_arg_dynamic_byte(0x55, side_attr_list()) |
199e7aa9 | 1219 | ), |
8d20e708 MD |
1220 | side_arg_dynamic_field("varblobvla", side_arg_dynamic_vla(&myvla)), |
1221 | ), | |
1222 | side_attr_list() | |
7aec0d09 MD |
1223 | ); |
1224 | } | |
1225 | } | |
ea32e5fc | 1226 | |
89747802 | 1227 | side_static_event_variadic(my_provider_event_format_string, |
71aa8975 MD |
1228 | "myprovider", "myeventformatstring", SIDE_LOGLEVEL_DEBUG, |
1229 | side_field_list( | |
1230 | side_field_string("fmt", side_attr_list()), | |
1231 | ), | |
1232 | side_attr_list( | |
1233 | side_attr("lang.c.format_string", side_attr_bool(true)), | |
1234 | ) | |
1235 | ); | |
1236 | ||
1237 | static | |
1238 | void test_fmt_string(void) | |
1239 | { | |
71aa8975 MD |
1240 | side_event_cond(my_provider_event_format_string) { |
1241 | side_arg_dynamic_define_vec(args, | |
1242 | side_arg_list( | |
1243 | side_arg_dynamic_string("blah", side_attr_list()), | |
1244 | side_arg_dynamic_s32(123, side_attr_list()), | |
1245 | ), | |
1246 | side_attr_list() | |
1247 | ); | |
1248 | side_event_call_variadic(my_provider_event_format_string, | |
1249 | side_arg_list( | |
1250 | side_arg_string("This is a formatted string with str: %s int: %d"), | |
1251 | ), | |
1252 | side_arg_list( | |
1253 | side_arg_dynamic_field("arguments", side_arg_dynamic_vla(&args)), | |
1254 | ), | |
1255 | side_attr_list() | |
1256 | ); | |
1257 | } | |
1258 | } | |
1259 | ||
8bdd5c12 MD |
1260 | side_static_event_variadic(my_provider_event_endian, "myprovider", "myevent_endian", SIDE_LOGLEVEL_DEBUG, |
1261 | side_field_list( | |
1262 | side_field_u16_le("u16_le", side_attr_list()), | |
1263 | side_field_u32_le("u32_le", side_attr_list()), | |
1264 | side_field_u64_le("u64_le", side_attr_list()), | |
1265 | side_field_s16_le("s16_le", side_attr_list()), | |
1266 | side_field_s32_le("s32_le", side_attr_list()), | |
1267 | side_field_s64_le("s64_le", side_attr_list()), | |
1268 | side_field_u16_be("u16_be", side_attr_list()), | |
1269 | side_field_u32_be("u32_be", side_attr_list()), | |
1270 | side_field_u64_be("u64_be", side_attr_list()), | |
1271 | side_field_s16_be("s16_be", side_attr_list()), | |
1272 | side_field_s32_be("s32_be", side_attr_list()), | |
1273 | side_field_s64_be("s64_be", side_attr_list()), | |
1274 | ), | |
1275 | side_attr_list() | |
1276 | ); | |
1277 | ||
1278 | static | |
1279 | void test_endian(void) | |
1280 | { | |
1281 | side_event_variadic(my_provider_event_endian, | |
1282 | side_arg_list( | |
1283 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN | |
1284 | side_arg_u16(1), | |
1285 | side_arg_u32(1), | |
1286 | side_arg_u64(1), | |
1287 | side_arg_s16(1), | |
1288 | side_arg_s32(1), | |
1289 | side_arg_s64(1), | |
1290 | side_arg_u16(side_bswap_16(1)), | |
1291 | side_arg_u32(side_bswap_32(1)), | |
1292 | side_arg_u64(side_bswap_64(1)), | |
1293 | side_arg_s16(side_bswap_16(1)), | |
1294 | side_arg_s32(side_bswap_32(1)), | |
1295 | side_arg_s64(side_bswap_64(1)), | |
1296 | #else | |
1297 | side_arg_u16(side_bswap_16(1)), | |
1298 | side_arg_u32(side_bswap_32(1)), | |
1299 | side_arg_u64(side_bswap_64(1)), | |
1300 | side_arg_s16(side_bswap_16(1)), | |
1301 | side_arg_s32(side_bswap_32(1)), | |
1302 | side_arg_s64(side_bswap_64(1)), | |
1303 | side_arg_u16(1), | |
1304 | side_arg_u32(1), | |
1305 | side_arg_u64(1), | |
1306 | side_arg_s16(1), | |
1307 | side_arg_s32(1), | |
1308 | side_arg_s64(1), | |
1309 | #endif | |
1310 | ), | |
1311 | side_arg_list( | |
1312 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN | |
1313 | side_arg_dynamic_field("u16_le", side_arg_dynamic_u16_le(1, side_attr_list())), | |
1314 | side_arg_dynamic_field("u32_le", side_arg_dynamic_u32_le(1, side_attr_list())), | |
1315 | side_arg_dynamic_field("u64_le", side_arg_dynamic_u64_le(1, side_attr_list())), | |
1316 | side_arg_dynamic_field("s16_le", side_arg_dynamic_s16_le(1, side_attr_list())), | |
1317 | side_arg_dynamic_field("s32_le", side_arg_dynamic_s32_le(1, side_attr_list())), | |
1318 | side_arg_dynamic_field("s64_le", side_arg_dynamic_s64_le(1, side_attr_list())), | |
1319 | side_arg_dynamic_field("u16_be", side_arg_dynamic_u16_be(side_bswap_16(1), side_attr_list())), | |
1320 | side_arg_dynamic_field("u32_be", side_arg_dynamic_u32_be(side_bswap_32(1), side_attr_list())), | |
1321 | side_arg_dynamic_field("u64_be", side_arg_dynamic_u64_be(side_bswap_64(1), side_attr_list())), | |
1322 | side_arg_dynamic_field("s16_be", side_arg_dynamic_s16_be(side_bswap_16(1), side_attr_list())), | |
1323 | side_arg_dynamic_field("s32_be", side_arg_dynamic_s32_be(side_bswap_32(1), side_attr_list())), | |
1324 | side_arg_dynamic_field("s64_be", side_arg_dynamic_s64_be(side_bswap_64(1), side_attr_list())), | |
1325 | #else | |
1326 | side_arg_dynamic_field("u16_le", side_arg_dynamic_u16_le(side_bswap_16(1), side_attr_list())), | |
1327 | side_arg_dynamic_field("u32_le", side_arg_dynamic_u32_le(side_bswap_32(1), side_attr_list())), | |
1328 | side_arg_dynamic_field("u64_le", side_arg_dynamic_u64_le(side_bswap_64(1), side_attr_list())), | |
1329 | side_arg_dynamic_field("s16_le", side_arg_dynamic_s16_le(side_bswap_16(1), side_attr_list())), | |
1330 | side_arg_dynamic_field("s32_le", side_arg_dynamic_s32_le(side_bswap_32(1), side_attr_list())), | |
1331 | side_arg_dynamic_field("s64_le", side_arg_dynamic_s64_le(side_bswap_64(1), side_attr_list())), | |
1332 | side_arg_dynamic_field("u16_be", side_arg_dynamic_u16_be(1, side_attr_list())), | |
1333 | side_arg_dynamic_field("u32_be", side_arg_dynamic_u32_be(1, side_attr_list())), | |
1334 | side_arg_dynamic_field("u64_be", side_arg_dynamic_u64_be(1, side_attr_list())), | |
1335 | side_arg_dynamic_field("s16_be", side_arg_dynamic_s16_be(1, side_attr_list())), | |
1336 | side_arg_dynamic_field("s32_be", side_arg_dynamic_s32_be(1, side_attr_list())), | |
1337 | side_arg_dynamic_field("s64_be", side_arg_dynamic_s64_be(1, side_attr_list())), | |
1338 | #endif | |
1339 | ), | |
1340 | side_attr_list() | |
1341 | ); | |
1342 | } | |
1343 | ||
1d9c515c MD |
1344 | side_static_event(my_provider_event_base, "myprovider", "myevent_base", SIDE_LOGLEVEL_DEBUG, |
1345 | side_field_list( | |
1346 | side_field_u8("u8base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1347 | side_field_u8("u8base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1348 | side_field_u8("u8base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1349 | side_field_u8("u8base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1350 | side_field_u16("u16base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1351 | side_field_u16("u16base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1352 | side_field_u16("u16base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1353 | side_field_u16("u16base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1354 | side_field_u32("u32base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1355 | side_field_u32("u32base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1356 | side_field_u32("u32base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1357 | side_field_u32("u32base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1358 | side_field_u64("u64base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1359 | side_field_u64("u64base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1360 | side_field_u64("u64base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1361 | side_field_u64("u64base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1362 | side_field_s8("s8base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1363 | side_field_s8("s8base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1364 | side_field_s8("s8base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1365 | side_field_s8("s8base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1366 | side_field_s16("s16base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1367 | side_field_s16("s16base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1368 | side_field_s16("s16base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1369 | side_field_s16("s16base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1370 | side_field_s32("s32base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1371 | side_field_s32("s32base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1372 | side_field_s32("s32base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1373 | side_field_s32("s32base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1374 | side_field_s64("s64base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1375 | side_field_s64("s64base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1376 | side_field_s64("s64base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1377 | side_field_s64("s64base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1378 | ), | |
1379 | side_attr_list() | |
1380 | ); | |
1381 | ||
1382 | static | |
1383 | void test_base(void) | |
1384 | { | |
1385 | side_event(my_provider_event_base, | |
1386 | side_arg_list( | |
1387 | side_arg_u8(55), | |
1388 | side_arg_u8(55), | |
1389 | side_arg_u8(55), | |
1390 | side_arg_u8(55), | |
1391 | side_arg_u16(55), | |
1392 | side_arg_u16(55), | |
1393 | side_arg_u16(55), | |
1394 | side_arg_u16(55), | |
1395 | side_arg_u32(55), | |
1396 | side_arg_u32(55), | |
1397 | side_arg_u32(55), | |
1398 | side_arg_u32(55), | |
1399 | side_arg_u64(55), | |
1400 | side_arg_u64(55), | |
1401 | side_arg_u64(55), | |
1402 | side_arg_u64(55), | |
1403 | side_arg_s8(-55), | |
1404 | side_arg_s8(-55), | |
1405 | side_arg_s8(-55), | |
1406 | side_arg_s8(-55), | |
1407 | side_arg_s16(-55), | |
1408 | side_arg_s16(-55), | |
1409 | side_arg_s16(-55), | |
1410 | side_arg_s16(-55), | |
1411 | side_arg_s32(-55), | |
1412 | side_arg_s32(-55), | |
1413 | side_arg_s32(-55), | |
1414 | side_arg_s32(-55), | |
1415 | side_arg_s64(-55), | |
1416 | side_arg_s64(-55), | |
1417 | side_arg_s64(-55), | |
1418 | side_arg_s64(-55), | |
1419 | ) | |
1420 | ); | |
1421 | } | |
1422 | ||
7a1cb105 MD |
1423 | struct test { |
1424 | uint32_t a; | |
1425 | uint64_t b; | |
1426 | uint8_t c; | |
1427 | int32_t d; | |
1428 | uint16_t e; | |
bc0b21eb MD |
1429 | int8_t f; |
1430 | int16_t g; | |
1431 | int32_t h; | |
1432 | int64_t i; | |
1433 | int64_t j; | |
1434 | int64_t k; | |
c1723f3c | 1435 | uint64_t test; |
7a1cb105 MD |
1436 | }; |
1437 | ||
d41cb7ee | 1438 | static side_define_struct(mystructgatherdef, |
33956c71 | 1439 | side_field_list( |
d41cb7ee | 1440 | side_field_gather_unsigned_integer("a", offsetof(struct test, a), |
88bab79c MD |
1441 | side_struct_field_sizeof(struct test, a), 0, 0, |
1442 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), | |
d41cb7ee | 1443 | side_field_gather_signed_integer("d", offsetof(struct test, d), |
88bab79c MD |
1444 | side_struct_field_sizeof(struct test, d), 0, 0, |
1445 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), | |
d41cb7ee | 1446 | side_field_gather_unsigned_integer("e", offsetof(struct test, e), |
88bab79c | 1447 | side_struct_field_sizeof(struct test, e), 8, 4, |
84c04cc8 | 1448 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), |
d41cb7ee | 1449 | side_field_gather_signed_integer("f", offsetof(struct test, f), |
88bab79c | 1450 | side_struct_field_sizeof(struct test, f), 1, 4, |
84c04cc8 | 1451 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), |
d41cb7ee | 1452 | side_field_gather_signed_integer("g", offsetof(struct test, g), |
88bab79c | 1453 | side_struct_field_sizeof(struct test, g), 11, 4, |
84c04cc8 | 1454 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), |
d41cb7ee | 1455 | side_field_gather_signed_integer("h", offsetof(struct test, h), |
88bab79c | 1456 | side_struct_field_sizeof(struct test, h), 1, 31, |
84c04cc8 | 1457 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), |
d41cb7ee | 1458 | side_field_gather_signed_integer("i", offsetof(struct test, i), |
88bab79c | 1459 | side_struct_field_sizeof(struct test, i), 33, 20, |
84c04cc8 | 1460 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), |
d41cb7ee | 1461 | side_field_gather_signed_integer("j", offsetof(struct test, j), |
88bab79c | 1462 | side_struct_field_sizeof(struct test, j), 63, 1, |
84c04cc8 | 1463 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), |
d41cb7ee | 1464 | side_field_gather_signed_integer("k", offsetof(struct test, k), |
88bab79c | 1465 | side_struct_field_sizeof(struct test, k), 1, 63, |
84c04cc8 | 1466 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), |
d41cb7ee | 1467 | side_field_gather_unsigned_integer_le("test", offsetof(struct test, test), |
88bab79c | 1468 | side_struct_field_sizeof(struct test, test), 0, 64, |
84c04cc8 | 1469 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), |
d41cb7ee | 1470 | side_field_gather_unsigned_integer_le("test_le", offsetof(struct test, test), |
88bab79c | 1471 | side_struct_field_sizeof(struct test, test), 0, 64, |
84c04cc8 | 1472 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), |
d41cb7ee | 1473 | side_field_gather_unsigned_integer_be("test_be", offsetof(struct test, test), |
88bab79c | 1474 | side_struct_field_sizeof(struct test, test), 0, 64, |
84c04cc8 | 1475 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), |
7a1cb105 MD |
1476 | ), |
1477 | side_attr_list() | |
1478 | ); | |
1479 | ||
d41cb7ee | 1480 | side_static_event(my_provider_event_structgather, "myprovider", "myeventstructgather", SIDE_LOGLEVEL_DEBUG, |
7a1cb105 | 1481 | side_field_list( |
d41cb7ee | 1482 | side_field_gather_struct("structgather", &mystructgatherdef, 0, sizeof(struct test), |
84c04cc8 | 1483 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
88bab79c | 1484 | side_field_gather_signed_integer("intgather", 0, sizeof(int32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, |
33956c71 | 1485 | side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), |
13d97eca | 1486 | #if __HAVE_FLOAT32 |
88bab79c | 1487 | side_field_gather_float("f32", 0, sizeof(_Float32), SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), |
13d97eca | 1488 | #endif |
7a1cb105 MD |
1489 | ), |
1490 | side_attr_list() | |
1491 | ); | |
1492 | ||
1493 | static | |
d41cb7ee | 1494 | void test_struct_gather(void) |
7a1cb105 | 1495 | { |
d41cb7ee | 1496 | side_event_cond(my_provider_event_structgather) { |
7a1cb105 MD |
1497 | struct test mystruct = { |
1498 | .a = 55, | |
1499 | .b = 123, | |
1500 | .c = 2, | |
1501 | .d = -55, | |
1502 | .e = 0xABCD, | |
bc0b21eb MD |
1503 | .f = -1, |
1504 | .g = -1, | |
1505 | .h = -1, | |
1506 | .i = -1, | |
1507 | .j = -1, | |
1508 | .k = -1, | |
c1723f3c | 1509 | .test = 0xFF, |
7a1cb105 | 1510 | }; |
33956c71 | 1511 | int32_t val = -66; |
13d97eca MD |
1512 | #if __HAVE_FLOAT32 |
1513 | _Float32 f32 = 1.1; | |
1514 | #endif | |
d41cb7ee | 1515 | side_event_call(my_provider_event_structgather, |
33956c71 | 1516 | side_arg_list( |
d41cb7ee | 1517 | side_arg_gather_struct(&mystruct), |
ede530c9 | 1518 | side_arg_gather_integer(&val), |
13d97eca | 1519 | #if __HAVE_FLOAT32 |
d41cb7ee | 1520 | side_arg_gather_float(&f32), |
13d97eca | 1521 | #endif |
33956c71 MD |
1522 | ) |
1523 | ); | |
7a1cb105 MD |
1524 | } |
1525 | } | |
1526 | ||
7394a8b8 MD |
1527 | struct testnest2 { |
1528 | uint8_t c; | |
1529 | }; | |
1530 | ||
1531 | struct testnest1 { | |
1532 | uint64_t b; | |
1533 | struct testnest2 *nest; | |
1534 | }; | |
1535 | ||
1536 | struct testnest0 { | |
1537 | uint32_t a; | |
1538 | struct testnest1 *nest; | |
1539 | }; | |
1540 | ||
d41cb7ee | 1541 | static side_define_struct(mystructgathernest2, |
7394a8b8 | 1542 | side_field_list( |
d41cb7ee | 1543 | side_field_gather_unsigned_integer("c", offsetof(struct testnest2, c), |
88bab79c MD |
1544 | side_struct_field_sizeof(struct testnest2, c), 0, 0, |
1545 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), | |
7394a8b8 MD |
1546 | ), |
1547 | side_attr_list() | |
1548 | ); | |
1549 | ||
d41cb7ee | 1550 | static side_define_struct(mystructgathernest1, |
7394a8b8 | 1551 | side_field_list( |
d41cb7ee | 1552 | side_field_gather_unsigned_integer("b", offsetof(struct testnest1, b), |
88bab79c MD |
1553 | side_struct_field_sizeof(struct testnest1, b), 0, 0, |
1554 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), | |
d41cb7ee | 1555 | side_field_gather_struct("nest2", &mystructgathernest2, |
dd7947bf | 1556 | offsetof(struct testnest1, nest), sizeof(struct testnest2), |
d41cb7ee | 1557 | SIDE_TYPE_GATHER_ACCESS_POINTER), |
7394a8b8 MD |
1558 | ), |
1559 | side_attr_list() | |
1560 | ); | |
1561 | ||
d41cb7ee | 1562 | static side_define_struct(mystructgathernest0, |
7394a8b8 | 1563 | side_field_list( |
d41cb7ee | 1564 | side_field_gather_unsigned_integer("a", offsetof(struct testnest0, a), |
88bab79c MD |
1565 | side_struct_field_sizeof(struct testnest0, a), 0, 0, |
1566 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), | |
d41cb7ee | 1567 | side_field_gather_struct("nest1", &mystructgathernest1, |
dd7947bf | 1568 | offsetof(struct testnest0, nest), sizeof(struct testnest1), |
d41cb7ee | 1569 | SIDE_TYPE_GATHER_ACCESS_POINTER), |
7394a8b8 MD |
1570 | ), |
1571 | side_attr_list() | |
1572 | ); | |
1573 | ||
d41cb7ee MD |
1574 | side_static_event(my_provider_event_structgather_nest, |
1575 | "myprovider", "myeventstructgathernest", SIDE_LOGLEVEL_DEBUG, | |
7394a8b8 | 1576 | side_field_list( |
d41cb7ee | 1577 | side_field_gather_struct("nest0", &mystructgathernest0, 0, |
84c04cc8 | 1578 | sizeof(struct testnest0), SIDE_TYPE_GATHER_ACCESS_DIRECT), |
7394a8b8 MD |
1579 | ), |
1580 | side_attr_list() | |
1581 | ); | |
1582 | ||
1583 | static | |
d41cb7ee | 1584 | void test_struct_gather_nest_ptr(void) |
7394a8b8 | 1585 | { |
d41cb7ee | 1586 | side_event_cond(my_provider_event_structgather_nest) { |
7394a8b8 MD |
1587 | struct testnest2 mystruct2 = { |
1588 | .c = 77, | |
1589 | }; | |
1590 | struct testnest1 mystruct1 = { | |
1591 | .b = 66, | |
1592 | .nest = &mystruct2, | |
1593 | }; | |
1594 | struct testnest0 mystruct = { | |
1595 | .a = 55, | |
1596 | .nest = &mystruct1, | |
1597 | }; | |
d41cb7ee | 1598 | side_event_call(my_provider_event_structgather_nest, |
7394a8b8 | 1599 | side_arg_list( |
d41cb7ee | 1600 | side_arg_gather_struct(&mystruct), |
7394a8b8 MD |
1601 | ) |
1602 | ); | |
1603 | } | |
1604 | } | |
1605 | ||
905f68e3 MD |
1606 | struct testfloat { |
1607 | #if __HAVE_FLOAT16 | |
1608 | _Float16 f16; | |
1609 | #endif | |
1610 | #if __HAVE_FLOAT32 | |
1611 | _Float32 f32; | |
1612 | #endif | |
1613 | #if __HAVE_FLOAT64 | |
1614 | _Float64 f64; | |
1615 | #endif | |
1616 | #if __HAVE_FLOAT128 | |
1617 | _Float128 f128; | |
1618 | #endif | |
1619 | }; | |
1620 | ||
d41cb7ee | 1621 | static side_define_struct(mystructgatherfloat, |
905f68e3 MD |
1622 | side_field_list( |
1623 | #if __HAVE_FLOAT16 | |
88bab79c | 1624 | side_field_gather_float("f16", offsetof(struct testfloat, f16), side_struct_field_sizeof(struct testfloat, f16), |
84c04cc8 | 1625 | SIDE_TYPE_GATHER_ACCESS_DIRECT, |
905f68e3 MD |
1626 | side_attr_list()), |
1627 | #endif | |
1628 | #if __HAVE_FLOAT32 | |
88bab79c | 1629 | side_field_gather_float("f32", offsetof(struct testfloat, f32), side_struct_field_sizeof(struct testfloat, f32), |
84c04cc8 | 1630 | SIDE_TYPE_GATHER_ACCESS_DIRECT, |
905f68e3 MD |
1631 | side_attr_list()), |
1632 | #endif | |
1633 | #if __HAVE_FLOAT64 | |
88bab79c | 1634 | side_field_gather_float("f64", offsetof(struct testfloat, f64), side_struct_field_sizeof(struct testfloat, f64), |
84c04cc8 | 1635 | SIDE_TYPE_GATHER_ACCESS_DIRECT, |
905f68e3 MD |
1636 | side_attr_list()), |
1637 | #endif | |
1638 | #if __HAVE_FLOAT128 | |
88bab79c | 1639 | side_field_gather_float("f128", offsetof(struct testfloat, f128), side_struct_field_sizeof(struct testfloat, f128), |
84c04cc8 | 1640 | SIDE_TYPE_GATHER_ACCESS_DIRECT, |
905f68e3 MD |
1641 | side_attr_list()), |
1642 | #endif | |
1643 | ), | |
1644 | side_attr_list() | |
1645 | ); | |
1646 | ||
d41cb7ee MD |
1647 | side_static_event(my_provider_event_structgatherfloat, |
1648 | "myprovider", "myeventstructgatherfloat", SIDE_LOGLEVEL_DEBUG, | |
905f68e3 | 1649 | side_field_list( |
d41cb7ee | 1650 | side_field_gather_struct("structgatherfloat", &mystructgatherfloat, 0, |
84c04cc8 | 1651 | sizeof(struct testfloat), SIDE_TYPE_GATHER_ACCESS_DIRECT), |
905f68e3 MD |
1652 | ), |
1653 | side_attr_list() | |
1654 | ); | |
1655 | ||
1656 | static | |
d41cb7ee | 1657 | void test_struct_gather_float(void) |
905f68e3 | 1658 | { |
d41cb7ee | 1659 | side_event_cond(my_provider_event_structgatherfloat) { |
905f68e3 MD |
1660 | struct testfloat mystruct = { |
1661 | #if __HAVE_FLOAT16 | |
1662 | .f16 = 1.1, | |
1663 | #endif | |
1664 | #if __HAVE_FLOAT32 | |
1665 | .f32 = 2.2, | |
1666 | #endif | |
1667 | #if __HAVE_FLOAT64 | |
1668 | .f64 = 3.3, | |
1669 | #endif | |
1670 | #if __HAVE_FLOAT128 | |
1671 | .f128 = 4.4, | |
1672 | #endif | |
1673 | }; | |
d41cb7ee | 1674 | side_event_call(my_provider_event_structgatherfloat, |
905f68e3 | 1675 | side_arg_list( |
d41cb7ee | 1676 | side_arg_gather_struct(&mystruct), |
905f68e3 MD |
1677 | ) |
1678 | ); | |
1679 | } | |
1680 | } | |
1681 | ||
d41cb7ee | 1682 | uint32_t mygatherarray[] = { 1, 2, 3, 4, 5 }; |
d9359cfa | 1683 | |
d41cb7ee | 1684 | uint16_t mygatherarray2[] = { 6, 7, 8, 9 }; |
d9359cfa MD |
1685 | |
1686 | struct testarray { | |
1687 | int a; | |
1688 | uint32_t *ptr; | |
1689 | }; | |
1690 | ||
d41cb7ee | 1691 | static side_define_struct(mystructgatherarray, |
d9359cfa | 1692 | side_field_list( |
d41cb7ee | 1693 | side_field_gather_array("array", |
88bab79c | 1694 | side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), |
d41cb7ee | 1695 | SIDE_ARRAY_SIZE(mygatherarray), |
d9359cfa | 1696 | offsetof(struct testarray, ptr), |
d41cb7ee | 1697 | SIDE_TYPE_GATHER_ACCESS_POINTER, |
d9359cfa MD |
1698 | side_attr_list()), |
1699 | ), | |
1700 | side_attr_list() | |
1701 | ); | |
1702 | ||
d41cb7ee MD |
1703 | side_static_event(my_provider_event_structgatherarray, |
1704 | "myprovider", "myeventstructgatherarray", SIDE_LOGLEVEL_DEBUG, | |
d9359cfa | 1705 | side_field_list( |
d41cb7ee | 1706 | side_field_gather_struct("structgatherarray", &mystructgatherarray, 0, |
84c04cc8 | 1707 | sizeof(struct testarray), SIDE_TYPE_GATHER_ACCESS_DIRECT), |
d41cb7ee | 1708 | side_field_gather_array("array2", |
88bab79c | 1709 | side_elem(side_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), |
d41cb7ee | 1710 | SIDE_ARRAY_SIZE(mygatherarray2), 0, |
84c04cc8 | 1711 | SIDE_TYPE_GATHER_ACCESS_DIRECT, |
d9359cfa MD |
1712 | side_attr_list() |
1713 | ), | |
1714 | ), | |
1715 | side_attr_list() | |
1716 | ); | |
1717 | ||
1718 | static | |
d41cb7ee | 1719 | void test_array_gather(void) |
d9359cfa | 1720 | { |
d41cb7ee | 1721 | side_event_cond(my_provider_event_structgatherarray) { |
d9359cfa MD |
1722 | struct testarray mystruct = { |
1723 | .a = 55, | |
d41cb7ee | 1724 | .ptr = mygatherarray, |
d9359cfa | 1725 | }; |
d41cb7ee | 1726 | side_event_call(my_provider_event_structgatherarray, |
d9359cfa | 1727 | side_arg_list( |
d41cb7ee MD |
1728 | side_arg_gather_struct(&mystruct), |
1729 | side_arg_gather_array(&mygatherarray2), | |
d9359cfa MD |
1730 | ) |
1731 | ); | |
1732 | } | |
1733 | } | |
1734 | ||
dd7947bf | 1735 | #define TESTSGNESTARRAY_LEN 4 |
d41cb7ee | 1736 | struct testgatherstructnest1 { |
dd7947bf MD |
1737 | int b; |
1738 | int c[TESTSGNESTARRAY_LEN]; | |
1739 | }; | |
1740 | ||
d41cb7ee MD |
1741 | struct testgatherstructnest0 { |
1742 | struct testgatherstructnest1 nest; | |
1743 | struct testgatherstructnest1 nestarray[2]; | |
dd7947bf MD |
1744 | int a; |
1745 | }; | |
1746 | ||
d41cb7ee | 1747 | static side_define_struct(mystructgatherstructnest1, |
dd7947bf | 1748 | side_field_list( |
d41cb7ee | 1749 | side_field_gather_signed_integer("b", offsetof(struct testgatherstructnest1, b), |
88bab79c | 1750 | side_struct_field_sizeof(struct testgatherstructnest1, b), 0, 0, |
84c04cc8 | 1751 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), |
d41cb7ee | 1752 | side_field_gather_array("c", |
dd7947bf | 1753 | side_elem( |
88bab79c | 1754 | side_type_gather_signed_integer(0, sizeof(uint32_t), 0, 0, |
84c04cc8 | 1755 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), |
dd7947bf MD |
1756 | ), |
1757 | TESTSGNESTARRAY_LEN, | |
d41cb7ee | 1758 | offsetof(struct testgatherstructnest1, c), |
84c04cc8 | 1759 | SIDE_TYPE_GATHER_ACCESS_DIRECT, |
dd7947bf MD |
1760 | side_attr_list()), |
1761 | ), | |
1762 | side_attr_list() | |
1763 | ); | |
1764 | ||
d41cb7ee | 1765 | static side_define_struct(mystructgatherstructnest0, |
dd7947bf | 1766 | side_field_list( |
d41cb7ee | 1767 | side_field_gather_signed_integer("a", offsetof(struct testgatherstructnest0, a), |
88bab79c | 1768 | side_struct_field_sizeof(struct testgatherstructnest0, a), 0, 0, |
84c04cc8 | 1769 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), |
d41cb7ee MD |
1770 | side_field_gather_struct("structnest0", &mystructgatherstructnest1, |
1771 | offsetof(struct testgatherstructnest0, nest), | |
1772 | sizeof(struct testgatherstructnest1), | |
84c04cc8 | 1773 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
d41cb7ee | 1774 | side_field_gather_array("nestarray", |
dd7947bf | 1775 | side_elem( |
d41cb7ee | 1776 | side_type_gather_struct(&mystructgatherstructnest1, |
dd7947bf | 1777 | 0, |
d41cb7ee | 1778 | sizeof(struct testgatherstructnest1), |
84c04cc8 | 1779 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
dd7947bf MD |
1780 | ), |
1781 | 2, | |
d41cb7ee | 1782 | offsetof(struct testgatherstructnest0, nestarray), |
84c04cc8 | 1783 | SIDE_TYPE_GATHER_ACCESS_DIRECT, |
dd7947bf MD |
1784 | side_attr_list()), |
1785 | ), | |
1786 | side_attr_list() | |
1787 | ); | |
1788 | ||
d41cb7ee MD |
1789 | side_static_event(my_provider_event_gatherstructnest, |
1790 | "myprovider", "myeventgatherstructnest", SIDE_LOGLEVEL_DEBUG, | |
dd7947bf | 1791 | side_field_list( |
d41cb7ee | 1792 | side_field_gather_struct("structgather", &mystructgatherstructnest0, 0, |
84c04cc8 | 1793 | sizeof(struct testgatherstructnest0), SIDE_TYPE_GATHER_ACCESS_DIRECT), |
dd7947bf MD |
1794 | ), |
1795 | side_attr_list() | |
1796 | ); | |
1797 | ||
1798 | static | |
d41cb7ee | 1799 | void test_gather_structnest(void) |
dd7947bf | 1800 | { |
d41cb7ee MD |
1801 | side_event_cond(my_provider_event_gatherstructnest) { |
1802 | struct testgatherstructnest0 mystruct = { | |
dd7947bf MD |
1803 | .nest = { |
1804 | .b = 66, | |
1805 | .c = { 0, 1, 2, 3 }, | |
1806 | }, | |
1807 | .nestarray = { | |
1808 | [0] = { | |
1809 | .b = 77, | |
1810 | .c = { 11, 12, 13, 14 }, | |
1811 | }, | |
1812 | [1] = { | |
1813 | .b = 88, | |
1814 | .c = { 15, 16, 17, 18 }, | |
1815 | }, | |
1816 | }, | |
1817 | .a = 55, | |
1818 | }; | |
d41cb7ee | 1819 | side_event_call(my_provider_event_gatherstructnest, |
dd7947bf | 1820 | side_arg_list( |
d41cb7ee | 1821 | side_arg_gather_struct(&mystruct), |
dd7947bf MD |
1822 | ) |
1823 | ); | |
1824 | } | |
1825 | } | |
1826 | ||
d41cb7ee | 1827 | uint32_t gathervla[] = { 1, 2, 3, 4 }; |
80429681 | 1828 | uint32_t gathervla2[] = { 5, 6, 7, 8, 9 }; |
65b8734a | 1829 | |
d41cb7ee | 1830 | struct testgathervla { |
65b8734a MD |
1831 | int a; |
1832 | uint16_t len; | |
1833 | uint32_t *p; | |
1834 | }; | |
1835 | ||
d41cb7ee | 1836 | static side_define_struct(mystructgathervla, |
65b8734a | 1837 | side_field_list( |
d41cb7ee | 1838 | side_field_gather_signed_integer("a", offsetof(struct testgathervla, a), |
88bab79c | 1839 | side_struct_field_sizeof(struct testgathervla, a), 0, 0, |
84c04cc8 | 1840 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list() |
65b8734a | 1841 | ), |
d41cb7ee | 1842 | side_field_gather_vla("nestvla", |
88bab79c | 1843 | side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), |
d41cb7ee MD |
1844 | offsetof(struct testgathervla, p), |
1845 | SIDE_TYPE_GATHER_ACCESS_POINTER, | |
1846 | side_length(side_type_gather_unsigned_integer(offsetof(struct testgathervla, len), | |
88bab79c | 1847 | sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), |
65b8734a MD |
1848 | side_attr_list() |
1849 | ), | |
1850 | ), | |
1851 | side_attr_list() | |
1852 | ); | |
1853 | ||
d41cb7ee MD |
1854 | side_static_event(my_provider_event_gathervla, |
1855 | "myprovider", "myeventgathervla", SIDE_LOGLEVEL_DEBUG, | |
65b8734a | 1856 | side_field_list( |
d41cb7ee | 1857 | side_field_gather_struct("structgathervla", &mystructgathervla, 0, |
84c04cc8 | 1858 | sizeof(struct testgathervla), SIDE_TYPE_GATHER_ACCESS_DIRECT), |
80429681 | 1859 | side_field_gather_vla("vla", |
88bab79c | 1860 | side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), |
84c04cc8 | 1861 | 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, |
88bab79c | 1862 | side_length(side_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), |
80429681 MD |
1863 | side_attr_list() |
1864 | ), | |
65b8734a MD |
1865 | ), |
1866 | side_attr_list() | |
1867 | ); | |
1868 | ||
1869 | static | |
d41cb7ee | 1870 | void test_gather_vla(void) |
65b8734a | 1871 | { |
d41cb7ee MD |
1872 | side_event_cond(my_provider_event_gathervla) { |
1873 | struct testgathervla mystruct = { | |
65b8734a | 1874 | .a = 55, |
d41cb7ee MD |
1875 | .len = SIDE_ARRAY_SIZE(gathervla), |
1876 | .p = gathervla, | |
65b8734a | 1877 | }; |
80429681 | 1878 | uint16_t vla2_len = 5; |
d41cb7ee | 1879 | side_event_call(my_provider_event_gathervla, |
65b8734a | 1880 | side_arg_list( |
d41cb7ee | 1881 | side_arg_gather_struct(&mystruct), |
80429681 | 1882 | side_arg_gather_vla(gathervla2, &vla2_len), |
65b8734a MD |
1883 | ) |
1884 | ); | |
1885 | } | |
1886 | } | |
1887 | ||
d41cb7ee | 1888 | struct testgathervlaflex { |
65b8734a MD |
1889 | uint8_t len; |
1890 | uint32_t otherfield; | |
1891 | uint64_t array[]; | |
1892 | }; | |
1893 | ||
d41cb7ee | 1894 | static side_define_struct(mystructgathervlaflex, |
65b8734a | 1895 | side_field_list( |
d41cb7ee | 1896 | side_field_gather_vla("vlaflex", |
88bab79c | 1897 | side_elem(side_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), |
d41cb7ee | 1898 | offsetof(struct testgathervlaflex, array), |
84c04cc8 | 1899 | SIDE_TYPE_GATHER_ACCESS_DIRECT, |
d41cb7ee | 1900 | side_length(side_type_gather_unsigned_integer(offsetof(struct testgathervlaflex, len), |
88bab79c | 1901 | side_struct_field_sizeof(struct testgathervlaflex, len), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), |
65b8734a MD |
1902 | side_attr_list() |
1903 | ), | |
1904 | ), | |
1905 | side_attr_list() | |
1906 | ); | |
1907 | ||
d41cb7ee MD |
1908 | side_static_event(my_provider_event_gathervlaflex, |
1909 | "myprovider", "myeventgathervlaflex", SIDE_LOGLEVEL_DEBUG, | |
65b8734a | 1910 | side_field_list( |
d41cb7ee | 1911 | side_field_gather_struct("structgathervlaflex", &mystructgathervlaflex, 0, |
84c04cc8 | 1912 | sizeof(struct testgathervlaflex), SIDE_TYPE_GATHER_ACCESS_DIRECT), |
65b8734a MD |
1913 | ), |
1914 | side_attr_list() | |
1915 | ); | |
1916 | ||
1917 | #define VLAFLEXLEN 6 | |
1918 | static | |
d41cb7ee | 1919 | void test_gather_vla_flex(void) |
65b8734a | 1920 | { |
d41cb7ee | 1921 | side_event_cond(my_provider_event_gathervlaflex) { |
358281a1 MD |
1922 | struct testgathervlaflex *mystruct = |
1923 | (struct testgathervlaflex *) malloc(sizeof(*mystruct) + VLAFLEXLEN + sizeof(uint64_t)); | |
65b8734a MD |
1924 | |
1925 | mystruct->len = VLAFLEXLEN; | |
1926 | mystruct->otherfield = 0; | |
1927 | mystruct->array[0] = 1; | |
1928 | mystruct->array[1] = 2; | |
1929 | mystruct->array[2] = 3; | |
1930 | mystruct->array[3] = 4; | |
1931 | mystruct->array[4] = 5; | |
1932 | mystruct->array[5] = 6; | |
d41cb7ee | 1933 | side_event_call(my_provider_event_gathervlaflex, |
65b8734a | 1934 | side_arg_list( |
d41cb7ee | 1935 | side_arg_gather_struct(mystruct), |
65b8734a MD |
1936 | ) |
1937 | ); | |
1938 | free(mystruct); | |
1939 | } | |
1940 | } | |
1941 | ||
d69918cc MD |
1942 | side_static_event(my_provider_event_gatherbyte, |
1943 | "myprovider", "myeventgatherbyte", SIDE_LOGLEVEL_DEBUG, | |
1944 | side_field_list( | |
84c04cc8 | 1945 | side_field_gather_byte("byte", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), |
d69918cc | 1946 | side_field_gather_array("array", |
84c04cc8 MD |
1947 | side_elem(side_type_gather_byte(0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), |
1948 | 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list() | |
d69918cc MD |
1949 | ), |
1950 | ), | |
1951 | side_attr_list() | |
1952 | ); | |
1953 | ||
1954 | static | |
1955 | void test_gather_byte(void) | |
1956 | { | |
ff69662a | 1957 | side_event_cond(my_provider_event_structgatherbyte) { |
d69918cc MD |
1958 | uint8_t v = 0x44; |
1959 | uint8_t array[3] = { 0x1, 0x2, 0x3 }; | |
1960 | ||
1961 | side_event_call(my_provider_event_gatherbyte, | |
1962 | side_arg_list( | |
1963 | side_arg_gather_byte(&v), | |
1964 | side_arg_gather_array(array), | |
1965 | ) | |
1966 | ); | |
1967 | } | |
1968 | } | |
1969 | ||
8ad2f385 MD |
1970 | #define ARRAYBOOLLEN 4 |
1971 | static bool arraybool[ARRAYBOOLLEN] = { false, true, false, true }; | |
1972 | ||
1973 | side_static_event(my_provider_event_gatherbool, | |
1974 | "myprovider", "myeventgatherbool", SIDE_LOGLEVEL_DEBUG, | |
1975 | side_field_list( | |
88bab79c MD |
1976 | side_field_gather_bool("v1_true", 0, sizeof(bool), 0, 0, |
1977 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), | |
1978 | side_field_gather_bool("v2_false", 0, sizeof(bool), 0, 0, | |
1979 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), | |
1980 | side_field_gather_bool("v3_true", 0, sizeof(uint16_t), 1, 1, | |
8ad2f385 | 1981 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), |
88bab79c | 1982 | side_field_gather_bool("v4_false", 0, sizeof(uint16_t), 1, 1, |
8ad2f385 | 1983 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), |
8ad2f385 | 1984 | side_field_gather_array("arraybool", |
88bab79c MD |
1985 | side_elem(side_type_gather_bool(0, sizeof(bool), 0, 0, |
1986 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), | |
8ad2f385 MD |
1987 | ARRAYBOOLLEN, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list() |
1988 | ), | |
1989 | ), | |
1990 | side_attr_list() | |
1991 | ); | |
1992 | ||
1993 | static | |
1994 | void test_gather_bool(void) | |
1995 | { | |
1996 | side_event_cond(my_provider_event_structgatherarray) { | |
1997 | bool v1 = true; | |
1998 | bool v2 = false; | |
1999 | uint16_t v3 = 1U << 1; | |
2000 | uint16_t v4 = 1U << 2; | |
2001 | ||
2002 | side_event_call(my_provider_event_gatherbool, | |
2003 | side_arg_list( | |
2004 | side_arg_gather_bool(&v1), | |
2005 | side_arg_gather_bool(&v2), | |
2006 | side_arg_gather_bool(&v3), | |
2007 | side_arg_gather_bool(&v4), | |
2008 | side_arg_gather_array(arraybool), | |
2009 | ) | |
2010 | ); | |
2011 | } | |
2012 | } | |
2013 | ||
4e1b0e0e MD |
2014 | side_static_event(my_provider_event_gatherpointer, |
2015 | "myprovider", "myeventgatherpointer", SIDE_LOGLEVEL_DEBUG, | |
2016 | side_field_list( | |
2017 | side_field_gather_pointer("ptr", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), | |
2018 | side_field_gather_array("array", | |
2019 | side_elem(side_type_gather_pointer(0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), | |
2020 | 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list() | |
2021 | ), | |
2022 | ), | |
2023 | side_attr_list() | |
2024 | ); | |
2025 | ||
2026 | static | |
2027 | void test_gather_pointer(void) | |
2028 | { | |
2029 | side_event_cond(my_provider_event_structgatherarray) { | |
2030 | void *v = (void *)0x44; | |
2031 | void *array[3] = { (void *)0x1, (void *)0x2, (void *)0x3 }; | |
2032 | ||
2033 | side_event_call(my_provider_event_gatherpointer, | |
2034 | side_arg_list( | |
2035 | side_arg_gather_pointer(&v), | |
2036 | side_arg_gather_array(array), | |
2037 | ) | |
2038 | ); | |
2039 | } | |
2040 | } | |
0519cb86 MD |
2041 | |
2042 | static side_define_enum(myenumgather, | |
2043 | side_enum_mapping_list( | |
2044 | side_enum_mapping_range("one-ten", 1, 10), | |
2045 | side_enum_mapping_range("100-200", 100, 200), | |
2046 | side_enum_mapping_value("200", 200), | |
2047 | side_enum_mapping_value("300", 300), | |
2048 | ), | |
2049 | side_attr_list() | |
2050 | ); | |
2051 | ||
2052 | side_static_event(my_provider_event_enum_gather, "myprovider", "myeventenumgather", SIDE_LOGLEVEL_DEBUG, | |
2053 | side_field_list( | |
2054 | side_field_gather_enum("5", &myenumgather, | |
2055 | side_elem( | |
2056 | side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, | |
2057 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()) | |
2058 | ) | |
2059 | ), | |
2060 | side_field_gather_enum("400", &myenumgather, | |
2061 | side_elem( | |
2062 | side_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, | |
2063 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()) | |
2064 | ) | |
2065 | ), | |
2066 | side_field_gather_enum("200", &myenumgather, | |
2067 | side_elem( | |
2068 | side_type_gather_unsigned_integer(0, sizeof(uint8_t), 0, 0, | |
2069 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()) | |
2070 | ) | |
2071 | ), | |
2072 | side_field_gather_enum("-100", &myenumgather, | |
2073 | side_elem( | |
2074 | side_type_gather_signed_integer(0, sizeof(int8_t), 0, 0, | |
2075 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()) | |
2076 | ) | |
2077 | ), | |
2078 | side_field_gather_enum("6_be", &myenumgather, | |
2079 | side_elem( | |
2080 | side_type_gather_unsigned_integer_be(0, sizeof(uint32_t), 0, 0, | |
2081 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()) | |
2082 | ) | |
2083 | ), | |
2084 | side_field_gather_enum("6_le", &myenumgather, | |
2085 | side_elem( | |
2086 | side_type_gather_unsigned_integer_le(0, sizeof(uint32_t), 0, 0, | |
2087 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()) | |
2088 | ) | |
2089 | ), | |
2090 | ), | |
2091 | side_attr_list() | |
2092 | ); | |
2093 | ||
2094 | static | |
2095 | void test_gather_enum(void) | |
2096 | { | |
2097 | uint32_t v1 = 5; | |
2098 | uint64_t v2 = 400; | |
2099 | uint8_t v3 = 200; | |
2100 | int8_t v4 = -100; | |
2101 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN | |
2102 | uint32_t v5 = side_bswap_32(6); | |
2103 | uint32_t v6 = 6; | |
2104 | #else | |
2105 | uint32_t v5 = 6; | |
2106 | uint32_t v6 = side_bswap_32(6); | |
2107 | #endif | |
2108 | ||
2109 | side_event(my_provider_event_enum_gather, | |
2110 | side_arg_list( | |
2111 | side_arg_gather_integer(&v1), | |
2112 | side_arg_gather_integer(&v2), | |
2113 | side_arg_gather_integer(&v3), | |
2114 | side_arg_gather_integer(&v4), | |
2115 | side_arg_gather_integer(&v5), | |
2116 | side_arg_gather_integer(&v6), | |
2117 | ) | |
2118 | ); | |
2119 | } | |
2120 | ||
f611d0c3 MD |
2121 | int main() |
2122 | { | |
2123 | test_fields(); | |
89747802 MD |
2124 | test_event_hidden(); |
2125 | test_event_export(); | |
c7a14585 | 2126 | test_struct_literal(); |
f611d0c3 MD |
2127 | test_struct(); |
2128 | test_array(); | |
2129 | test_vla(); | |
2130 | test_vla_visitor(); | |
cdd6e858 | 2131 | test_vla_visitor_2d(); |
a2e2357e MD |
2132 | test_dynamic_basic_type(); |
2133 | test_dynamic_vla(); | |
465e5e7e | 2134 | test_dynamic_null(); |
c208889e MD |
2135 | test_dynamic_struct(); |
2136 | test_dynamic_nested_struct(); | |
2137 | test_dynamic_vla_struct(); | |
2138 | test_dynamic_struct_vla(); | |
948e3e72 | 2139 | test_dynamic_nested_vla(); |
19fa6aa2 | 2140 | test_variadic(); |
41c4d119 | 2141 | test_static_variadic(); |
4f40d951 MD |
2142 | test_bool(); |
2143 | test_dynamic_bool(); | |
8ceca0cd | 2144 | test_dynamic_vla_with_visitor(); |
2b359235 | 2145 | test_dynamic_struct_with_visitor(); |
65010f43 | 2146 | test_event_user_attribute(); |
a848763d | 2147 | test_field_user_attribute(); |
808bd9bf MD |
2148 | test_variadic_attr(); |
2149 | test_variadic_vla_attr(); | |
2150 | test_variadic_struct_attr(); | |
fb25b355 MD |
2151 | test_float(); |
2152 | test_variadic_float(); | |
79f677ba | 2153 | test_enum(); |
ea32e5fc | 2154 | test_enum_bitmap(); |
7aec0d09 | 2155 | test_blob(); |
71aa8975 | 2156 | test_fmt_string(); |
8bdd5c12 | 2157 | test_endian(); |
1d9c515c | 2158 | test_base(); |
d41cb7ee MD |
2159 | test_struct_gather(); |
2160 | test_struct_gather_nest_ptr(); | |
2161 | test_struct_gather_float(); | |
2162 | test_array_gather(); | |
2163 | test_gather_structnest(); | |
2164 | test_gather_vla(); | |
2165 | test_gather_vla_flex(); | |
d69918cc | 2166 | test_gather_byte(); |
8ad2f385 | 2167 | test_gather_bool(); |
4e1b0e0e | 2168 | test_gather_pointer(); |
0519cb86 | 2169 | test_gather_enum(); |
f611d0c3 MD |
2170 | return 0; |
2171 | } |