1 // SPDX-License-Identifier: MIT
3 * Copyright 2022 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 #include <side/trace.h>
16 /* User code example */
18 side_static_event(my_provider_event
, "myprovider", "myevent", SIDE_LOGLEVEL_DEBUG
,
20 side_field_u32("abc", side_attr_list()),
21 side_field_s64("def", side_attr_list()),
22 side_field_pointer("ptr", side_attr_list()),
23 side_field_dynamic("dynamic"),
24 side_field_dynamic("dynamic_pointer"),
25 side_field_null("null", side_attr_list()),
31 void test_fields(void)
36 side_event(my_provider_event
,
40 side_arg_pointer((void *) 0x1),
41 side_arg_dynamic_string("zzz", side_attr_list()),
42 side_arg_dynamic_pointer((void *) 0x1, side_attr_list()),
48 side_hidden_event(my_provider_event_hidden
, "myprovider", "myeventhidden", SIDE_LOGLEVEL_DEBUG
,
50 side_field_u32("abc", side_attr_list()),
56 void test_event_hidden(void)
58 side_event(my_provider_event_hidden
, side_arg_list(side_arg_u32(2)));
61 side_declare_event(my_provider_event_export
);
63 side_export_event(my_provider_event_export
, "myprovider", "myeventexport", SIDE_LOGLEVEL_DEBUG
,
65 side_field_u32("abc", side_attr_list()),
71 void test_event_export(void)
73 side_event(my_provider_event_export
, side_arg_list(side_arg_u32(2)));
76 side_static_event(my_provider_event_struct_literal
, "myprovider", "myeventstructliteral", SIDE_LOGLEVEL_DEBUG
,
78 side_field_struct("structliteral",
81 side_field_u32("x", side_attr_list()),
82 side_field_s64("y", side_attr_list()),
87 side_field_u8("z", side_attr_list()),
93 void test_struct_literal(void)
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)));
101 static side_define_struct(mystructdef
,
103 side_field_u32("x", side_attr_list()),
104 side_field_s64("y", side_attr_list()),
109 side_static_event(my_provider_event_struct
, "myprovider", "myeventstruct", SIDE_LOGLEVEL_DEBUG
,
111 side_field_struct("struct", &mystructdef
),
112 side_field_u8("z", side_attr_list()),
118 void test_struct(void)
120 side_event_cond(my_provider_event_struct
) {
121 side_arg_define_vec(mystruct
, side_arg_list(side_arg_u32(21), side_arg_s64(22)));
122 side_event_call(my_provider_event_struct
, side_arg_list(side_arg_struct(&mystruct
), side_arg_u8(55)));
126 side_static_event(my_provider_event_array
, "myprovider", "myarray", SIDE_LOGLEVEL_DEBUG
,
128 side_field_array("arr", side_elem(side_type_u32(side_attr_list())), 3, side_attr_list()),
129 side_field_s64("v", side_attr_list()),
135 void test_array(void)
137 side_event_cond(my_provider_event_array
) {
138 side_arg_define_vec(myarray
, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3)));
139 side_event_call(my_provider_event_array
, side_arg_list(side_arg_array(&myarray
), side_arg_s64(42)));
143 side_static_event(my_provider_event_vla
, "myprovider", "myvla", SIDE_LOGLEVEL_DEBUG
,
145 side_field_vla("vla", side_elem(side_type_u32(side_attr_list())), side_attr_list()),
146 side_field_s64("v", side_attr_list()),
154 side_event_cond(my_provider_event_vla
) {
155 side_arg_define_vec(myvla
, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3)));
156 side_event_call(my_provider_event_vla
, side_arg_list(side_arg_vla(&myvla
), side_arg_s64(42)));
160 /* 1D array visitor */
162 struct app_visitor_ctx
{
168 enum side_visitor_status
test_visitor(const struct side_tracer_visitor_ctx
*tracer_ctx
, void *_ctx
)
170 struct app_visitor_ctx
*ctx
= (struct app_visitor_ctx
*) _ctx
;
171 uint32_t length
= ctx
->length
, i
;
173 for (i
= 0; i
< length
; i
++) {
174 const struct side_arg elem
= side_arg_u32(ctx
->ptr
[i
]);
176 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != SIDE_VISITOR_STATUS_OK
)
177 return SIDE_VISITOR_STATUS_ERROR
;
179 return SIDE_VISITOR_STATUS_OK
;
182 static uint32_t testarray
[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
184 side_static_event(my_provider_event_vla_visitor
, "myprovider", "myvlavisit", SIDE_LOGLEVEL_DEBUG
,
186 side_field_vla_visitor("vlavisit", side_elem(side_type_u32(side_attr_list())), test_visitor
, side_attr_list()),
187 side_field_s64("v", side_attr_list()),
193 void test_vla_visitor(void)
195 side_event_cond(my_provider_event_vla_visitor
) {
196 struct app_visitor_ctx ctx
= {
198 .length
= SIDE_ARRAY_SIZE(testarray
),
200 side_event_call(my_provider_event_vla_visitor
, side_arg_list(side_arg_vla_visitor(&ctx
), side_arg_s64(42)));
204 /* 2D array visitor */
206 struct app_visitor_2d_inner_ctx
{
212 enum side_visitor_status
test_inner_visitor(const struct side_tracer_visitor_ctx
*tracer_ctx
, void *_ctx
)
214 struct app_visitor_2d_inner_ctx
*ctx
= (struct app_visitor_2d_inner_ctx
*) _ctx
;
215 uint32_t length
= ctx
->length
, i
;
217 for (i
= 0; i
< length
; i
++) {
218 const struct side_arg elem
= side_arg_u32(ctx
->ptr
[i
]);
220 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != SIDE_VISITOR_STATUS_OK
)
221 return SIDE_VISITOR_STATUS_ERROR
;
223 return SIDE_VISITOR_STATUS_OK
;
226 struct app_visitor_2d_outer_ctx
{
227 const uint32_t (*ptr
)[2];
232 enum side_visitor_status
test_outer_visitor(const struct side_tracer_visitor_ctx
*tracer_ctx
, void *_ctx
)
234 struct app_visitor_2d_outer_ctx
*ctx
= (struct app_visitor_2d_outer_ctx
*) _ctx
;
235 uint32_t length
= ctx
->length
, i
;
237 for (i
= 0; i
< length
; i
++) {
238 struct app_visitor_2d_inner_ctx inner_ctx
= {
242 const struct side_arg elem
= side_arg_vla_visitor(&inner_ctx
);
243 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != SIDE_VISITOR_STATUS_OK
)
244 return SIDE_VISITOR_STATUS_ERROR
;
246 return SIDE_VISITOR_STATUS_OK
;
249 static uint32_t testarray2d
[][2] = {
255 side_static_event(my_provider_event_vla_visitor2d
, "myprovider", "myvlavisit2d", SIDE_LOGLEVEL_DEBUG
,
257 side_field_vla_visitor("vlavisit2d",
259 side_type_vla_visitor(
260 side_elem(side_type_u32(side_attr_list())),
263 ), test_outer_visitor
, side_attr_list()),
264 side_field_s64("v", side_attr_list()),
270 void test_vla_visitor_2d(void)
272 side_event_cond(my_provider_event_vla_visitor2d
) {
273 struct app_visitor_2d_outer_ctx ctx
= {
275 .length
= SIDE_ARRAY_SIZE(testarray2d
),
277 side_event_call(my_provider_event_vla_visitor2d
, side_arg_list(side_arg_vla_visitor(&ctx
), side_arg_s64(42)));
281 side_static_event(my_provider_event_dynamic_basic
,
282 "myprovider", "mydynamicbasic", SIDE_LOGLEVEL_DEBUG
,
284 side_field_dynamic("dynamic"),
290 void test_dynamic_basic_type(void)
292 side_event(my_provider_event_dynamic_basic
,
293 side_arg_list(side_arg_dynamic_s16(-33, side_attr_list())));
296 side_static_event(my_provider_event_dynamic_vla
,
297 "myprovider", "mydynamicvla", SIDE_LOGLEVEL_DEBUG
,
299 side_field_dynamic("dynamic"),
305 void test_dynamic_vla(void)
307 side_arg_dynamic_define_vec(myvla
,
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()),
315 side_event(my_provider_event_dynamic_vla
,
316 side_arg_list(side_arg_dynamic_vla(&myvla
)));
319 side_static_event(my_provider_event_dynamic_null
,
320 "myprovider", "mydynamicnull", SIDE_LOGLEVEL_DEBUG
,
322 side_field_dynamic("dynamic"),
328 void test_dynamic_null(void)
330 side_event(my_provider_event_dynamic_null
,
331 side_arg_list(side_arg_dynamic_null(side_attr_list())));
334 side_static_event(my_provider_event_dynamic_struct
,
335 "myprovider", "mydynamicstruct", SIDE_LOGLEVEL_DEBUG
,
337 side_field_dynamic("dynamic"),
343 void test_dynamic_struct(void)
345 side_arg_dynamic_define_struct(mystruct
,
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())),
354 side_event(my_provider_event_dynamic_struct
,
355 side_arg_list(side_arg_dynamic_struct(&mystruct
)));
358 side_static_event(my_provider_event_dynamic_nested_struct
,
359 "myprovider", "mydynamicnestedstruct", SIDE_LOGLEVEL_DEBUG
,
361 side_field_dynamic("dynamic"),
367 void test_dynamic_nested_struct(void)
369 side_arg_dynamic_define_struct(nested
,
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())),
376 side_arg_dynamic_define_struct(nested2
,
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())),
383 side_arg_dynamic_define_struct(mystruct
,
385 side_arg_dynamic_field("nested", side_arg_dynamic_struct(&nested
)),
386 side_arg_dynamic_field("nested2", side_arg_dynamic_struct(&nested2
)),
390 side_event(my_provider_event_dynamic_nested_struct
,
391 side_arg_list(side_arg_dynamic_struct(&mystruct
)));
394 side_static_event(my_provider_event_dynamic_vla_struct
,
395 "myprovider", "mydynamicvlastruct", SIDE_LOGLEVEL_DEBUG
,
397 side_field_dynamic("dynamic"),
403 void test_dynamic_vla_struct(void)
405 side_arg_dynamic_define_struct(nested
,
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())),
412 side_arg_dynamic_define_vec(myvla
,
414 side_arg_dynamic_struct(&nested
),
415 side_arg_dynamic_struct(&nested
),
416 side_arg_dynamic_struct(&nested
),
417 side_arg_dynamic_struct(&nested
),
421 side_event(my_provider_event_dynamic_vla_struct
,
422 side_arg_list(side_arg_dynamic_vla(&myvla
)));
425 side_static_event(my_provider_event_dynamic_struct_vla
,
426 "myprovider", "mydynamicstructvla", SIDE_LOGLEVEL_DEBUG
,
428 side_field_dynamic("dynamic"),
434 void test_dynamic_struct_vla(void)
436 side_arg_dynamic_define_vec(myvla
,
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()),
444 side_arg_dynamic_define_vec(myvla2
,
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()),
452 side_arg_dynamic_define_struct(mystruct
,
454 side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla
)),
455 side_arg_dynamic_field("b", side_arg_dynamic_vla(&myvla2
)),
459 side_event(my_provider_event_dynamic_struct_vla
,
460 side_arg_list(side_arg_dynamic_struct(&mystruct
)));
463 side_static_event(my_provider_event_dynamic_nested_vla
,
464 "myprovider", "mydynamicnestedvla", SIDE_LOGLEVEL_DEBUG
,
466 side_field_dynamic("dynamic"),
472 void test_dynamic_nested_vla(void)
474 side_arg_dynamic_define_vec(nestedvla
,
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()),
482 side_arg_dynamic_define_vec(nestedvla2
,
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()),
490 side_arg_dynamic_define_vec(myvla
,
492 side_arg_dynamic_vla(&nestedvla
),
493 side_arg_dynamic_vla(&nestedvla2
),
497 side_event(my_provider_event_dynamic_nested_vla
,
498 side_arg_list(side_arg_dynamic_vla(&myvla
)));
501 side_static_event_variadic(my_provider_event_variadic
,
502 "myprovider", "myvariadicevent", SIDE_LOGLEVEL_DEBUG
,
508 void test_variadic(void)
510 side_event_variadic(my_provider_event_variadic
,
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())),
520 side_static_event_variadic(my_provider_event_static_variadic
,
521 "myprovider", "mystaticvariadicevent", SIDE_LOGLEVEL_DEBUG
,
523 side_field_u32("abc", side_attr_list()),
524 side_field_u16("def", side_attr_list()),
530 void test_static_variadic(void)
532 side_event_variadic(my_provider_event_static_variadic
,
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())),
545 side_static_event(my_provider_event_bool
, "myprovider", "myeventbool", SIDE_LOGLEVEL_DEBUG
,
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()),
563 uint64_t c
= 0x12345678;
569 side_event(my_provider_event_bool
,
582 side_static_event_variadic(my_provider_event_dynamic_bool
,
583 "myprovider", "mydynamicbool", SIDE_LOGLEVEL_DEBUG
,
589 void test_dynamic_bool(void)
591 side_event_variadic(my_provider_event_dynamic_bool
,
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())),
603 side_static_event(my_provider_event_dynamic_vla_visitor
,
604 "myprovider", "mydynamicvlavisitor", SIDE_LOGLEVEL_DEBUG
,
606 side_field_dynamic("dynamic"),
611 struct app_dynamic_vla_visitor_ctx
{
617 enum side_visitor_status
test_dynamic_vla_visitor(const struct side_tracer_visitor_ctx
*tracer_ctx
, void *_ctx
)
619 struct app_dynamic_vla_visitor_ctx
*ctx
= (struct app_dynamic_vla_visitor_ctx
*) _ctx
;
620 uint32_t length
= ctx
->length
, i
;
622 for (i
= 0; i
< length
; i
++) {
623 const struct side_arg elem
= side_arg_dynamic_u32(ctx
->ptr
[i
], side_attr_list());
624 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != SIDE_VISITOR_STATUS_OK
)
625 return SIDE_VISITOR_STATUS_ERROR
;
627 return SIDE_VISITOR_STATUS_OK
;
630 static uint32_t testarray_dynamic_vla
[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
633 void test_dynamic_vla_with_visitor(void)
635 side_event_cond(my_provider_event_dynamic_vla_visitor
) {
636 struct app_dynamic_vla_visitor_ctx ctx
= {
637 .ptr
= testarray_dynamic_vla
,
638 .length
= SIDE_ARRAY_SIZE(testarray_dynamic_vla
),
640 side_event_call(my_provider_event_dynamic_vla_visitor
,
642 side_arg_dynamic_vla_visitor(test_dynamic_vla_visitor
, &ctx
, side_attr_list())
648 side_static_event(my_provider_event_dynamic_struct_visitor
,
649 "myprovider", "mydynamicstructvisitor", SIDE_LOGLEVEL_DEBUG
,
651 side_field_dynamic("dynamic"),
656 struct struct_visitor_pair
{
661 struct app_dynamic_struct_visitor_ctx
{
662 const struct struct_visitor_pair
*ptr
;
667 enum side_visitor_status
test_dynamic_struct_visitor(const struct side_tracer_dynamic_struct_visitor_ctx
*tracer_ctx
, void *_ctx
)
669 struct app_dynamic_struct_visitor_ctx
*ctx
= (struct app_dynamic_struct_visitor_ctx
*) _ctx
;
670 uint32_t length
= ctx
->length
, i
;
672 for (i
= 0; i
< length
; i
++) {
673 struct side_arg_dynamic_field dynamic_field
= {
674 .field_name
= ctx
->ptr
[i
].name
,
675 .elem
= side_arg_dynamic_u32(ctx
->ptr
[i
].value
, side_attr_list()),
677 if (tracer_ctx
->write_field(tracer_ctx
, &dynamic_field
) != SIDE_VISITOR_STATUS_OK
)
678 return SIDE_VISITOR_STATUS_ERROR
;
680 return SIDE_VISITOR_STATUS_OK
;
683 static struct struct_visitor_pair testarray_dynamic_struct
[] = {
691 void test_dynamic_struct_with_visitor(void)
693 side_event_cond(my_provider_event_dynamic_struct_visitor
) {
694 struct app_dynamic_struct_visitor_ctx ctx
= {
695 .ptr
= testarray_dynamic_struct
,
696 .length
= SIDE_ARRAY_SIZE(testarray_dynamic_struct
),
698 side_event_call(my_provider_event_dynamic_struct_visitor
,
700 side_arg_dynamic_struct_visitor(test_dynamic_struct_visitor
, &ctx
, side_attr_list())
706 side_static_event(my_provider_event_user_attribute
, "myprovider", "myevent_user_attribute", SIDE_LOGLEVEL_DEBUG
,
708 side_field_u32("abc", side_attr_list()),
709 side_field_s64("def", side_attr_list()),
712 side_attr("user_attribute_a", side_attr_string("val1")),
713 side_attr("user_attribute_b", side_attr_string("val2")),
718 void test_event_user_attribute(void)
720 side_event(my_provider_event_user_attribute
, side_arg_list(side_arg_u32(1), side_arg_s64(2)));
723 side_static_event(my_provider_field_user_attribute
, "myprovider", "myevent_field_attribute", SIDE_LOGLEVEL_DEBUG
,
725 side_field_u32("abc",
727 side_attr("user_attribute_a", side_attr_string("val1")),
728 side_attr("user_attribute_b", side_attr_u32(2)),
731 side_field_s64("def",
733 side_attr("user_attribute_c", side_attr_string("val3")),
734 side_attr("user_attribute_d", side_attr_s64(-5)),
742 void test_field_user_attribute(void)
744 side_event(my_provider_field_user_attribute
, side_arg_list(side_arg_u32(1), side_arg_s64(2)));
747 side_static_event_variadic(my_provider_event_variadic_attr
,
748 "myprovider", "myvariadiceventattr", SIDE_LOGLEVEL_DEBUG
,
754 void test_variadic_attr(void)
756 side_event_variadic(my_provider_event_variadic_attr
,
759 side_arg_dynamic_field("a",
760 side_arg_dynamic_u32(55,
762 side_attr("user_attribute_c", side_attr_string("valX")),
763 side_attr("user_attribute_d", side_attr_u8(55)),
767 side_arg_dynamic_field("b",
768 side_arg_dynamic_s8(-4,
770 side_attr("X", side_attr_u8(1)),
771 side_attr("Y", side_attr_s8(2)),
780 side_static_event_variadic(my_provider_event_variadic_vla_attr
,
781 "myprovider", "myvariadiceventvlaattr", SIDE_LOGLEVEL_DEBUG
,
787 void test_variadic_vla_attr(void)
789 side_arg_dynamic_define_vec(myvla
,
791 side_arg_dynamic_u32(1,
793 side_attr("Z", side_attr_u8(0)),
794 side_attr("A", side_attr_u8(123)),
797 side_arg_dynamic_u32(2, side_attr_list()),
798 side_arg_dynamic_u32(3, side_attr_list()),
801 side_attr("X", side_attr_u8(1)),
802 side_attr("Y", side_attr_u8(2)),
805 side_event_variadic(my_provider_event_variadic_vla_attr
,
808 side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla
)),
814 side_static_event_variadic(my_provider_event_variadic_struct_attr
,
815 "myprovider", "myvariadiceventstructattr", SIDE_LOGLEVEL_DEBUG
,
821 void test_variadic_struct_attr(void)
823 side_event_cond(my_provider_event_variadic_struct_attr
) {
824 side_arg_dynamic_define_struct(mystruct
,
826 side_arg_dynamic_field("a",
827 side_arg_dynamic_u32(43,
829 side_attr("A", side_attr_bool(true)),
833 side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())),
836 side_attr("X", side_attr_u8(1)),
837 side_attr("Y", side_attr_u8(2)),
840 side_event_call_variadic(my_provider_event_variadic_struct_attr
,
843 side_arg_dynamic_field("a", side_arg_dynamic_struct(&mystruct
)),
850 side_static_event(my_provider_event_float
, "myprovider", "myeventfloat", SIDE_LOGLEVEL_DEBUG
,
853 side_field_float_binary16("binary16", side_attr_list()),
854 side_field_float_binary16_le("binary16_le", side_attr_list()),
855 side_field_float_binary16_be("binary16_be", side_attr_list()),
858 side_field_float_binary32("binary32", side_attr_list()),
859 side_field_float_binary32_le("binary32_le", side_attr_list()),
860 side_field_float_binary32_be("binary32_be", side_attr_list()),
863 side_field_float_binary64("binary64", side_attr_list()),
864 side_field_float_binary64_le("binary64_le", side_attr_list()),
865 side_field_float_binary64_be("binary64_be", side_attr_list()),
868 side_field_float_binary128("binary128", side_attr_list()),
869 side_field_float_binary128_le("binary128_le", side_attr_list()),
870 side_field_float_binary128_be("binary128_be", side_attr_list()),
877 void test_float(void)
913 float16
.u
= side_bswap_16(float16
.u
);
916 float32
.u
= side_bswap_32(float32
.u
);
919 float64
.u
= side_bswap_64(float64
.u
);
922 side_bswap_128p(float128
.arr
);
925 side_event(my_provider_event_float
,
928 side_arg_float_binary16(1.1),
929 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
930 side_arg_float_binary16(1.1),
931 side_arg_float_binary16(float16
.f
),
933 side_arg_float_binary16(float16
.f
),
934 side_arg_float_binary16(1.1),
938 side_arg_float_binary32(2.2),
939 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
940 side_arg_float_binary32(2.2),
941 side_arg_float_binary32(float32
.f
),
943 side_arg_float_binary32(float32
.f
),
944 side_arg_float_binary32(2.2),
948 side_arg_float_binary64(3.3),
949 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
950 side_arg_float_binary64(3.3),
951 side_arg_float_binary64(float64
.f
),
953 side_arg_float_binary64(float64
.f
),
954 side_arg_float_binary64(3.3),
958 side_arg_float_binary128(4.4),
959 # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN
960 side_arg_float_binary128(4.4),
961 side_arg_float_binary128(float128
.f
),
963 side_arg_float_binary128(float128
.f
),
964 side_arg_float_binary128(4.4),
971 side_static_event_variadic(my_provider_event_variadic_float
,
972 "myprovider", "myvariadicfloat", SIDE_LOGLEVEL_DEBUG
,
978 void test_variadic_float(void)
1014 float16
.u
= side_bswap_16(float16
.u
);
1017 float32
.u
= side_bswap_32(float32
.u
);
1020 float64
.u
= side_bswap_64(float64
.u
);
1023 side_bswap_128p(float128
.arr
);
1026 side_event_variadic(my_provider_event_variadic_float
,
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())),
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())),
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())),
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())),
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())),
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())),
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())),
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())),
1074 static side_define_enum(myenum
,
1075 side_enum_mapping_list(
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),
1084 side_static_event(my_provider_event_enum
, "myprovider", "myeventenum", SIDE_LOGLEVEL_DEBUG
,
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()))),
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()))),
1097 void test_enum(void)
1099 side_event(my_provider_event_enum
,
1105 #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN
1106 side_arg_u32(side_bswap_32(6)),
1110 side_arg_u32(side_bswap_32(6)),
1116 /* A bitmap enum maps bits to labels. */
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),
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),
1132 side_static_event(my_provider_event_enum_bitmap
, "myprovider", "myeventenumbitmap", SIDE_LOGLEVEL_DEBUG
,
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()))),
1142 side_field_enum_bitmap("byte_bit_2", &myenum_bitmap
, side_elem(side_type_byte(side_attr_list()))),
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()))),
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()))),
1154 void test_enum_bitmap(void)
1156 side_event_cond(my_provider_event_enum_bitmap
) {
1157 side_arg_define_vec(myarray
,
1163 side_arg_u32(0x80000000), /* bit 159 */
1166 side_event_call(my_provider_event_enum_bitmap
,
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),
1174 side_arg_u64(1ULL << 63),
1175 side_arg_u64((1ULL << 1) | (1ULL << 63)),
1176 side_arg_byte(1U << 2),
1177 side_arg_array(&myarray
),
1178 side_arg_vla(&myarray
),
1179 #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN
1180 side_arg_u32(side_bswap_32(1U << 2)),
1181 side_arg_u32(1U << 2),
1183 side_arg_u32(1U << 2),
1184 side_arg_u32(side_bswap_32(1U << 2)),
1191 side_static_event_variadic(my_provider_event_blob
, "myprovider", "myeventblob", SIDE_LOGLEVEL_DEBUG
,
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()),
1200 void test_blob(void)
1202 side_event_cond(my_provider_event_blob
) {
1203 side_arg_define_vec(myarray
, side_arg_list(side_arg_byte(1), side_arg_byte(2), side_arg_byte(3)));
1204 side_arg_dynamic_define_vec(myvla
,
1206 side_arg_dynamic_byte(0x22, side_attr_list()),
1207 side_arg_dynamic_byte(0x33, side_attr_list()),
1211 side_event_call_variadic(my_provider_event_blob
,
1213 side_arg_byte(0x55),
1214 side_arg_array(&myarray
),
1217 side_arg_dynamic_field("varblobfield",
1218 side_arg_dynamic_byte(0x55, side_attr_list())
1220 side_arg_dynamic_field("varblobvla", side_arg_dynamic_vla(&myvla
)),
1227 side_static_event_variadic(my_provider_event_format_string
,
1228 "myprovider", "myeventformatstring", SIDE_LOGLEVEL_DEBUG
,
1230 side_field_string("fmt", side_attr_list()),
1233 side_attr("lang.c.format_string", side_attr_bool(true)),
1238 void test_fmt_string(void)
1240 side_event_cond(my_provider_event_format_string
) {
1241 side_arg_dynamic_define_vec(args
,
1243 side_arg_dynamic_string("blah", side_attr_list()),
1244 side_arg_dynamic_s32(123, side_attr_list()),
1248 side_event_call_variadic(my_provider_event_format_string
,
1250 side_arg_string("This is a formatted string with str: %s int: %d"),
1253 side_arg_dynamic_field("arguments", side_arg_dynamic_vla(&args
)),
1260 side_static_event_variadic(my_provider_event_endian
, "myprovider", "myevent_endian", SIDE_LOGLEVEL_DEBUG
,
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()),
1279 void test_endian(void)
1281 side_event_variadic(my_provider_event_endian
,
1283 #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN
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)),
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)),
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())),
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())),
1344 side_static_event(my_provider_event_base
, "myprovider", "myevent_base", SIDE_LOGLEVEL_DEBUG
,
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)))),
1383 void test_base(void)
1385 side_event(my_provider_event_base
,
1438 static side_define_struct(mystructgatherdef
,
1440 side_field_gather_unsigned_integer("a", offsetof(struct test
, a
),
1441 side_struct_field_sizeof(struct test
, a
), 0, 0,
1442 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1443 side_field_gather_signed_integer("d", offsetof(struct test
, d
),
1444 side_struct_field_sizeof(struct test
, d
), 0, 0,
1445 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1446 side_field_gather_unsigned_integer("e", offsetof(struct test
, e
),
1447 side_struct_field_sizeof(struct test
, e
), 8, 4,
1448 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1449 side_field_gather_signed_integer("f", offsetof(struct test
, f
),
1450 side_struct_field_sizeof(struct test
, f
), 1, 4,
1451 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1452 side_field_gather_signed_integer("g", offsetof(struct test
, g
),
1453 side_struct_field_sizeof(struct test
, g
), 11, 4,
1454 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1455 side_field_gather_signed_integer("h", offsetof(struct test
, h
),
1456 side_struct_field_sizeof(struct test
, h
), 1, 31,
1457 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1458 side_field_gather_signed_integer("i", offsetof(struct test
, i
),
1459 side_struct_field_sizeof(struct test
, i
), 33, 20,
1460 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1461 side_field_gather_signed_integer("j", offsetof(struct test
, j
),
1462 side_struct_field_sizeof(struct test
, j
), 63, 1,
1463 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1464 side_field_gather_signed_integer("k", offsetof(struct test
, k
),
1465 side_struct_field_sizeof(struct test
, k
), 1, 63,
1466 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1467 side_field_gather_unsigned_integer_le("test", offsetof(struct test
, test
),
1468 side_struct_field_sizeof(struct test
, test
), 0, 64,
1469 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1470 side_field_gather_unsigned_integer_le("test_le", offsetof(struct test
, test
),
1471 side_struct_field_sizeof(struct test
, test
), 0, 64,
1472 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1473 side_field_gather_unsigned_integer_be("test_be", offsetof(struct test
, test
),
1474 side_struct_field_sizeof(struct test
, test
), 0, 64,
1475 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
1480 side_static_event(my_provider_event_structgather
, "myprovider", "myeventstructgather", SIDE_LOGLEVEL_DEBUG
,
1482 side_field_gather_struct("structgather", &mystructgatherdef
, 0, sizeof(struct test
),
1483 SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1484 side_field_gather_signed_integer("intgather", 0, sizeof(int32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1485 side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
1487 side_field_gather_float("f32", 0, sizeof(_Float32
), SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1494 void test_struct_gather(void)
1496 side_event_cond(my_provider_event_structgather
) {
1497 struct test mystruct
= {
1515 side_event_call(my_provider_event_structgather
,
1517 side_arg_gather_struct(&mystruct
),
1518 side_arg_gather_integer(&val
),
1520 side_arg_gather_float(&f32
),
1533 struct testnest2
*nest
;
1538 struct testnest1
*nest
;
1541 static side_define_struct(mystructgathernest2
,
1543 side_field_gather_unsigned_integer("c", offsetof(struct testnest2
, c
),
1544 side_struct_field_sizeof(struct testnest2
, c
), 0, 0,
1545 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1550 static side_define_struct(mystructgathernest1
,
1552 side_field_gather_unsigned_integer("b", offsetof(struct testnest1
, b
),
1553 side_struct_field_sizeof(struct testnest1
, b
), 0, 0,
1554 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1555 side_field_gather_struct("nest2", &mystructgathernest2
,
1556 offsetof(struct testnest1
, nest
), sizeof(struct testnest2
),
1557 SIDE_TYPE_GATHER_ACCESS_POINTER
),
1562 static side_define_struct(mystructgathernest0
,
1564 side_field_gather_unsigned_integer("a", offsetof(struct testnest0
, a
),
1565 side_struct_field_sizeof(struct testnest0
, a
), 0, 0,
1566 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1567 side_field_gather_struct("nest1", &mystructgathernest1
,
1568 offsetof(struct testnest0
, nest
), sizeof(struct testnest1
),
1569 SIDE_TYPE_GATHER_ACCESS_POINTER
),
1574 side_static_event(my_provider_event_structgather_nest
,
1575 "myprovider", "myeventstructgathernest", SIDE_LOGLEVEL_DEBUG
,
1577 side_field_gather_struct("nest0", &mystructgathernest0
, 0,
1578 sizeof(struct testnest0
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1584 void test_struct_gather_nest_ptr(void)
1586 side_event_cond(my_provider_event_structgather_nest
) {
1587 struct testnest2 mystruct2
= {
1590 struct testnest1 mystruct1
= {
1594 struct testnest0 mystruct
= {
1598 side_event_call(my_provider_event_structgather_nest
,
1600 side_arg_gather_struct(&mystruct
),
1621 static side_define_struct(mystructgatherfloat
,
1624 side_field_gather_float("f16", offsetof(struct testfloat
, f16
), side_struct_field_sizeof(struct testfloat
, f16
),
1625 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1629 side_field_gather_float("f32", offsetof(struct testfloat
, f32
), side_struct_field_sizeof(struct testfloat
, f32
),
1630 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1634 side_field_gather_float("f64", offsetof(struct testfloat
, f64
), side_struct_field_sizeof(struct testfloat
, f64
),
1635 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1639 side_field_gather_float("f128", offsetof(struct testfloat
, f128
), side_struct_field_sizeof(struct testfloat
, f128
),
1640 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1647 side_static_event(my_provider_event_structgatherfloat
,
1648 "myprovider", "myeventstructgatherfloat", SIDE_LOGLEVEL_DEBUG
,
1650 side_field_gather_struct("structgatherfloat", &mystructgatherfloat
, 0,
1651 sizeof(struct testfloat
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1657 void test_struct_gather_float(void)
1659 side_event_cond(my_provider_event_structgatherfloat
) {
1660 struct testfloat mystruct
= {
1674 side_event_call(my_provider_event_structgatherfloat
,
1676 side_arg_gather_struct(&mystruct
),
1682 uint32_t mygatherarray
[] = { 1, 2, 3, 4, 5 };
1684 uint16_t mygatherarray2
[] = { 6, 7, 8, 9 };
1691 static side_define_struct(mystructgatherarray
,
1693 side_field_gather_array("array",
1694 side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1695 SIDE_ARRAY_SIZE(mygatherarray
),
1696 offsetof(struct testarray
, ptr
),
1697 SIDE_TYPE_GATHER_ACCESS_POINTER
,
1703 side_static_event(my_provider_event_structgatherarray
,
1704 "myprovider", "myeventstructgatherarray", SIDE_LOGLEVEL_DEBUG
,
1706 side_field_gather_struct("structgatherarray", &mystructgatherarray
, 0,
1707 sizeof(struct testarray
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1708 side_field_gather_array("array2",
1709 side_elem(side_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1710 SIDE_ARRAY_SIZE(mygatherarray2
), 0,
1711 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1719 void test_array_gather(void)
1721 side_event_cond(my_provider_event_structgatherarray
) {
1722 struct testarray mystruct
= {
1724 .ptr
= mygatherarray
,
1726 side_event_call(my_provider_event_structgatherarray
,
1728 side_arg_gather_struct(&mystruct
),
1729 side_arg_gather_array(&mygatherarray2
),
1735 #define TESTSGNESTARRAY_LEN 4
1736 struct testgatherstructnest1
{
1738 int c
[TESTSGNESTARRAY_LEN
];
1741 struct testgatherstructnest0
{
1742 struct testgatherstructnest1 nest
;
1743 struct testgatherstructnest1 nestarray
[2];
1747 static side_define_struct(mystructgatherstructnest1
,
1749 side_field_gather_signed_integer("b", offsetof(struct testgatherstructnest1
, b
),
1750 side_struct_field_sizeof(struct testgatherstructnest1
, b
), 0, 0,
1751 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1752 side_field_gather_array("c",
1754 side_type_gather_signed_integer(0, sizeof(uint32_t), 0, 0,
1755 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1757 TESTSGNESTARRAY_LEN
,
1758 offsetof(struct testgatherstructnest1
, c
),
1759 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1765 static side_define_struct(mystructgatherstructnest0
,
1767 side_field_gather_signed_integer("a", offsetof(struct testgatherstructnest0
, a
),
1768 side_struct_field_sizeof(struct testgatherstructnest0
, a
), 0, 0,
1769 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1770 side_field_gather_struct("structnest0", &mystructgatherstructnest1
,
1771 offsetof(struct testgatherstructnest0
, nest
),
1772 sizeof(struct testgatherstructnest1
),
1773 SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1774 side_field_gather_array("nestarray",
1776 side_type_gather_struct(&mystructgatherstructnest1
,
1778 sizeof(struct testgatherstructnest1
),
1779 SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1782 offsetof(struct testgatherstructnest0
, nestarray
),
1783 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1789 side_static_event(my_provider_event_gatherstructnest
,
1790 "myprovider", "myeventgatherstructnest", SIDE_LOGLEVEL_DEBUG
,
1792 side_field_gather_struct("structgather", &mystructgatherstructnest0
, 0,
1793 sizeof(struct testgatherstructnest0
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1799 void test_gather_structnest(void)
1801 side_event_cond(my_provider_event_gatherstructnest
) {
1802 struct testgatherstructnest0 mystruct
= {
1805 .c
= { 0, 1, 2, 3 },
1810 .c
= { 11, 12, 13, 14 },
1814 .c
= { 15, 16, 17, 18 },
1819 side_event_call(my_provider_event_gatherstructnest
,
1821 side_arg_gather_struct(&mystruct
),
1827 uint32_t gathervla
[] = { 1, 2, 3, 4 };
1828 uint32_t gathervla2
[] = { 5, 6, 7, 8, 9 };
1830 struct testgathervla
{
1836 static side_define_struct(mystructgathervla
,
1838 side_field_gather_signed_integer("a", offsetof(struct testgathervla
, a
),
1839 side_struct_field_sizeof(struct testgathervla
, a
), 0, 0,
1840 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()
1842 side_field_gather_vla("nestvla",
1843 side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1844 offsetof(struct testgathervla
, p
),
1845 SIDE_TYPE_GATHER_ACCESS_POINTER
,
1846 side_length(side_type_gather_unsigned_integer(offsetof(struct testgathervla
, len
),
1847 sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1854 side_static_event(my_provider_event_gathervla
,
1855 "myprovider", "myeventgathervla", SIDE_LOGLEVEL_DEBUG
,
1857 side_field_gather_struct("structgathervla", &mystructgathervla
, 0,
1858 sizeof(struct testgathervla
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1859 side_field_gather_vla("vla",
1860 side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1861 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1862 side_length(side_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1870 void test_gather_vla(void)
1872 side_event_cond(my_provider_event_gathervla
) {
1873 struct testgathervla mystruct
= {
1875 .len
= SIDE_ARRAY_SIZE(gathervla
),
1878 uint16_t vla2_len
= 5;
1879 side_event_call(my_provider_event_gathervla
,
1881 side_arg_gather_struct(&mystruct
),
1882 side_arg_gather_vla(gathervla2
, &vla2_len
),
1888 struct testgathervlaflex
{
1890 uint32_t otherfield
;
1894 static side_define_struct(mystructgathervlaflex
,
1896 side_field_gather_vla("vlaflex",
1897 side_elem(side_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1898 offsetof(struct testgathervlaflex
, array
),
1899 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
1900 side_length(side_type_gather_unsigned_integer(offsetof(struct testgathervlaflex
, len
),
1901 side_struct_field_sizeof(struct testgathervlaflex
, len
), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1908 side_static_event(my_provider_event_gathervlaflex
,
1909 "myprovider", "myeventgathervlaflex", SIDE_LOGLEVEL_DEBUG
,
1911 side_field_gather_struct("structgathervlaflex", &mystructgathervlaflex
, 0,
1912 sizeof(struct testgathervlaflex
), SIDE_TYPE_GATHER_ACCESS_DIRECT
),
1917 #define VLAFLEXLEN 6
1919 void test_gather_vla_flex(void)
1921 side_event_cond(my_provider_event_gathervlaflex
) {
1922 struct testgathervlaflex
*mystruct
=
1923 (struct testgathervlaflex
*) malloc(sizeof(*mystruct
) + VLAFLEXLEN
+ sizeof(uint64_t));
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;
1933 side_event_call(my_provider_event_gathervlaflex
,
1935 side_arg_gather_struct(mystruct
),
1942 side_static_event(my_provider_event_gatherbyte
,
1943 "myprovider", "myeventgatherbyte", SIDE_LOGLEVEL_DEBUG
,
1945 side_field_gather_byte("byte", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1946 side_field_gather_array("array",
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()
1955 void test_gather_byte(void)
1957 side_event_cond(my_provider_event_gatherbyte
) {
1959 uint8_t array
[3] = { 0x1, 0x2, 0x3 };
1961 side_event_call(my_provider_event_gatherbyte
,
1963 side_arg_gather_byte(&v
),
1964 side_arg_gather_array(array
),
1970 #define ARRAYBOOLLEN 4
1971 static bool arraybool
[ARRAYBOOLLEN
] = { false, true, false, true };
1973 side_static_event(my_provider_event_gatherbool
,
1974 "myprovider", "myeventgatherbool", SIDE_LOGLEVEL_DEBUG
,
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,
1981 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1982 side_field_gather_bool("v4_false", 0, sizeof(uint16_t), 1, 1,
1983 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()),
1984 side_field_gather_array("arraybool",
1985 side_elem(side_type_gather_bool(0, sizeof(bool), 0, 0,
1986 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())),
1987 ARRAYBOOLLEN
, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list()
1994 void test_gather_bool(void)
1996 side_event_cond(my_provider_event_structgatherarray
) {
1999 uint16_t v3
= 1U << 1;
2000 uint16_t v4
= 1U << 2;
2002 side_event_call(my_provider_event_gatherbool
,
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
),
2014 side_static_event(my_provider_event_gatherpointer
,
2015 "myprovider", "myeventgatherpointer", SIDE_LOGLEVEL_DEBUG
,
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()
2027 void test_gather_pointer(void)
2029 side_event_cond(my_provider_event_structgatherarray
) {
2030 void *v
= (void *)0x44;
2031 void *array
[3] = { (void *)0x1, (void *)0x2, (void *)0x3 };
2033 side_event_call(my_provider_event_gatherpointer
,
2035 side_arg_gather_pointer(&v
),
2036 side_arg_gather_array(array
),
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),
2052 side_static_event(my_provider_event_enum_gather
, "myprovider", "myeventenumgather", SIDE_LOGLEVEL_DEBUG
,
2054 side_field_gather_enum("5", &myenumgather
,
2056 side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0,
2057 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2060 side_field_gather_enum("400", &myenumgather
,
2062 side_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0,
2063 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2066 side_field_gather_enum("200", &myenumgather
,
2068 side_type_gather_unsigned_integer(0, sizeof(uint8_t), 0, 0,
2069 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2072 side_field_gather_enum("-100", &myenumgather
,
2074 side_type_gather_signed_integer(0, sizeof(int8_t), 0, 0,
2075 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2078 side_field_gather_enum("6_be", &myenumgather
,
2080 side_type_gather_unsigned_integer_be(0, sizeof(uint32_t), 0, 0,
2081 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2084 side_field_gather_enum("6_le", &myenumgather
,
2086 side_type_gather_unsigned_integer_le(0, sizeof(uint32_t), 0, 0,
2087 SIDE_TYPE_GATHER_ACCESS_DIRECT
, side_attr_list())
2095 void test_gather_enum(void)
2101 #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN
2102 uint32_t v5
= side_bswap_32(6);
2106 uint32_t v6
= side_bswap_32(6);
2109 side_event(my_provider_event_enum_gather
,
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
),
2124 test_event_hidden();
2125 test_event_export();
2126 test_struct_literal();
2131 test_vla_visitor_2d();
2132 test_dynamic_basic_type();
2134 test_dynamic_null();
2135 test_dynamic_struct();
2136 test_dynamic_nested_struct();
2137 test_dynamic_vla_struct();
2138 test_dynamic_struct_vla();
2139 test_dynamic_nested_vla();
2141 test_static_variadic();
2143 test_dynamic_bool();
2144 test_dynamic_vla_with_visitor();
2145 test_dynamic_struct_with_visitor();
2146 test_event_user_attribute();
2147 test_field_user_attribute();
2148 test_variadic_attr();
2149 test_variadic_vla_attr();
2150 test_variadic_struct_attr();
2152 test_variadic_float();
2159 test_struct_gather();
2160 test_struct_gather_nest_ptr();
2161 test_struct_gather_float();
2162 test_array_gather();
2163 test_gather_structnest();
2165 test_gather_vla_flex();
2168 test_gather_pointer();