1 // SPDX-License-Identifier: MIT
3 * Copyright 2022 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 #include <side/trace.h>
15 /* User code example */
17 side_static_event(my_provider_event
, "myprovider", "myevent", SIDE_LOGLEVEL_DEBUG
,
19 side_field_u32("abc", side_attr_list()),
20 side_field_s64("def", side_attr_list()),
21 side_field_pointer("ptr", side_attr_list()),
22 side_field_dynamic("dynamic"),
23 side_field_dynamic("dynamic_pointer"),
24 side_field_null("null", side_attr_list()),
30 void test_fields(void)
35 side_event(my_provider_event
,
39 side_arg_pointer((void *) 0x1),
40 side_arg_dynamic_string("zzz", side_attr_list()),
41 side_arg_dynamic_pointer((void *) 0x1, side_attr_list()),
47 side_hidden_event(my_provider_event_hidden
, "myprovider", "myeventhidden", SIDE_LOGLEVEL_DEBUG
,
49 side_field_u32("abc", side_attr_list()),
55 void test_event_hidden(void)
57 side_event(my_provider_event_hidden
, side_arg_list(side_arg_u32(2)));
60 side_declare_event(my_provider_event_export
);
62 side_export_event(my_provider_event_export
, "myprovider", "myeventexport", SIDE_LOGLEVEL_DEBUG
,
64 side_field_u32("abc", side_attr_list()),
70 void test_event_export(void)
72 side_event(my_provider_event_export
, side_arg_list(side_arg_u32(2)));
75 side_static_event(my_provider_event_struct_literal
, "myprovider", "myeventstructliteral", SIDE_LOGLEVEL_DEBUG
,
77 side_field_struct("structliteral",
80 side_field_u32("x", side_attr_list()),
81 side_field_s64("y", side_attr_list()),
86 side_field_u8("z", side_attr_list()),
92 void test_struct_literal(void)
94 side_event_cond(my_provider_event_struct_literal
) {
95 side_arg_define_vec(mystruct
, side_arg_list(side_arg_u32(21), side_arg_s64(22)));
96 side_event_call(my_provider_event_struct_literal
, side_arg_list(side_arg_struct(&mystruct
), side_arg_u8(55)));
100 static side_define_struct(mystructdef
,
102 side_field_u32("x", side_attr_list()),
103 side_field_s64("y", side_attr_list()),
108 side_static_event(my_provider_event_struct
, "myprovider", "myeventstruct", SIDE_LOGLEVEL_DEBUG
,
110 side_field_struct("struct", &mystructdef
),
111 side_field_u8("z", side_attr_list()),
117 void test_struct(void)
119 side_event_cond(my_provider_event_struct
) {
120 side_arg_define_vec(mystruct
, side_arg_list(side_arg_u32(21), side_arg_s64(22)));
121 side_event_call(my_provider_event_struct
, side_arg_list(side_arg_struct(&mystruct
), side_arg_u8(55)));
125 side_static_event(my_provider_event_array
, "myprovider", "myarray", SIDE_LOGLEVEL_DEBUG
,
127 side_field_array("arr", side_elem(side_type_u32(side_attr_list())), 3, side_attr_list()),
128 side_field_s64("v", side_attr_list()),
134 void test_array(void)
136 side_event_cond(my_provider_event_array
) {
137 side_arg_define_vec(myarray
, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3)));
138 side_event_call(my_provider_event_array
, side_arg_list(side_arg_array(&myarray
), side_arg_s64(42)));
142 side_static_event(my_provider_event_vla
, "myprovider", "myvla", SIDE_LOGLEVEL_DEBUG
,
144 side_field_vla("vla", side_elem(side_type_u32(side_attr_list())), side_attr_list()),
145 side_field_s64("v", side_attr_list()),
153 side_event_cond(my_provider_event_vla
) {
154 side_arg_define_vec(myvla
, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3)));
155 side_event_call(my_provider_event_vla
, side_arg_list(side_arg_vla(&myvla
), side_arg_s64(42)));
159 /* 1D array visitor */
161 struct app_visitor_ctx
{
167 enum side_visitor_status
test_visitor(const struct side_tracer_visitor_ctx
*tracer_ctx
, void *_ctx
)
169 struct app_visitor_ctx
*ctx
= (struct app_visitor_ctx
*) _ctx
;
170 uint32_t length
= ctx
->length
, i
;
172 for (i
= 0; i
< length
; i
++) {
173 const struct side_arg elem
= side_arg_u32(ctx
->ptr
[i
]);
175 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != SIDE_VISITOR_STATUS_OK
)
176 return SIDE_VISITOR_STATUS_ERROR
;
178 return SIDE_VISITOR_STATUS_OK
;
181 static uint32_t testarray
[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
183 side_static_event(my_provider_event_vla_visitor
, "myprovider", "myvlavisit", SIDE_LOGLEVEL_DEBUG
,
185 side_field_vla_visitor("vlavisit", side_elem(side_type_u32(side_attr_list())), test_visitor
, side_attr_list()),
186 side_field_s64("v", side_attr_list()),
192 void test_vla_visitor(void)
194 side_event_cond(my_provider_event_vla_visitor
) {
195 struct app_visitor_ctx ctx
= {
197 .length
= SIDE_ARRAY_SIZE(testarray
),
199 side_event_call(my_provider_event_vla_visitor
, side_arg_list(side_arg_vla_visitor(&ctx
), side_arg_s64(42)));
203 /* 2D array visitor */
205 struct app_visitor_2d_inner_ctx
{
211 enum side_visitor_status
test_inner_visitor(const struct side_tracer_visitor_ctx
*tracer_ctx
, void *_ctx
)
213 struct app_visitor_2d_inner_ctx
*ctx
= (struct app_visitor_2d_inner_ctx
*) _ctx
;
214 uint32_t length
= ctx
->length
, i
;
216 for (i
= 0; i
< length
; i
++) {
217 const struct side_arg elem
= side_arg_u32(ctx
->ptr
[i
]);
219 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != SIDE_VISITOR_STATUS_OK
)
220 return SIDE_VISITOR_STATUS_ERROR
;
222 return SIDE_VISITOR_STATUS_OK
;
225 struct app_visitor_2d_outer_ctx
{
226 const uint32_t (*ptr
)[2];
231 enum side_visitor_status
test_outer_visitor(const struct side_tracer_visitor_ctx
*tracer_ctx
, void *_ctx
)
233 struct app_visitor_2d_outer_ctx
*ctx
= (struct app_visitor_2d_outer_ctx
*) _ctx
;
234 uint32_t length
= ctx
->length
, i
;
236 for (i
= 0; i
< length
; i
++) {
237 struct app_visitor_2d_inner_ctx inner_ctx
= {
241 const struct side_arg elem
= side_arg_vla_visitor(&inner_ctx
);
242 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != SIDE_VISITOR_STATUS_OK
)
243 return SIDE_VISITOR_STATUS_ERROR
;
245 return SIDE_VISITOR_STATUS_OK
;
248 static uint32_t testarray2d
[][2] = {
254 side_static_event(my_provider_event_vla_visitor2d
, "myprovider", "myvlavisit2d", SIDE_LOGLEVEL_DEBUG
,
256 side_field_vla_visitor("vlavisit2d",
258 side_type_vla_visitor(
259 side_elem(side_type_u32(side_attr_list())),
262 ), test_outer_visitor
, side_attr_list()),
263 side_field_s64("v", side_attr_list()),
269 void test_vla_visitor_2d(void)
271 side_event_cond(my_provider_event_vla_visitor2d
) {
272 struct app_visitor_2d_outer_ctx ctx
= {
274 .length
= SIDE_ARRAY_SIZE(testarray2d
),
276 side_event_call(my_provider_event_vla_visitor2d
, side_arg_list(side_arg_vla_visitor(&ctx
), side_arg_s64(42)));
280 side_static_event(my_provider_event_dynamic_basic
,
281 "myprovider", "mydynamicbasic", SIDE_LOGLEVEL_DEBUG
,
283 side_field_dynamic("dynamic"),
289 void test_dynamic_basic_type(void)
291 side_event(my_provider_event_dynamic_basic
,
292 side_arg_list(side_arg_dynamic_s16(-33, side_attr_list())));
295 side_static_event(my_provider_event_dynamic_vla
,
296 "myprovider", "mydynamicvla", SIDE_LOGLEVEL_DEBUG
,
298 side_field_dynamic("dynamic"),
304 void test_dynamic_vla(void)
306 side_arg_dynamic_define_vec(myvla
,
308 side_arg_dynamic_u32(1, side_attr_list()),
309 side_arg_dynamic_u32(2, side_attr_list()),
310 side_arg_dynamic_u32(3, side_attr_list()),
314 side_event(my_provider_event_dynamic_vla
,
315 side_arg_list(side_arg_dynamic_vla(&myvla
)));
318 side_static_event(my_provider_event_dynamic_null
,
319 "myprovider", "mydynamicnull", SIDE_LOGLEVEL_DEBUG
,
321 side_field_dynamic("dynamic"),
327 void test_dynamic_null(void)
329 side_event(my_provider_event_dynamic_null
,
330 side_arg_list(side_arg_dynamic_null(side_attr_list())));
333 side_static_event(my_provider_event_dynamic_struct
,
334 "myprovider", "mydynamicstruct", SIDE_LOGLEVEL_DEBUG
,
336 side_field_dynamic("dynamic"),
342 void test_dynamic_struct(void)
344 side_arg_dynamic_define_struct(mystruct
,
346 side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())),
347 side_arg_dynamic_field("b", side_arg_dynamic_string("zzz", side_attr_list())),
348 side_arg_dynamic_field("c", side_arg_dynamic_null(side_attr_list())),
353 side_event(my_provider_event_dynamic_struct
,
354 side_arg_list(side_arg_dynamic_struct(&mystruct
)));
357 side_static_event(my_provider_event_dynamic_nested_struct
,
358 "myprovider", "mydynamicnestedstruct", SIDE_LOGLEVEL_DEBUG
,
360 side_field_dynamic("dynamic"),
366 void test_dynamic_nested_struct(void)
368 side_arg_dynamic_define_struct(nested
,
370 side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())),
371 side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())),
375 side_arg_dynamic_define_struct(nested2
,
377 side_arg_dynamic_field("aa", side_arg_dynamic_u64(128, side_attr_list())),
378 side_arg_dynamic_field("bb", side_arg_dynamic_u16(1, side_attr_list())),
382 side_arg_dynamic_define_struct(mystruct
,
384 side_arg_dynamic_field("nested", side_arg_dynamic_struct(&nested
)),
385 side_arg_dynamic_field("nested2", side_arg_dynamic_struct(&nested2
)),
389 side_event(my_provider_event_dynamic_nested_struct
,
390 side_arg_list(side_arg_dynamic_struct(&mystruct
)));
393 side_static_event(my_provider_event_dynamic_vla_struct
,
394 "myprovider", "mydynamicvlastruct", SIDE_LOGLEVEL_DEBUG
,
396 side_field_dynamic("dynamic"),
402 void test_dynamic_vla_struct(void)
404 side_arg_dynamic_define_struct(nested
,
406 side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())),
407 side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())),
411 side_arg_dynamic_define_vec(myvla
,
413 side_arg_dynamic_struct(&nested
),
414 side_arg_dynamic_struct(&nested
),
415 side_arg_dynamic_struct(&nested
),
416 side_arg_dynamic_struct(&nested
),
420 side_event(my_provider_event_dynamic_vla_struct
,
421 side_arg_list(side_arg_dynamic_vla(&myvla
)));
424 side_static_event(my_provider_event_dynamic_struct_vla
,
425 "myprovider", "mydynamicstructvla", SIDE_LOGLEVEL_DEBUG
,
427 side_field_dynamic("dynamic"),
433 void test_dynamic_struct_vla(void)
435 side_arg_dynamic_define_vec(myvla
,
437 side_arg_dynamic_u32(1, side_attr_list()),
438 side_arg_dynamic_u32(2, side_attr_list()),
439 side_arg_dynamic_u32(3, side_attr_list()),
443 side_arg_dynamic_define_vec(myvla2
,
445 side_arg_dynamic_u32(4, side_attr_list()),
446 side_arg_dynamic_u64(5, side_attr_list()),
447 side_arg_dynamic_u32(6, side_attr_list()),
451 side_arg_dynamic_define_struct(mystruct
,
453 side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla
)),
454 side_arg_dynamic_field("b", side_arg_dynamic_vla(&myvla2
)),
458 side_event(my_provider_event_dynamic_struct_vla
,
459 side_arg_list(side_arg_dynamic_struct(&mystruct
)));
462 side_static_event(my_provider_event_dynamic_nested_vla
,
463 "myprovider", "mydynamicnestedvla", SIDE_LOGLEVEL_DEBUG
,
465 side_field_dynamic("dynamic"),
471 void test_dynamic_nested_vla(void)
473 side_arg_dynamic_define_vec(nestedvla
,
475 side_arg_dynamic_u32(1, side_attr_list()),
476 side_arg_dynamic_u16(2, side_attr_list()),
477 side_arg_dynamic_u32(3, side_attr_list()),
481 side_arg_dynamic_define_vec(nestedvla2
,
483 side_arg_dynamic_u8(4, side_attr_list()),
484 side_arg_dynamic_u32(5, side_attr_list()),
485 side_arg_dynamic_u32(6, side_attr_list()),
489 side_arg_dynamic_define_vec(myvla
,
491 side_arg_dynamic_vla(&nestedvla
),
492 side_arg_dynamic_vla(&nestedvla2
),
496 side_event(my_provider_event_dynamic_nested_vla
,
497 side_arg_list(side_arg_dynamic_vla(&myvla
)));
500 side_static_event_variadic(my_provider_event_variadic
,
501 "myprovider", "myvariadicevent", SIDE_LOGLEVEL_DEBUG
,
507 void test_variadic(void)
509 side_event_variadic(my_provider_event_variadic
,
512 side_arg_dynamic_field("a", side_arg_dynamic_u32(55, side_attr_list())),
513 side_arg_dynamic_field("b", side_arg_dynamic_s8(-4, side_attr_list())),
519 side_static_event_variadic(my_provider_event_static_variadic
,
520 "myprovider", "mystaticvariadicevent", SIDE_LOGLEVEL_DEBUG
,
522 side_field_u32("abc", side_attr_list()),
523 side_field_u16("def", side_attr_list()),
529 void test_static_variadic(void)
531 side_event_variadic(my_provider_event_static_variadic
,
537 side_arg_dynamic_field("a", side_arg_dynamic_u32(55, side_attr_list())),
538 side_arg_dynamic_field("b", side_arg_dynamic_s8(-4, side_attr_list())),
544 side_static_event(my_provider_event_bool
, "myprovider", "myeventbool", SIDE_LOGLEVEL_DEBUG
,
546 side_field_bool("a_false", side_attr_list()),
547 side_field_bool("b_true", side_attr_list()),
548 side_field_bool("c_true", side_attr_list()),
549 side_field_bool("d_true", side_attr_list()),
550 side_field_bool("e_true", side_attr_list()),
551 side_field_bool("f_false", side_attr_list()),
552 side_field_bool("g_true", side_attr_list()),
562 uint64_t c
= 0x12345678;
568 side_event(my_provider_event_bool
,
581 side_static_event_variadic(my_provider_event_dynamic_bool
,
582 "myprovider", "mydynamicbool", SIDE_LOGLEVEL_DEBUG
,
588 void test_dynamic_bool(void)
590 side_event_variadic(my_provider_event_dynamic_bool
,
593 side_arg_dynamic_field("a_true", side_arg_dynamic_bool(55, side_attr_list())),
594 side_arg_dynamic_field("b_true", side_arg_dynamic_bool(-4, side_attr_list())),
595 side_arg_dynamic_field("c_false", side_arg_dynamic_bool(0, side_attr_list())),
596 side_arg_dynamic_field("d_true", side_arg_dynamic_bool(256, side_attr_list())),
602 side_static_event(my_provider_event_dynamic_vla_visitor
,
603 "myprovider", "mydynamicvlavisitor", SIDE_LOGLEVEL_DEBUG
,
605 side_field_dynamic("dynamic"),
610 struct app_dynamic_vla_visitor_ctx
{
616 enum side_visitor_status
test_dynamic_vla_visitor(const struct side_tracer_visitor_ctx
*tracer_ctx
, void *_ctx
)
618 struct app_dynamic_vla_visitor_ctx
*ctx
= (struct app_dynamic_vla_visitor_ctx
*) _ctx
;
619 uint32_t length
= ctx
->length
, i
;
621 for (i
= 0; i
< length
; i
++) {
622 const struct side_arg elem
= side_arg_dynamic_u32(ctx
->ptr
[i
], side_attr_list());
623 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != SIDE_VISITOR_STATUS_OK
)
624 return SIDE_VISITOR_STATUS_ERROR
;
626 return SIDE_VISITOR_STATUS_OK
;
629 static uint32_t testarray_dynamic_vla
[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
632 void test_dynamic_vla_with_visitor(void)
634 side_event_cond(my_provider_event_dynamic_vla_visitor
) {
635 struct app_dynamic_vla_visitor_ctx ctx
= {
636 .ptr
= testarray_dynamic_vla
,
637 .length
= SIDE_ARRAY_SIZE(testarray_dynamic_vla
),
639 side_event_call(my_provider_event_dynamic_vla_visitor
,
641 side_arg_dynamic_vla_visitor(test_dynamic_vla_visitor
, &ctx
, side_attr_list())
647 side_static_event(my_provider_event_dynamic_struct_visitor
,
648 "myprovider", "mydynamicstructvisitor", SIDE_LOGLEVEL_DEBUG
,
650 side_field_dynamic("dynamic"),
655 struct struct_visitor_pair
{
660 struct app_dynamic_struct_visitor_ctx
{
661 const struct struct_visitor_pair
*ptr
;
666 enum side_visitor_status
test_dynamic_struct_visitor(const struct side_tracer_dynamic_struct_visitor_ctx
*tracer_ctx
, void *_ctx
)
668 struct app_dynamic_struct_visitor_ctx
*ctx
= (struct app_dynamic_struct_visitor_ctx
*) _ctx
;
669 uint32_t length
= ctx
->length
, i
;
671 for (i
= 0; i
< length
; i
++) {
672 struct side_arg_dynamic_field dynamic_field
= {
673 .field_name
= ctx
->ptr
[i
].name
,
674 .elem
= side_arg_dynamic_u32(ctx
->ptr
[i
].value
, side_attr_list()),
676 if (tracer_ctx
->write_field(tracer_ctx
, &dynamic_field
) != SIDE_VISITOR_STATUS_OK
)
677 return SIDE_VISITOR_STATUS_ERROR
;
679 return SIDE_VISITOR_STATUS_OK
;
682 static struct struct_visitor_pair testarray_dynamic_struct
[] = {
690 void test_dynamic_struct_with_visitor(void)
692 side_event_cond(my_provider_event_dynamic_struct_visitor
) {
693 struct app_dynamic_struct_visitor_ctx ctx
= {
694 .ptr
= testarray_dynamic_struct
,
695 .length
= SIDE_ARRAY_SIZE(testarray_dynamic_struct
),
697 side_event_call(my_provider_event_dynamic_struct_visitor
,
699 side_arg_dynamic_struct_visitor(test_dynamic_struct_visitor
, &ctx
, side_attr_list())
705 side_static_event(my_provider_event_user_attribute
, "myprovider", "myevent_user_attribute", SIDE_LOGLEVEL_DEBUG
,
707 side_field_u32("abc", side_attr_list()),
708 side_field_s64("def", side_attr_list()),
711 side_attr("user_attribute_a", side_attr_string("val1")),
712 side_attr("user_attribute_b", side_attr_string("val2")),
717 void test_event_user_attribute(void)
719 side_event(my_provider_event_user_attribute
, side_arg_list(side_arg_u32(1), side_arg_s64(2)));
722 side_static_event(my_provider_field_user_attribute
, "myprovider", "myevent_field_attribute", SIDE_LOGLEVEL_DEBUG
,
724 side_field_u32("abc",
726 side_attr("user_attribute_a", side_attr_string("val1")),
727 side_attr("user_attribute_b", side_attr_u32(2)),
730 side_field_s64("def",
732 side_attr("user_attribute_c", side_attr_string("val3")),
733 side_attr("user_attribute_d", side_attr_s64(-5)),
741 void test_field_user_attribute(void)
743 side_event(my_provider_field_user_attribute
, side_arg_list(side_arg_u32(1), side_arg_s64(2)));
746 side_static_event_variadic(my_provider_event_variadic_attr
,
747 "myprovider", "myvariadiceventattr", SIDE_LOGLEVEL_DEBUG
,
753 void test_variadic_attr(void)
755 side_event_variadic(my_provider_event_variadic_attr
,
758 side_arg_dynamic_field("a",
759 side_arg_dynamic_u32(55,
761 side_attr("user_attribute_c", side_attr_string("valX")),
762 side_attr("user_attribute_d", side_attr_u8(55)),
766 side_arg_dynamic_field("b",
767 side_arg_dynamic_s8(-4,
769 side_attr("X", side_attr_u8(1)),
770 side_attr("Y", side_attr_s8(2)),
779 side_static_event_variadic(my_provider_event_variadic_vla_attr
,
780 "myprovider", "myvariadiceventvlaattr", SIDE_LOGLEVEL_DEBUG
,
786 void test_variadic_vla_attr(void)
788 side_arg_dynamic_define_vec(myvla
,
790 side_arg_dynamic_u32(1,
792 side_attr("Z", side_attr_u8(0)),
793 side_attr("A", side_attr_u8(123)),
796 side_arg_dynamic_u32(2, side_attr_list()),
797 side_arg_dynamic_u32(3, side_attr_list()),
800 side_attr("X", side_attr_u8(1)),
801 side_attr("Y", side_attr_u8(2)),
804 side_event_variadic(my_provider_event_variadic_vla_attr
,
807 side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla
)),
813 side_static_event_variadic(my_provider_event_variadic_struct_attr
,
814 "myprovider", "myvariadiceventstructattr", SIDE_LOGLEVEL_DEBUG
,
820 void test_variadic_struct_attr(void)
822 side_event_cond(my_provider_event_variadic_struct_attr
) {
823 side_arg_dynamic_define_struct(mystruct
,
825 side_arg_dynamic_field("a",
826 side_arg_dynamic_u32(43,
828 side_attr("A", side_attr_bool(true)),
832 side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())),
835 side_attr("X", side_attr_u8(1)),
836 side_attr("Y", side_attr_u8(2)),
839 side_event_call_variadic(my_provider_event_variadic_struct_attr
,
842 side_arg_dynamic_field("a", side_arg_dynamic_struct(&mystruct
)),
849 side_static_event(my_provider_event_float
, "myprovider", "myeventfloat", SIDE_LOGLEVEL_DEBUG
,
852 side_field_float_binary16("binary16", side_attr_list()),
853 side_field_float_binary16_le("binary16_le", side_attr_list()),
854 side_field_float_binary16_be("binary16_be", side_attr_list()),
857 side_field_float_binary32("binary32", side_attr_list()),
858 side_field_float_binary32_le("binary32_le", side_attr_list()),
859 side_field_float_binary32_be("binary32_be", side_attr_list()),
862 side_field_float_binary64("binary64", side_attr_list()),
863 side_field_float_binary64_le("binary64_le", side_attr_list()),
864 side_field_float_binary64_be("binary64_be", side_attr_list()),
867 side_field_float_binary128("binary128", side_attr_list()),
868 side_field_float_binary128_le("binary128_le", side_attr_list()),
869 side_field_float_binary128_be("binary128_be", side_attr_list()),
876 void test_float(void)
912 float16
.u
= side_bswap_16(float16
.u
);
915 float32
.u
= side_bswap_32(float32
.u
);
918 float64
.u
= side_bswap_64(float64
.u
);
921 side_bswap_128p(float128
.arr
);
924 side_event(my_provider_event_float
,
927 side_arg_float_binary16(1.1),
928 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
929 side_arg_float_binary16(1.1),
930 side_arg_float_binary16(float16
.f
),
932 side_arg_float_binary16(float16
.f
),
933 side_arg_float_binary16(1.1),
937 side_arg_float_binary32(2.2),
938 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
939 side_arg_float_binary32(2.2),
940 side_arg_float_binary32(float32
.f
),
942 side_arg_float_binary32(float32
.f
),
943 side_arg_float_binary32(2.2),
947 side_arg_float_binary64(3.3),
948 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
949 side_arg_float_binary64(3.3),
950 side_arg_float_binary64(float64
.f
),
952 side_arg_float_binary64(float64
.f
),
953 side_arg_float_binary64(3.3),
957 side_arg_float_binary128(4.4),
958 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
959 side_arg_float_binary128(4.4),
960 side_arg_float_binary128(float128
.f
),
962 side_arg_float_binary128(float128
.f
),
963 side_arg_float_binary128(4.4),
970 side_static_event_variadic(my_provider_event_variadic_float
,
971 "myprovider", "myvariadicfloat", SIDE_LOGLEVEL_DEBUG
,
977 void test_variadic_float(void)
1013 float16
.u
= side_bswap_16(float16
.u
);
1016 float32
.u
= side_bswap_32(float32
.u
);
1019 float64
.u
= side_bswap_64(float64
.u
);
1022 side_bswap_128p(float128
.arr
);
1025 side_event_variadic(my_provider_event_variadic_float
,
1029 side_arg_dynamic_field("binary16", side_arg_dynamic_float_binary16(1.1, side_attr_list())),
1030 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
1031 side_arg_dynamic_field("binary16_le", side_arg_dynamic_float_binary16_le(1.1, side_attr_list())),
1032 side_arg_dynamic_field("binary16_be", side_arg_dynamic_float_binary16_be(float16
.f
, side_attr_list())),
1034 side_arg_dynamic_field("binary16_le", side_arg_dynamic_float_binary16_le(float16
.f
, side_attr_list())),
1035 side_arg_dynamic_field("binary16_be", side_arg_dynamic_float_binary16_be(1.1, side_attr_list())),
1039 side_arg_dynamic_field("binary32", side_arg_dynamic_float_binary32(2.2, side_attr_list())),
1040 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
1041 side_arg_dynamic_field("binary32_le", side_arg_dynamic_float_binary32_le(2.2, side_attr_list())),
1042 side_arg_dynamic_field("binary32_be", side_arg_dynamic_float_binary32_be(float32
.f
, side_attr_list())),
1044 side_arg_dynamic_field("binary32_le", side_arg_dynamic_float_binary32_le(float32
.f
, side_attr_list())),
1045 side_arg_dynamic_field("binary32_be", side_arg_dynamic_float_binary32_be(2.2, side_attr_list())),
1049 side_arg_dynamic_field("binary64", side_arg_dynamic_float_binary64(3.3, side_attr_list())),
1050 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
1051 side_arg_dynamic_field("binary64_le", side_arg_dynamic_float_binary64_le(3.3, side_attr_list())),
1052 side_arg_dynamic_field("binary64_be", side_arg_dynamic_float_binary64_be(float64
.f
, side_attr_list())),
1054 side_arg_dynamic_field("binary64_le", side_arg_dynamic_float_binary64_le(float64
.f
, side_attr_list())),
1055 side_arg_dynamic_field("binary64_be", side_arg_dynamic_float_binary64_be(3.3, side_attr_list())),
1059 side_arg_dynamic_field("binary128", side_arg_dynamic_float_binary128(4.4, side_attr_list())),
1060 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
1061 side_arg_dynamic_field("binary128_le", side_arg_dynamic_float_binary128_le(4.4, side_attr_list())),
1062 side_arg_dynamic_field("binary128_be", side_arg_dynamic_float_binary128_be(float128
.f
, side_attr_list())),
1064 side_arg_dynamic_field("binary128_le", side_arg_dynamic_float_binary128_le(float128
.f
, side_attr_list())),
1065 side_arg_dynamic_field("binary128_be", side_arg_dynamic_float_binary128_be(4.4, side_attr_list())),
1073 static side_define_enum(myenum
,
1074 side_enum_mapping_list(
1075 side_enum_mapping_range("one-ten", 1, 10),
1076 side_enum_mapping_range("100-200", 100, 200),
1077 side_enum_mapping_value("200", 200),
1078 side_enum_mapping_value("300", 300),
1083 side_static_event(my_provider_event_enum
, "myprovider", "myeventenum", SIDE_LOGLEVEL_DEBUG
,
1085 side_field_enum("5", &myenum
, side_elem(side_type_u32(side_attr_list()))),
1086 side_field_enum("400", &myenum
, side_elem(side_type_u64(side_attr_list()))),
1087 side_field_enum("200", &myenum
, side_elem(side_type_u8(side_attr_list()))),
1088 side_field_enum("-100", &myenum
, side_elem(side_type_s8(side_attr_list()))),
1089 side_field_enum("6_be", &myenum
, side_elem(side_type_u32_be(side_attr_list()))),
1090 side_field_enum("6_le", &myenum
, side_elem(side_type_u32_le(side_attr_list()))),
1096 void test_enum(void)
1098 side_event(my_provider_event_enum
,
1104 #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN
1105 side_arg_u32(side_bswap_32(6)),
1109 side_arg_u32(side_bswap_32(6)),
1115 /* A bitmap enum maps bits to labels. */
1116 static side_define_enum_bitmap(myenum_bitmap
,
1117 side_enum_bitmap_mapping_list(
1118 side_enum_bitmap_mapping_value("0", 0),
1119 side_enum_bitmap_mapping_range("1-2", 1, 2),
1120 side_enum_bitmap_mapping_range("2-4", 2, 4),
1121 side_enum_bitmap_mapping_value("3", 3),
1122 side_enum_bitmap_mapping_value("30", 30),
1123 side_enum_bitmap_mapping_value("63", 63),
1124 side_enum_bitmap_mapping_range("158-160", 158, 160),
1125 side_enum_bitmap_mapping_value("159", 159),
1126 side_enum_bitmap_mapping_range("500-700", 500, 700),
1131 side_static_event(my_provider_event_enum_bitmap
, "myprovider", "myeventenumbitmap", SIDE_LOGLEVEL_DEBUG
,
1133 side_field_enum_bitmap("bit_0", &myenum_bitmap
, side_elem(side_type_u32(side_attr_list()))),
1134 side_field_enum_bitmap("bit_1", &myenum_bitmap
, side_elem(side_type_u32(side_attr_list()))),
1135 side_field_enum_bitmap("bit_2", &myenum_bitmap
, side_elem(side_type_u8(side_attr_list()))),
1136 side_field_enum_bitmap("bit_3", &myenum_bitmap
, side_elem(side_type_u8(side_attr_list()))),
1137 side_field_enum_bitmap("bit_30", &myenum_bitmap
, side_elem(side_type_u32(side_attr_list()))),
1138 side_field_enum_bitmap("bit_31", &myenum_bitmap
, side_elem(side_type_u32(side_attr_list()))),
1139 side_field_enum_bitmap("bit_63", &myenum_bitmap
, side_elem(side_type_u64(side_attr_list()))),
1140 side_field_enum_bitmap("bits_1+63", &myenum_bitmap
, side_elem(side_type_u64(side_attr_list()))),
1141 side_field_enum_bitmap("byte_bit_2", &myenum_bitmap
, side_elem(side_type_byte(side_attr_list()))),
1142 side_field_enum_bitmap("bit_159", &myenum_bitmap
,
1143 side_elem(side_type_array(side_elem(side_type_u32(side_attr_list())), 5, side_attr_list()))),
1144 side_field_enum_bitmap("bit_159", &myenum_bitmap
,
1145 side_elem(side_type_vla(side_elem(side_type_u32(side_attr_list())), side_attr_list()))),
1146 side_field_enum_bitmap("bit_2_be", &myenum_bitmap
, side_elem(side_type_u32_be(side_attr_list()))),
1147 side_field_enum_bitmap("bit_2_le", &myenum_bitmap
, side_elem(side_type_u32_le(side_attr_list()))),
1153 void test_enum_bitmap(void)
1155 side_event_cond(my_provider_event_enum_bitmap
) {
1156 side_arg_define_vec(myarray
,
1162 side_arg_u32(0x80000000), /* bit 159 */
1165 side_event_call(my_provider_event_enum_bitmap
,
1167 side_arg_u32(1U << 0),
1168 side_arg_u32(1U << 1),
1169 side_arg_u8(1U << 2),
1170 side_arg_u8(1U << 3),
1171 side_arg_u32(1U << 30),
1172 side_arg_u32(1U << 31),
1173 side_arg_u64(1ULL << 63),
1174 side_arg_u64((1ULL << 1) | (1ULL << 63)),
1175 side_arg_byte(1U << 2),
1176 side_arg_array(&myarray
),
1177 side_arg_vla(&myarray
),
1178 #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN
1179 side_arg_u32(side_bswap_32(1U << 2)),
1180 side_arg_u32(1U << 2),
1182 side_arg_u32(1U << 2),
1183 side_arg_u32(side_bswap_32(1U << 2)),
1190 side_static_event_variadic(my_provider_event_blob
, "myprovider", "myeventblob", SIDE_LOGLEVEL_DEBUG
,
1192 side_field_byte("blobfield", side_attr_list()),
1193 side_field_array("arrayblob", side_elem(side_type_byte(side_attr_list())), 3, side_attr_list()),
1199 void test_blob(void)
1201 side_event_cond(my_provider_event_blob
) {
1202 side_arg_define_vec(myarray
, side_arg_list(side_arg_byte(1), side_arg_byte(2), side_arg_byte(3)));
1203 side_arg_dynamic_define_vec(myvla
,
1205 side_arg_dynamic_byte(0x22, side_attr_list()),
1206 side_arg_dynamic_byte(0x33, side_attr_list()),
1210 side_event_call_variadic(my_provider_event_blob
,
1212 side_arg_byte(0x55),
1213 side_arg_array(&myarray
),
1216 side_arg_dynamic_field("varblobfield",
1217 side_arg_dynamic_byte(0x55, side_attr_list())
1219 side_arg_dynamic_field("varblobvla", side_arg_dynamic_vla(&myvla
)),
1226 side_static_event_variadic(my_provider_event_format_string
,
1227 "myprovider", "myeventformatstring", SIDE_LOGLEVEL_DEBUG
,
1229 side_field_string("fmt", side_attr_list()),
1232 side_attr("lang.c.format_string", side_attr_bool(true)),
1237 void test_fmt_string(void)
1239 side_event_cond(my_provider_event_format_string
) {
1240 side_arg_dynamic_define_vec(args
,
1242 side_arg_dynamic_string("blah", side_attr_list()),
1243 side_arg_dynamic_s32(123, side_attr_list()),
1247 side_event_call_variadic(my_provider_event_format_string
,
1249 side_arg_string("This is a formatted string with str: %s int: %d"),
1252 side_arg_dynamic_field("arguments", side_arg_dynamic_vla(&args
)),
1259 side_static_event_variadic(my_provider_event_endian
, "myprovider", "myevent_endian", SIDE_LOGLEVEL_DEBUG
,
1261 side_field_u16_le("u16_le", side_attr_list()),
1262 side_field_u32_le("u32_le", side_attr_list()),
1263 side_field_u64_le("u64_le", side_attr_list()),
1264 side_field_s16_le("s16_le", side_attr_list()),
1265 side_field_s32_le("s32_le", side_attr_list()),
1266 side_field_s64_le("s64_le", side_attr_list()),
1267 side_field_u16_be("u16_be", side_attr_list()),
1268 side_field_u32_be("u32_be", side_attr_list()),
1269 side_field_u64_be("u64_be", side_attr_list()),
1270 side_field_s16_be("s16_be", side_attr_list()),
1271 side_field_s32_be("s32_be", side_attr_list()),
1272 side_field_s64_be("s64_be", side_attr_list()),
1278 void test_endian(void)
1280 side_event_variadic(my_provider_event_endian
,
1282 #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN
1289 side_arg_u16(side_bswap_16(1)),
1290 side_arg_u32(side_bswap_32(1)),
1291 side_arg_u64(side_bswap_64(1)),
1292 side_arg_s16(side_bswap_16(1)),
1293 side_arg_s32(side_bswap_32(1)),
1294 side_arg_s64(side_bswap_64(1)),
1296 side_arg_u16(side_bswap_16(1)),
1297 side_arg_u32(side_bswap_32(1)),
1298 side_arg_u64(side_bswap_64(1)),
1299 side_arg_s16(side_bswap_16(1)),
1300 side_arg_s32(side_bswap_32(1)),
1301 side_arg_s64(side_bswap_64(1)),
1311 #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN
1312 side_arg_dynamic_field("u16_le", side_arg_dynamic_u16_le(1, side_attr_list())),
1313 side_arg_dynamic_field("u32_le", side_arg_dynamic_u32_le(1, side_attr_list())),
1314 side_arg_dynamic_field("u64_le", side_arg_dynamic_u64_le(1, side_attr_list())),
1315 side_arg_dynamic_field("s16_le", side_arg_dynamic_s16_le(1, side_attr_list())),
1316 side_arg_dynamic_field("s32_le", side_arg_dynamic_s32_le(1, side_attr_list())),
1317 side_arg_dynamic_field("s64_le", side_arg_dynamic_s64_le(1, side_attr_list())),
1318 side_arg_dynamic_field("u16_be", side_arg_dynamic_u16_be(side_bswap_16(1), side_attr_list())),
1319 side_arg_dynamic_field("u32_be", side_arg_dynamic_u32_be(side_bswap_32(1), side_attr_list())),
1320 side_arg_dynamic_field("u64_be", side_arg_dynamic_u64_be(side_bswap_64(1), side_attr_list())),
1321 side_arg_dynamic_field("s16_be", side_arg_dynamic_s16_be(side_bswap_16(1), side_attr_list())),
1322 side_arg_dynamic_field("s32_be", side_arg_dynamic_s32_be(side_bswap_32(1), side_attr_list())),
1323 side_arg_dynamic_field("s64_be", side_arg_dynamic_s64_be(side_bswap_64(1), side_attr_list())),
1325 side_arg_dynamic_field("u16_le", side_arg_dynamic_u16_le(side_bswap_16(1), side_attr_list())),
1326 side_arg_dynamic_field("u32_le", side_arg_dynamic_u32_le(side_bswap_32(1), side_attr_list())),
1327 side_arg_dynamic_field("u64_le", side_arg_dynamic_u64_le(side_bswap_64(1), side_attr_list())),
1328 side_arg_dynamic_field("s16_le", side_arg_dynamic_s16_le(side_bswap_16(1), side_attr_list())),
1329 side_arg_dynamic_field("s32_le", side_arg_dynamic_s32_le(side_bswap_32(1), side_attr_list())),
1330 side_arg_dynamic_field("s64_le", side_arg_dynamic_s64_le(side_bswap_64(1), side_attr_list())),
1331 side_arg_dynamic_field("u16_be", side_arg_dynamic_u16_be(1, side_attr_list())),
1332 side_arg_dynamic_field("u32_be", side_arg_dynamic_u32_be(1, side_attr_list())),
1333 side_arg_dynamic_field("u64_be", side_arg_dynamic_u64_be(1, side_attr_list())),
1334 side_arg_dynamic_field("s16_be", side_arg_dynamic_s16_be(1, side_attr_list())),
1335 side_arg_dynamic_field("s32_be", side_arg_dynamic_s32_be(1, side_attr_list())),
1336 side_arg_dynamic_field("s64_be", side_arg_dynamic_s64_be(1, side_attr_list())),
1343 side_static_event(my_provider_event_base
, "myprovider", "myevent_base", SIDE_LOGLEVEL_DEBUG
,
1345 side_field_u8("u8base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))),
1346 side_field_u8("u8base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))),
1347 side_field_u8("u8base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1348 side_field_u8("u8base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1349 side_field_u16("u16base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))),
1350 side_field_u16("u16base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))),
1351 side_field_u16("u16base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1352 side_field_u16("u16base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1353 side_field_u32("u32base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))),
1354 side_field_u32("u32base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))),
1355 side_field_u32("u32base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1356 side_field_u32("u32base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1357 side_field_u64("u64base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))),
1358 side_field_u64("u64base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))),
1359 side_field_u64("u64base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1360 side_field_u64("u64base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1361 side_field_s8("s8base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))),
1362 side_field_s8("s8base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))),
1363 side_field_s8("s8base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1364 side_field_s8("s8base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1365 side_field_s16("s16base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))),
1366 side_field_s16("s16base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))),
1367 side_field_s16("s16base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1368 side_field_s16("s16base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1369 side_field_s32("s32base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))),
1370 side_field_s32("s32base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))),
1371 side_field_s32("s32base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1372 side_field_s32("s32base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1373 side_field_s64("s64base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))),
1374 side_field_s64("s64base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))),
1375 side_field_s64("s64base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1376 side_field_s64("s64base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1382 void test_base(void)
1384 side_event(my_provider_event_base
,
1437 static side_define_struct(mystructgatherdef
,
1439 side_field_gather_unsigned_integer("a", offsetof(struct test
, a
),
1440 side_struct_field_sizeof(struct test
, a
), 0, 0,
1441 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1442 side_field_gather_signed_integer("d", offsetof(struct test
, d
),
1443 side_struct_field_sizeof(struct test
, d
), 0, 0,
1444 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1445 side_field_gather_unsigned_integer("e", offsetof(struct test
, e
),
1446 side_struct_field_sizeof(struct test
, e
), 8, 4,
1447 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1448 side_field_gather_signed_integer("f", offsetof(struct test
, f
),
1449 side_struct_field_sizeof(struct test
, f
), 1, 4,
1450 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1451 side_field_gather_signed_integer("g", offsetof(struct test
, g
),
1452 side_struct_field_sizeof(struct test
, g
), 11, 4,
1453 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1454 side_field_gather_signed_integer("h", offsetof(struct test
, h
),
1455 side_struct_field_sizeof(struct test
, h
), 1, 31,
1456 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1457 side_field_gather_signed_integer("i", offsetof(struct test
, i
),
1458 side_struct_field_sizeof(struct test
, i
), 33, 20,
1459 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1460 side_field_gather_signed_integer("j", offsetof(struct test
, j
),
1461 side_struct_field_sizeof(struct test
, j
), 63, 1,
1462 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1463 side_field_gather_signed_integer("k", offsetof(struct test
, k
),
1464 side_struct_field_sizeof(struct test
, k
), 1, 63,
1465 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1466 side_field_gather_unsigned_integer_le("test", offsetof(struct test
, test
),
1467 side_struct_field_sizeof(struct test
, test
), 0, 64,
1468 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1469 side_field_gather_unsigned_integer_le("test_le", offsetof(struct test
, test
),
1470 side_struct_field_sizeof(struct test
, test
), 0, 64,
1471 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1472 side_field_gather_unsigned_integer_be("test_be", offsetof(struct test
, test
),
1473 side_struct_field_sizeof(struct test
, test
), 0, 64,
1474 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1479 side_static_event(my_provider_event_structgather
, "myprovider", "myeventstructgather", SIDE_LOGLEVEL_DEBUG
,
1481 side_field_gather_struct("structgather", &mystructgatherdef
, 0, sizeof(struct test
),
1482 SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1483 side_field_gather_signed_integer("intgather", 0, sizeof(int32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1484 side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1486 side_field_gather_float("f32", 0, sizeof(_Float32
), SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1493 void test_struct_gather(void)
1495 side_event_cond(my_provider_event_structgather
) {
1496 struct test mystruct
= {
1514 side_event_call(my_provider_event_structgather
,
1516 side_arg_gather_struct(&mystruct
),
1517 side_arg_gather_integer(&val
),
1519 side_arg_gather_float(&f32
),
1532 struct testnest2
*nest
;
1537 struct testnest1
*nest
;
1540 static side_define_struct(mystructgathernest2
,
1542 side_field_gather_unsigned_integer("c", offsetof(struct testnest2
, c
),
1543 side_struct_field_sizeof(struct testnest2
, c
), 0, 0,
1544 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1549 static side_define_struct(mystructgathernest1
,
1551 side_field_gather_unsigned_integer("b", offsetof(struct testnest1
, b
),
1552 side_struct_field_sizeof(struct testnest1
, b
), 0, 0,
1553 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1554 side_field_gather_struct("nest2", &mystructgathernest2
,
1555 offsetof(struct testnest1
, nest
), sizeof(struct testnest2
),
1556 SIDE_TYPE_GATHER_ACCESS_POINTER
),
1561 static side_define_struct(mystructgathernest0
,
1563 side_field_gather_unsigned_integer("a", offsetof(struct testnest0
, a
),
1564 side_struct_field_sizeof(struct testnest0
, a
), 0, 0,
1565 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1566 side_field_gather_struct("nest1", &mystructgathernest1
,
1567 offsetof(struct testnest0
, nest
), sizeof(struct testnest1
),
1568 SIDE_TYPE_GATHER_ACCESS_POINTER
),
1573 side_static_event(my_provider_event_structgather_nest
,
1574 "myprovider", "myeventstructgathernest", SIDE_LOGLEVEL_DEBUG
,
1576 side_field_gather_struct("nest0", &mystructgathernest0
, 0,
1577 sizeof(struct testnest0
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1583 void test_struct_gather_nest_ptr(void)
1585 side_event_cond(my_provider_event_structgather_nest
) {
1586 struct testnest2 mystruct2
= {
1589 struct testnest1 mystruct1
= {
1593 struct testnest0 mystruct
= {
1597 side_event_call(my_provider_event_structgather_nest
,
1599 side_arg_gather_struct(&mystruct
),
1620 static side_define_struct(mystructgatherfloat
,
1623 side_field_gather_float("f16", offsetof(struct testfloat
, f16
), side_struct_field_sizeof(struct testfloat
, f16
),
1624 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1628 side_field_gather_float("f32", offsetof(struct testfloat
, f32
), side_struct_field_sizeof(struct testfloat
, f32
),
1629 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1633 side_field_gather_float("f64", offsetof(struct testfloat
, f64
), side_struct_field_sizeof(struct testfloat
, f64
),
1634 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1638 side_field_gather_float("f128", offsetof(struct testfloat
, f128
), side_struct_field_sizeof(struct testfloat
, f128
),
1639 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1646 side_static_event(my_provider_event_structgatherfloat
,
1647 "myprovider", "myeventstructgatherfloat", SIDE_LOGLEVEL_DEBUG
,
1649 side_field_gather_struct("structgatherfloat", &mystructgatherfloat
, 0,
1650 sizeof(struct testfloat
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1656 void test_struct_gather_float(void)
1658 side_event_cond(my_provider_event_structgatherfloat
) {
1659 struct testfloat mystruct
= {
1673 side_event_call(my_provider_event_structgatherfloat
,
1675 side_arg_gather_struct(&mystruct
),
1681 uint32_t mygatherarray
[] = { 1, 2, 3, 4, 5 };
1683 uint16_t mygatherarray2
[] = { 6, 7, 8, 9 };
1690 static side_define_struct(mystructgatherarray
,
1692 side_field_gather_array("array",
1693 side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1694 SIDE_ARRAY_SIZE(mygatherarray
),
1695 offsetof(struct testarray
, ptr
),
1696 SIDE_TYPE_GATHER_ACCESS_POINTER
,
1702 side_static_event(my_provider_event_structgatherarray
,
1703 "myprovider", "myeventstructgatherarray", SIDE_LOGLEVEL_DEBUG
,
1705 side_field_gather_struct("structgatherarray", &mystructgatherarray
, 0,
1706 sizeof(struct testarray
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1707 side_field_gather_array("array2",
1708 side_elem(side_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1709 SIDE_ARRAY_SIZE(mygatherarray2
), 0,
1710 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1718 void test_array_gather(void)
1720 side_event_cond(my_provider_event_structgatherarray
) {
1721 struct testarray mystruct
= {
1723 .ptr
= mygatherarray
,
1725 side_event_call(my_provider_event_structgatherarray
,
1727 side_arg_gather_struct(&mystruct
),
1728 side_arg_gather_array(&mygatherarray2
),
1734 #define TESTSGNESTARRAY_LEN 4
1735 struct testgatherstructnest1
{
1737 int c
[TESTSGNESTARRAY_LEN
];
1740 struct testgatherstructnest0
{
1741 struct testgatherstructnest1 nest
;
1742 struct testgatherstructnest1 nestarray
[2];
1746 static side_define_struct(mystructgatherstructnest1
,
1748 side_field_gather_signed_integer("b", offsetof(struct testgatherstructnest1
, b
),
1749 side_struct_field_sizeof(struct testgatherstructnest1
, b
), 0, 0,
1750 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1751 side_field_gather_array("c",
1753 side_type_gather_signed_integer(0, sizeof(uint32_t), 0, 0,
1754 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1756 TESTSGNESTARRAY_LEN
,
1757 offsetof(struct testgatherstructnest1
, c
),
1758 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1764 static side_define_struct(mystructgatherstructnest0
,
1766 side_field_gather_signed_integer("a", offsetof(struct testgatherstructnest0
, a
),
1767 side_struct_field_sizeof(struct testgatherstructnest0
, a
), 0, 0,
1768 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1769 side_field_gather_struct("structnest0", &mystructgatherstructnest1
,
1770 offsetof(struct testgatherstructnest0
, nest
),
1771 sizeof(struct testgatherstructnest1
),
1772 SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1773 side_field_gather_array("nestarray",
1775 side_type_gather_struct(&mystructgatherstructnest1
,
1777 sizeof(struct testgatherstructnest1
),
1778 SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1781 offsetof(struct testgatherstructnest0
, nestarray
),
1782 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1788 side_static_event(my_provider_event_gatherstructnest
,
1789 "myprovider", "myeventgatherstructnest", SIDE_LOGLEVEL_DEBUG
,
1791 side_field_gather_struct("structgather", &mystructgatherstructnest0
, 0,
1792 sizeof(struct testgatherstructnest0
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1798 void test_gather_structnest(void)
1800 side_event_cond(my_provider_event_gatherstructnest
) {
1801 struct testgatherstructnest0 mystruct
= {
1804 .c
= { 0, 1, 2, 3 },
1809 .c
= { 11, 12, 13, 14 },
1813 .c
= { 15, 16, 17, 18 },
1818 side_event_call(my_provider_event_gatherstructnest
,
1820 side_arg_gather_struct(&mystruct
),
1826 uint32_t gathervla
[] = { 1, 2, 3, 4 };
1827 uint32_t gathervla2
[] = { 5, 6, 7, 8, 9 };
1829 struct testgathervla
{
1835 static side_define_struct(mystructgathervla
,
1837 side_field_gather_signed_integer("a", offsetof(struct testgathervla
, a
),
1838 side_struct_field_sizeof(struct testgathervla
, a
), 0, 0,
1839 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()
1841 side_field_gather_vla("nestvla",
1842 side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1843 offsetof(struct testgathervla
, p
),
1844 SIDE_TYPE_GATHER_ACCESS_POINTER
,
1845 side_length(side_type_gather_unsigned_integer(offsetof(struct testgathervla
, len
),
1846 sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1853 side_static_event(my_provider_event_gathervla
,
1854 "myprovider", "myeventgathervla", SIDE_LOGLEVEL_DEBUG
,
1856 side_field_gather_struct("structgathervla", &mystructgathervla
, 0,
1857 sizeof(struct testgathervla
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1858 side_field_gather_vla("vla",
1859 side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1860 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1861 side_length(side_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1869 void test_gather_vla(void)
1871 side_event_cond(my_provider_event_gathervla
) {
1872 struct testgathervla mystruct
= {
1874 .len
= SIDE_ARRAY_SIZE(gathervla
),
1877 uint16_t vla2_len
= 5;
1878 side_event_call(my_provider_event_gathervla
,
1880 side_arg_gather_struct(&mystruct
),
1881 side_arg_gather_vla(gathervla2
, &vla2_len
),
1887 struct testgathervlaflex
{
1889 uint32_t otherfield
;
1893 static side_define_struct(mystructgathervlaflex
,
1895 side_field_gather_vla("vlaflex",
1896 side_elem(side_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1897 offsetof(struct testgathervlaflex
, array
),
1898 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1899 side_length(side_type_gather_unsigned_integer(offsetof(struct testgathervlaflex
, len
),
1900 side_struct_field_sizeof(struct testgathervlaflex
, len
), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1907 side_static_event(my_provider_event_gathervlaflex
,
1908 "myprovider", "myeventgathervlaflex", SIDE_LOGLEVEL_DEBUG
,
1910 side_field_gather_struct("structgathervlaflex", &mystructgathervlaflex
, 0,
1911 sizeof(struct testgathervlaflex
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1916 #define VLAFLEXLEN 6
1918 void test_gather_vla_flex(void)
1920 side_event_cond(my_provider_event_gathervlaflex
) {
1921 struct testgathervlaflex
*mystruct
=
1922 (struct testgathervlaflex
*) malloc(sizeof(*mystruct
) + VLAFLEXLEN
* sizeof(uint64_t));
1924 mystruct
->len
= VLAFLEXLEN
;
1925 mystruct
->otherfield
= 0;
1926 mystruct
->array
[0] = 1;
1927 mystruct
->array
[1] = 2;
1928 mystruct
->array
[2] = 3;
1929 mystruct
->array
[3] = 4;
1930 mystruct
->array
[4] = 5;
1931 mystruct
->array
[5] = 6;
1932 side_event_call(my_provider_event_gathervlaflex
,
1934 side_arg_gather_struct(mystruct
),
1941 side_static_event(my_provider_event_gatherbyte
,
1942 "myprovider", "myeventgatherbyte", SIDE_LOGLEVEL_DEBUG
,
1944 side_field_gather_byte("byte", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1945 side_field_gather_array("array",
1946 side_elem(side_type_gather_byte(0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1947 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()
1954 void test_gather_byte(void)
1956 side_event_cond(my_provider_event_gatherbyte
) {
1958 uint8_t array
[3] = { 0x1, 0x2, 0x3 };
1960 side_event_call(my_provider_event_gatherbyte
,
1962 side_arg_gather_byte(&v
),
1963 side_arg_gather_array(array
),
1969 #define ARRAYBOOLLEN 4
1970 static bool arraybool
[ARRAYBOOLLEN
] = { false, true, false, true };
1972 side_static_event(my_provider_event_gatherbool
,
1973 "myprovider", "myeventgatherbool", SIDE_LOGLEVEL_DEBUG
,
1975 side_field_gather_bool("v1_true", 0, sizeof(bool), 0, 0,
1976 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1977 side_field_gather_bool("v2_false", 0, sizeof(bool), 0, 0,
1978 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1979 side_field_gather_bool("v3_true", 0, sizeof(uint16_t), 1, 1,
1980 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1981 side_field_gather_bool("v4_false", 0, sizeof(uint16_t), 1, 1,
1982 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1983 side_field_gather_array("arraybool",
1984 side_elem(side_type_gather_bool(0, sizeof(bool), 0, 0,
1985 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1986 ARRAYBOOLLEN
, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()
1993 void test_gather_bool(void)
1995 side_event_cond(my_provider_event_structgatherarray
) {
1998 uint16_t v3
= 1U << 1;
1999 uint16_t v4
= 1U << 2;
2001 side_event_call(my_provider_event_gatherbool
,
2003 side_arg_gather_bool(&v1
),
2004 side_arg_gather_bool(&v2
),
2005 side_arg_gather_bool(&v3
),
2006 side_arg_gather_bool(&v4
),
2007 side_arg_gather_array(arraybool
),
2013 side_static_event(my_provider_event_gatherpointer
,
2014 "myprovider", "myeventgatherpointer", SIDE_LOGLEVEL_DEBUG
,
2016 side_field_gather_pointer("ptr", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
2017 side_field_gather_array("array",
2018 side_elem(side_type_gather_pointer(0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
2019 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()
2026 void test_gather_pointer(void)
2028 side_event_cond(my_provider_event_structgatherarray
) {
2029 void *v
= (void *)0x44;
2030 void *array
[3] = { (void *)0x1, (void *)0x2, (void *)0x3 };
2032 side_event_call(my_provider_event_gatherpointer
,
2034 side_arg_gather_pointer(&v
),
2035 side_arg_gather_array(array
),
2041 static side_define_enum(myenumgather
,
2042 side_enum_mapping_list(
2043 side_enum_mapping_range("one-ten", 1, 10),
2044 side_enum_mapping_range("100-200", 100, 200),
2045 side_enum_mapping_value("200", 200),
2046 side_enum_mapping_value("300", 300),
2051 side_static_event(my_provider_event_enum_gather
, "myprovider", "myeventenumgather", SIDE_LOGLEVEL_DEBUG
,
2053 side_field_gather_enum("5", &myenumgather
,
2055 side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0,
2056 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2059 side_field_gather_enum("400", &myenumgather
,
2061 side_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0,
2062 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2065 side_field_gather_enum("200", &myenumgather
,
2067 side_type_gather_unsigned_integer(0, sizeof(uint8_t), 0, 0,
2068 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2071 side_field_gather_enum("-100", &myenumgather
,
2073 side_type_gather_signed_integer(0, sizeof(int8_t), 0, 0,
2074 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2077 side_field_gather_enum("6_be", &myenumgather
,
2079 side_type_gather_unsigned_integer_be(0, sizeof(uint32_t), 0, 0,
2080 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2083 side_field_gather_enum("6_le", &myenumgather
,
2085 side_type_gather_unsigned_integer_le(0, sizeof(uint32_t), 0, 0,
2086 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2094 void test_gather_enum(void)
2100 #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN
2101 uint32_t v5
= side_bswap_32(6);
2105 uint32_t v6
= side_bswap_32(6);
2108 side_event(my_provider_event_enum_gather
,
2110 side_arg_gather_integer(&v1
),
2111 side_arg_gather_integer(&v2
),
2112 side_arg_gather_integer(&v3
),
2113 side_arg_gather_integer(&v4
),
2114 side_arg_gather_integer(&v5
),
2115 side_arg_gather_integer(&v6
),
2120 side_static_event(my_provider_event_gatherstring
,
2121 "myprovider", "myeventgatherstring", SIDE_LOGLEVEL_DEBUG
,
2123 side_field_gather_string("string", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
2124 side_field_gather_array("arrayptr",
2125 side_elem(side_type_gather_string(0, SIDE_TYPE_GATHER_ACCESS_POINTER
, side_attr_list())),
2126 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()
2128 side_field_gather_array("array",
2129 side_elem(side_type_gather_string(0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
2130 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()
2137 void test_gather_string(void)
2139 side_event_cond(my_provider_event_gatherstring
) {
2140 const char *str1
= "abcdef";
2141 const char *ptrarray
[3] = {
2146 char flatarray
[] = { 'a', 'b', '\0', 'c', 'd', '\0', 'e', 'f', '\0' };
2148 side_event_call(my_provider_event_gatherstring
,
2150 side_arg_gather_string(str1
),
2151 side_arg_gather_array(ptrarray
),
2152 side_arg_gather_array(flatarray
),
2158 side_static_event(my_provider_event_str_utf
, "myprovider", "myevent_str_utf", SIDE_LOGLEVEL_DEBUG
,
2160 side_field_string("utf8", side_attr_list()),
2161 side_field_string32("utf32", side_attr_list()),
2162 side_field_string16("utf16", side_attr_list()),
2163 side_field_string32_le("utf32_le", side_attr_list()),
2164 side_field_string16_le("utf16_le", side_attr_list()),
2165 side_field_string32_be("utf32_be", side_attr_list()),
2166 side_field_string16_be("utf16_be", side_attr_list()),
2167 side_field_dynamic("dynamic_utf32"),
2168 side_field_gather_string32("gather_utf32", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
2174 void test_string_utf(void)
2180 * UTF-32: U+000000ae
2182 uint8_t str8
[] = { 0xc2, 0xae, 'a', 'b', 'c', 0 };
2183 uint32_t str32
[] = { 0x000000ae, 'a', 'b', 'c', 0 };
2184 uint16_t str16
[] = { 0x00ae, 'a', 'b', 'c', 0 };
2185 #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN
2186 uint32_t str32_le
[] = { 0x000000ae, 'a', 'b', 'c', 0 };
2187 uint16_t str16_le
[] = { 0x00ae, 'a', 'b', 'c', 0 };
2188 uint32_t str32_be
[] = { side_bswap_32(0x000000ae), side_bswap_32('a'), side_bswap_32('b'), side_bswap_32('c'), 0 };
2189 uint16_t str16_be
[] = { side_bswap_16(0x00ae), side_bswap_16('a'), side_bswap_16('b'), side_bswap_16('c'), 0 };
2191 uint32_t str32_le
[] = { side_bswap_32(0x000000ae), side_bswap_32('a'), side_bswap_32('b'), side_bswap_32('c'), 0 };
2192 uint16_t str16_le
[] = { side_bswap_16(0x00ae), side_bswap_16('a'), side_bswap_16('b'), side_bswap_16('c'), 0 };
2193 uint32_t str32_be
[] = { 0x000000ae, 'a', 'b', 'c', 0 };
2194 uint16_t str16_be
[] = { 0x00ae, 'a', 'b', 'c', 0 };
2197 side_event(my_provider_event_str_utf
,
2199 side_arg_string(str8
),
2200 side_arg_string32(str32
),
2201 side_arg_string16(str16
),
2202 side_arg_string32(str32_le
),
2203 side_arg_string16(str16_le
),
2204 side_arg_string32(str32_be
),
2205 side_arg_string16(str16_be
),
2206 side_arg_dynamic_string32(str32
, side_attr_list()),
2207 side_arg_gather_string(str32
),
2215 test_event_hidden();
2216 test_event_export();
2217 test_struct_literal();
2222 test_vla_visitor_2d();
2223 test_dynamic_basic_type();
2225 test_dynamic_null();
2226 test_dynamic_struct();
2227 test_dynamic_nested_struct();
2228 test_dynamic_vla_struct();
2229 test_dynamic_struct_vla();
2230 test_dynamic_nested_vla();
2232 test_static_variadic();
2234 test_dynamic_bool();
2235 test_dynamic_vla_with_visitor();
2236 test_dynamic_struct_with_visitor();
2237 test_event_user_attribute();
2238 test_field_user_attribute();
2239 test_variadic_attr();
2240 test_variadic_vla_attr();
2241 test_variadic_struct_attr();
2243 test_variadic_float();
2250 test_struct_gather();
2251 test_struct_gather_nest_ptr();
2252 test_struct_gather_float();
2253 test_array_gather();
2254 test_gather_structnest();
2256 test_gather_vla_flex();
2259 test_gather_pointer();
2261 test_gather_string();