1 // SPDX-License-Identifier: MIT
3 * Copyright 2022 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 #include <tgif/trace.h>
15 /* User code example */
17 tgif_static_event(my_provider_event
, "myprovider", "myevent", TGIF_LOGLEVEL_DEBUG
,
19 tgif_field_u32("abc", tgif_attr_list()),
20 tgif_field_s64("def", tgif_attr_list()),
21 tgif_field_pointer("ptr", tgif_attr_list()),
22 tgif_field_dynamic("dynamic"),
23 tgif_field_dynamic("dynamic_pointer"),
24 tgif_field_null("null", tgif_attr_list()),
30 void test_fields(void)
35 tgif_event(my_provider_event
,
39 tgif_arg_pointer((void *) 0x1),
40 tgif_arg_dynamic_string("zzz", tgif_attr_list()),
41 tgif_arg_dynamic_pointer((void *) 0x1, tgif_attr_list()),
47 tgif_hidden_event(my_provider_event_hidden
, "myprovider", "myeventhidden", TGIF_LOGLEVEL_DEBUG
,
49 tgif_field_u32("abc", tgif_attr_list()),
55 void test_event_hidden(void)
57 tgif_event(my_provider_event_hidden
, tgif_arg_list(tgif_arg_u32(2)));
60 tgif_declare_event(my_provider_event_export
);
62 tgif_export_event(my_provider_event_export
, "myprovider", "myeventexport", TGIF_LOGLEVEL_DEBUG
,
64 tgif_field_u32("abc", tgif_attr_list()),
70 void test_event_export(void)
72 tgif_event(my_provider_event_export
, tgif_arg_list(tgif_arg_u32(2)));
75 tgif_static_event(my_provider_event_struct_literal
, "myprovider", "myeventstructliteral", TGIF_LOGLEVEL_DEBUG
,
77 tgif_field_struct("structliteral",
80 tgif_field_u32("x", tgif_attr_list()),
81 tgif_field_s64("y", tgif_attr_list()),
86 tgif_field_u8("z", tgif_attr_list()),
92 void test_struct_literal(void)
94 tgif_event_cond(my_provider_event_struct_literal
) {
95 tgif_arg_define_vec(mystruct
, tgif_arg_list(tgif_arg_u32(21), tgif_arg_s64(22)));
96 tgif_event_call(my_provider_event_struct_literal
, tgif_arg_list(tgif_arg_struct(&mystruct
), tgif_arg_u8(55)));
100 static tgif_define_struct(mystructdef
,
102 tgif_field_u32("x", tgif_attr_list()),
103 tgif_field_s64("y", tgif_attr_list()),
108 tgif_static_event(my_provider_event_struct
, "myprovider", "myeventstruct", TGIF_LOGLEVEL_DEBUG
,
110 tgif_field_struct("struct", &mystructdef
),
111 tgif_field_u8("z", tgif_attr_list()),
117 void test_struct(void)
119 tgif_event_cond(my_provider_event_struct
) {
120 tgif_arg_define_vec(mystruct
, tgif_arg_list(tgif_arg_u32(21), tgif_arg_s64(22)));
121 tgif_event_call(my_provider_event_struct
, tgif_arg_list(tgif_arg_struct(&mystruct
), tgif_arg_u8(55)));
125 tgif_static_event(my_provider_event_array
, "myprovider", "myarray", TGIF_LOGLEVEL_DEBUG
,
127 tgif_field_array("arr", tgif_elem(tgif_type_u32(tgif_attr_list())), 3, tgif_attr_list()),
128 tgif_field_s64("v", tgif_attr_list()),
134 void test_array(void)
136 tgif_event_cond(my_provider_event_array
) {
137 tgif_arg_define_vec(myarray
, tgif_arg_list(tgif_arg_u32(1), tgif_arg_u32(2), tgif_arg_u32(3)));
138 tgif_event_call(my_provider_event_array
, tgif_arg_list(tgif_arg_array(&myarray
), tgif_arg_s64(42)));
142 tgif_static_event(my_provider_event_vla
, "myprovider", "myvla", TGIF_LOGLEVEL_DEBUG
,
144 tgif_field_vla("vla", tgif_elem(tgif_type_u32(tgif_attr_list())), tgif_attr_list()),
145 tgif_field_s64("v", tgif_attr_list()),
153 tgif_event_cond(my_provider_event_vla
) {
154 tgif_arg_define_vec(myvla
, tgif_arg_list(tgif_arg_u32(1), tgif_arg_u32(2), tgif_arg_u32(3)));
155 tgif_event_call(my_provider_event_vla
, tgif_arg_list(tgif_arg_vla(&myvla
), tgif_arg_s64(42)));
159 /* 1D array visitor */
161 struct app_visitor_ctx
{
167 enum tgif_visitor_status
test_visitor(const struct tgif_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 tgif_arg elem
= tgif_arg_u32(ctx
->ptr
[i
]);
175 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != TGIF_VISITOR_STATUS_OK
)
176 return TGIF_VISITOR_STATUS_ERROR
;
178 return TGIF_VISITOR_STATUS_OK
;
181 static uint32_t testarray
[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
183 tgif_static_event(my_provider_event_vla_visitor
, "myprovider", "myvlavisit", TGIF_LOGLEVEL_DEBUG
,
185 tgif_field_vla_visitor("vlavisit", tgif_elem(tgif_type_u32(tgif_attr_list())), test_visitor
, tgif_attr_list()),
186 tgif_field_s64("v", tgif_attr_list()),
192 void test_vla_visitor(void)
194 tgif_event_cond(my_provider_event_vla_visitor
) {
195 struct app_visitor_ctx ctx
= {
197 .length
= TGIF_ARRAY_SIZE(testarray
),
199 tgif_event_call(my_provider_event_vla_visitor
, tgif_arg_list(tgif_arg_vla_visitor(&ctx
), tgif_arg_s64(42)));
203 /* 2D array visitor */
205 struct app_visitor_2d_inner_ctx
{
211 enum tgif_visitor_status
test_inner_visitor(const struct tgif_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 tgif_arg elem
= tgif_arg_u32(ctx
->ptr
[i
]);
219 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != TGIF_VISITOR_STATUS_OK
)
220 return TGIF_VISITOR_STATUS_ERROR
;
222 return TGIF_VISITOR_STATUS_OK
;
225 struct app_visitor_2d_outer_ctx
{
226 const uint32_t (*ptr
)[2];
231 enum tgif_visitor_status
test_outer_visitor(const struct tgif_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 tgif_arg elem
= tgif_arg_vla_visitor(&inner_ctx
);
242 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != TGIF_VISITOR_STATUS_OK
)
243 return TGIF_VISITOR_STATUS_ERROR
;
245 return TGIF_VISITOR_STATUS_OK
;
248 static uint32_t testarray2d
[][2] = {
254 tgif_static_event(my_provider_event_vla_visitor2d
, "myprovider", "myvlavisit2d", TGIF_LOGLEVEL_DEBUG
,
256 tgif_field_vla_visitor("vlavisit2d",
258 tgif_type_vla_visitor(
259 tgif_elem(tgif_type_u32(tgif_attr_list())),
262 ), test_outer_visitor
, tgif_attr_list()),
263 tgif_field_s64("v", tgif_attr_list()),
269 void test_vla_visitor_2d(void)
271 tgif_event_cond(my_provider_event_vla_visitor2d
) {
272 struct app_visitor_2d_outer_ctx ctx
= {
274 .length
= TGIF_ARRAY_SIZE(testarray2d
),
276 tgif_event_call(my_provider_event_vla_visitor2d
, tgif_arg_list(tgif_arg_vla_visitor(&ctx
), tgif_arg_s64(42)));
280 tgif_static_event(my_provider_event_dynamic_basic
,
281 "myprovider", "mydynamicbasic", TGIF_LOGLEVEL_DEBUG
,
283 tgif_field_dynamic("dynamic"),
289 void test_dynamic_basic_type(void)
291 tgif_event(my_provider_event_dynamic_basic
,
292 tgif_arg_list(tgif_arg_dynamic_s16(-33, tgif_attr_list())));
295 tgif_static_event(my_provider_event_dynamic_vla
,
296 "myprovider", "mydynamicvla", TGIF_LOGLEVEL_DEBUG
,
298 tgif_field_dynamic("dynamic"),
304 void test_dynamic_vla(void)
306 tgif_arg_dynamic_define_vec(myvla
,
308 tgif_arg_dynamic_u32(1, tgif_attr_list()),
309 tgif_arg_dynamic_u32(2, tgif_attr_list()),
310 tgif_arg_dynamic_u32(3, tgif_attr_list()),
314 tgif_event(my_provider_event_dynamic_vla
,
315 tgif_arg_list(tgif_arg_dynamic_vla(&myvla
)));
318 tgif_static_event(my_provider_event_dynamic_null
,
319 "myprovider", "mydynamicnull", TGIF_LOGLEVEL_DEBUG
,
321 tgif_field_dynamic("dynamic"),
327 void test_dynamic_null(void)
329 tgif_event(my_provider_event_dynamic_null
,
330 tgif_arg_list(tgif_arg_dynamic_null(tgif_attr_list())));
333 tgif_static_event(my_provider_event_dynamic_struct
,
334 "myprovider", "mydynamicstruct", TGIF_LOGLEVEL_DEBUG
,
336 tgif_field_dynamic("dynamic"),
342 void test_dynamic_struct(void)
344 tgif_arg_dynamic_define_struct(mystruct
,
346 tgif_arg_dynamic_field("a", tgif_arg_dynamic_u32(43, tgif_attr_list())),
347 tgif_arg_dynamic_field("b", tgif_arg_dynamic_string("zzz", tgif_attr_list())),
348 tgif_arg_dynamic_field("c", tgif_arg_dynamic_null(tgif_attr_list())),
353 tgif_event(my_provider_event_dynamic_struct
,
354 tgif_arg_list(tgif_arg_dynamic_struct(&mystruct
)));
357 tgif_static_event(my_provider_event_dynamic_nested_struct
,
358 "myprovider", "mydynamicnestedstruct", TGIF_LOGLEVEL_DEBUG
,
360 tgif_field_dynamic("dynamic"),
366 void test_dynamic_nested_struct(void)
368 tgif_arg_dynamic_define_struct(nested
,
370 tgif_arg_dynamic_field("a", tgif_arg_dynamic_u32(43, tgif_attr_list())),
371 tgif_arg_dynamic_field("b", tgif_arg_dynamic_u8(55, tgif_attr_list())),
375 tgif_arg_dynamic_define_struct(nested2
,
377 tgif_arg_dynamic_field("aa", tgif_arg_dynamic_u64(128, tgif_attr_list())),
378 tgif_arg_dynamic_field("bb", tgif_arg_dynamic_u16(1, tgif_attr_list())),
382 tgif_arg_dynamic_define_struct(mystruct
,
384 tgif_arg_dynamic_field("nested", tgif_arg_dynamic_struct(&nested
)),
385 tgif_arg_dynamic_field("nested2", tgif_arg_dynamic_struct(&nested2
)),
389 tgif_event(my_provider_event_dynamic_nested_struct
,
390 tgif_arg_list(tgif_arg_dynamic_struct(&mystruct
)));
393 tgif_static_event(my_provider_event_dynamic_vla_struct
,
394 "myprovider", "mydynamicvlastruct", TGIF_LOGLEVEL_DEBUG
,
396 tgif_field_dynamic("dynamic"),
402 void test_dynamic_vla_struct(void)
404 tgif_arg_dynamic_define_struct(nested
,
406 tgif_arg_dynamic_field("a", tgif_arg_dynamic_u32(43, tgif_attr_list())),
407 tgif_arg_dynamic_field("b", tgif_arg_dynamic_u8(55, tgif_attr_list())),
411 tgif_arg_dynamic_define_vec(myvla
,
413 tgif_arg_dynamic_struct(&nested
),
414 tgif_arg_dynamic_struct(&nested
),
415 tgif_arg_dynamic_struct(&nested
),
416 tgif_arg_dynamic_struct(&nested
),
420 tgif_event(my_provider_event_dynamic_vla_struct
,
421 tgif_arg_list(tgif_arg_dynamic_vla(&myvla
)));
424 tgif_static_event(my_provider_event_dynamic_struct_vla
,
425 "myprovider", "mydynamicstructvla", TGIF_LOGLEVEL_DEBUG
,
427 tgif_field_dynamic("dynamic"),
433 void test_dynamic_struct_vla(void)
435 tgif_arg_dynamic_define_vec(myvla
,
437 tgif_arg_dynamic_u32(1, tgif_attr_list()),
438 tgif_arg_dynamic_u32(2, tgif_attr_list()),
439 tgif_arg_dynamic_u32(3, tgif_attr_list()),
443 tgif_arg_dynamic_define_vec(myvla2
,
445 tgif_arg_dynamic_u32(4, tgif_attr_list()),
446 tgif_arg_dynamic_u64(5, tgif_attr_list()),
447 tgif_arg_dynamic_u32(6, tgif_attr_list()),
451 tgif_arg_dynamic_define_struct(mystruct
,
453 tgif_arg_dynamic_field("a", tgif_arg_dynamic_vla(&myvla
)),
454 tgif_arg_dynamic_field("b", tgif_arg_dynamic_vla(&myvla2
)),
458 tgif_event(my_provider_event_dynamic_struct_vla
,
459 tgif_arg_list(tgif_arg_dynamic_struct(&mystruct
)));
462 tgif_static_event(my_provider_event_dynamic_nested_vla
,
463 "myprovider", "mydynamicnestedvla", TGIF_LOGLEVEL_DEBUG
,
465 tgif_field_dynamic("dynamic"),
471 void test_dynamic_nested_vla(void)
473 tgif_arg_dynamic_define_vec(nestedvla
,
475 tgif_arg_dynamic_u32(1, tgif_attr_list()),
476 tgif_arg_dynamic_u16(2, tgif_attr_list()),
477 tgif_arg_dynamic_u32(3, tgif_attr_list()),
481 tgif_arg_dynamic_define_vec(nestedvla2
,
483 tgif_arg_dynamic_u8(4, tgif_attr_list()),
484 tgif_arg_dynamic_u32(5, tgif_attr_list()),
485 tgif_arg_dynamic_u32(6, tgif_attr_list()),
489 tgif_arg_dynamic_define_vec(myvla
,
491 tgif_arg_dynamic_vla(&nestedvla
),
492 tgif_arg_dynamic_vla(&nestedvla2
),
496 tgif_event(my_provider_event_dynamic_nested_vla
,
497 tgif_arg_list(tgif_arg_dynamic_vla(&myvla
)));
500 tgif_static_event_variadic(my_provider_event_variadic
,
501 "myprovider", "myvariadicevent", TGIF_LOGLEVEL_DEBUG
,
507 void test_variadic(void)
509 tgif_event_variadic(my_provider_event_variadic
,
512 tgif_arg_dynamic_field("a", tgif_arg_dynamic_u32(55, tgif_attr_list())),
513 tgif_arg_dynamic_field("b", tgif_arg_dynamic_s8(-4, tgif_attr_list())),
519 tgif_static_event_variadic(my_provider_event_static_variadic
,
520 "myprovider", "mystaticvariadicevent", TGIF_LOGLEVEL_DEBUG
,
522 tgif_field_u32("abc", tgif_attr_list()),
523 tgif_field_u16("def", tgif_attr_list()),
529 void test_static_variadic(void)
531 tgif_event_variadic(my_provider_event_static_variadic
,
537 tgif_arg_dynamic_field("a", tgif_arg_dynamic_u32(55, tgif_attr_list())),
538 tgif_arg_dynamic_field("b", tgif_arg_dynamic_s8(-4, tgif_attr_list())),
544 tgif_static_event(my_provider_event_bool
, "myprovider", "myeventbool", TGIF_LOGLEVEL_DEBUG
,
546 tgif_field_bool("a_false", tgif_attr_list()),
547 tgif_field_bool("b_true", tgif_attr_list()),
548 tgif_field_bool("c_true", tgif_attr_list()),
549 tgif_field_bool("d_true", tgif_attr_list()),
550 tgif_field_bool("e_true", tgif_attr_list()),
551 tgif_field_bool("f_false", tgif_attr_list()),
552 tgif_field_bool("g_true", tgif_attr_list()),
562 uint64_t c
= 0x12345678;
568 tgif_event(my_provider_event_bool
,
581 tgif_static_event_variadic(my_provider_event_dynamic_bool
,
582 "myprovider", "mydynamicbool", TGIF_LOGLEVEL_DEBUG
,
588 void test_dynamic_bool(void)
590 tgif_event_variadic(my_provider_event_dynamic_bool
,
593 tgif_arg_dynamic_field("a_true", tgif_arg_dynamic_bool(55, tgif_attr_list())),
594 tgif_arg_dynamic_field("b_true", tgif_arg_dynamic_bool(-4, tgif_attr_list())),
595 tgif_arg_dynamic_field("c_false", tgif_arg_dynamic_bool(0, tgif_attr_list())),
596 tgif_arg_dynamic_field("d_true", tgif_arg_dynamic_bool(256, tgif_attr_list())),
602 tgif_static_event(my_provider_event_dynamic_vla_visitor
,
603 "myprovider", "mydynamicvlavisitor", TGIF_LOGLEVEL_DEBUG
,
605 tgif_field_dynamic("dynamic"),
610 struct app_dynamic_vla_visitor_ctx
{
616 enum tgif_visitor_status
test_dynamic_vla_visitor(const struct tgif_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 tgif_arg elem
= tgif_arg_dynamic_u32(ctx
->ptr
[i
], tgif_attr_list());
623 if (tracer_ctx
->write_elem(tracer_ctx
, &elem
) != TGIF_VISITOR_STATUS_OK
)
624 return TGIF_VISITOR_STATUS_ERROR
;
626 return TGIF_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 tgif_event_cond(my_provider_event_dynamic_vla_visitor
) {
635 struct app_dynamic_vla_visitor_ctx ctx
= {
636 .ptr
= testarray_dynamic_vla
,
637 .length
= TGIF_ARRAY_SIZE(testarray_dynamic_vla
),
639 tgif_event_call(my_provider_event_dynamic_vla_visitor
,
641 tgif_arg_dynamic_vla_visitor(test_dynamic_vla_visitor
, &ctx
, tgif_attr_list())
647 tgif_static_event(my_provider_event_dynamic_struct_visitor
,
648 "myprovider", "mydynamicstructvisitor", TGIF_LOGLEVEL_DEBUG
,
650 tgif_field_dynamic("dynamic"),
655 struct struct_visitor_pair
{
660 struct app_dynamic_struct_visitor_ctx
{
661 const struct struct_visitor_pair
*ptr
;
666 enum tgif_visitor_status
test_dynamic_struct_visitor(const struct tgif_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 tgif_arg_dynamic_field dynamic_field
= {
673 .field_name
= ctx
->ptr
[i
].name
,
674 .elem
= tgif_arg_dynamic_u32(ctx
->ptr
[i
].value
, tgif_attr_list()),
676 if (tracer_ctx
->write_field(tracer_ctx
, &dynamic_field
) != TGIF_VISITOR_STATUS_OK
)
677 return TGIF_VISITOR_STATUS_ERROR
;
679 return TGIF_VISITOR_STATUS_OK
;
682 static struct struct_visitor_pair testarray_dynamic_struct
[] = {
690 void test_dynamic_struct_with_visitor(void)
692 tgif_event_cond(my_provider_event_dynamic_struct_visitor
) {
693 struct app_dynamic_struct_visitor_ctx ctx
= {
694 .ptr
= testarray_dynamic_struct
,
695 .length
= TGIF_ARRAY_SIZE(testarray_dynamic_struct
),
697 tgif_event_call(my_provider_event_dynamic_struct_visitor
,
699 tgif_arg_dynamic_struct_visitor(test_dynamic_struct_visitor
, &ctx
, tgif_attr_list())
705 tgif_static_event(my_provider_event_user_attribute
, "myprovider", "myevent_user_attribute", TGIF_LOGLEVEL_DEBUG
,
707 tgif_field_u32("abc", tgif_attr_list()),
708 tgif_field_s64("def", tgif_attr_list()),
711 tgif_attr("user_attribute_a", tgif_attr_string("val1")),
712 tgif_attr("user_attribute_b", tgif_attr_string("val2")),
717 void test_event_user_attribute(void)
719 tgif_event(my_provider_event_user_attribute
, tgif_arg_list(tgif_arg_u32(1), tgif_arg_s64(2)));
722 tgif_static_event(my_provider_field_user_attribute
, "myprovider", "myevent_field_attribute", TGIF_LOGLEVEL_DEBUG
,
724 tgif_field_u32("abc",
726 tgif_attr("user_attribute_a", tgif_attr_string("val1")),
727 tgif_attr("user_attribute_b", tgif_attr_u32(2)),
730 tgif_field_s64("def",
732 tgif_attr("user_attribute_c", tgif_attr_string("val3")),
733 tgif_attr("user_attribute_d", tgif_attr_s64(-5)),
741 void test_field_user_attribute(void)
743 tgif_event(my_provider_field_user_attribute
, tgif_arg_list(tgif_arg_u32(1), tgif_arg_s64(2)));
746 tgif_static_event_variadic(my_provider_event_variadic_attr
,
747 "myprovider", "myvariadiceventattr", TGIF_LOGLEVEL_DEBUG
,
753 void test_variadic_attr(void)
755 tgif_event_variadic(my_provider_event_variadic_attr
,
758 tgif_arg_dynamic_field("a",
759 tgif_arg_dynamic_u32(55,
761 tgif_attr("user_attribute_c", tgif_attr_string("valX")),
762 tgif_attr("user_attribute_d", tgif_attr_u8(55)),
766 tgif_arg_dynamic_field("b",
767 tgif_arg_dynamic_s8(-4,
769 tgif_attr("X", tgif_attr_u8(1)),
770 tgif_attr("Y", tgif_attr_s8(2)),
779 tgif_static_event_variadic(my_provider_event_variadic_vla_attr
,
780 "myprovider", "myvariadiceventvlaattr", TGIF_LOGLEVEL_DEBUG
,
786 void test_variadic_vla_attr(void)
788 tgif_arg_dynamic_define_vec(myvla
,
790 tgif_arg_dynamic_u32(1,
792 tgif_attr("Z", tgif_attr_u8(0)),
793 tgif_attr("A", tgif_attr_u8(123)),
796 tgif_arg_dynamic_u32(2, tgif_attr_list()),
797 tgif_arg_dynamic_u32(3, tgif_attr_list()),
800 tgif_attr("X", tgif_attr_u8(1)),
801 tgif_attr("Y", tgif_attr_u8(2)),
804 tgif_event_variadic(my_provider_event_variadic_vla_attr
,
807 tgif_arg_dynamic_field("a", tgif_arg_dynamic_vla(&myvla
)),
813 tgif_static_event_variadic(my_provider_event_variadic_struct_attr
,
814 "myprovider", "myvariadiceventstructattr", TGIF_LOGLEVEL_DEBUG
,
820 void test_variadic_struct_attr(void)
822 tgif_event_cond(my_provider_event_variadic_struct_attr
) {
823 tgif_arg_dynamic_define_struct(mystruct
,
825 tgif_arg_dynamic_field("a",
826 tgif_arg_dynamic_u32(43,
828 tgif_attr("A", tgif_attr_bool(true)),
832 tgif_arg_dynamic_field("b", tgif_arg_dynamic_u8(55, tgif_attr_list())),
835 tgif_attr("X", tgif_attr_u8(1)),
836 tgif_attr("Y", tgif_attr_u8(2)),
839 tgif_event_call_variadic(my_provider_event_variadic_struct_attr
,
842 tgif_arg_dynamic_field("a", tgif_arg_dynamic_struct(&mystruct
)),
849 tgif_static_event(my_provider_event_float
, "myprovider", "myeventfloat", TGIF_LOGLEVEL_DEBUG
,
852 tgif_field_float_binary16("binary16", tgif_attr_list()),
853 tgif_field_float_binary16_le("binary16_le", tgif_attr_list()),
854 tgif_field_float_binary16_be("binary16_be", tgif_attr_list()),
857 tgif_field_float_binary32("binary32", tgif_attr_list()),
858 tgif_field_float_binary32_le("binary32_le", tgif_attr_list()),
859 tgif_field_float_binary32_be("binary32_be", tgif_attr_list()),
862 tgif_field_float_binary64("binary64", tgif_attr_list()),
863 tgif_field_float_binary64_le("binary64_le", tgif_attr_list()),
864 tgif_field_float_binary64_be("binary64_be", tgif_attr_list()),
867 tgif_field_float_binary128("binary128", tgif_attr_list()),
868 tgif_field_float_binary128_le("binary128_le", tgif_attr_list()),
869 tgif_field_float_binary128_be("binary128_be", tgif_attr_list()),
876 void test_float(void)
912 float16
.u
= tgif_bswap_16(float16
.u
);
915 float32
.u
= tgif_bswap_32(float32
.u
);
918 float64
.u
= tgif_bswap_64(float64
.u
);
921 tgif_bswap_128p(float128
.arr
);
924 tgif_event(my_provider_event_float
,
927 tgif_arg_float_binary16(1.1),
928 # if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN
929 tgif_arg_float_binary16(1.1),
930 tgif_arg_float_binary16(float16
.f
),
932 tgif_arg_float_binary16(float16
.f
),
933 tgif_arg_float_binary16(1.1),
937 tgif_arg_float_binary32(2.2),
938 # if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN
939 tgif_arg_float_binary32(2.2),
940 tgif_arg_float_binary32(float32
.f
),
942 tgif_arg_float_binary32(float32
.f
),
943 tgif_arg_float_binary32(2.2),
947 tgif_arg_float_binary64(3.3),
948 # if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN
949 tgif_arg_float_binary64(3.3),
950 tgif_arg_float_binary64(float64
.f
),
952 tgif_arg_float_binary64(float64
.f
),
953 tgif_arg_float_binary64(3.3),
957 tgif_arg_float_binary128(4.4),
958 # if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN
959 tgif_arg_float_binary128(4.4),
960 tgif_arg_float_binary128(float128
.f
),
962 tgif_arg_float_binary128(float128
.f
),
963 tgif_arg_float_binary128(4.4),
970 tgif_static_event_variadic(my_provider_event_variadic_float
,
971 "myprovider", "myvariadicfloat", TGIF_LOGLEVEL_DEBUG
,
977 void test_variadic_float(void)
1013 float16
.u
= tgif_bswap_16(float16
.u
);
1016 float32
.u
= tgif_bswap_32(float32
.u
);
1019 float64
.u
= tgif_bswap_64(float64
.u
);
1022 tgif_bswap_128p(float128
.arr
);
1025 tgif_event_variadic(my_provider_event_variadic_float
,
1029 tgif_arg_dynamic_field("binary16", tgif_arg_dynamic_float_binary16(1.1, tgif_attr_list())),
1030 # if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN
1031 tgif_arg_dynamic_field("binary16_le", tgif_arg_dynamic_float_binary16_le(1.1, tgif_attr_list())),
1032 tgif_arg_dynamic_field("binary16_be", tgif_arg_dynamic_float_binary16_be(float16
.f
, tgif_attr_list())),
1034 tgif_arg_dynamic_field("binary16_le", tgif_arg_dynamic_float_binary16_le(float16
.f
, tgif_attr_list())),
1035 tgif_arg_dynamic_field("binary16_be", tgif_arg_dynamic_float_binary16_be(1.1, tgif_attr_list())),
1039 tgif_arg_dynamic_field("binary32", tgif_arg_dynamic_float_binary32(2.2, tgif_attr_list())),
1040 # if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN
1041 tgif_arg_dynamic_field("binary32_le", tgif_arg_dynamic_float_binary32_le(2.2, tgif_attr_list())),
1042 tgif_arg_dynamic_field("binary32_be", tgif_arg_dynamic_float_binary32_be(float32
.f
, tgif_attr_list())),
1044 tgif_arg_dynamic_field("binary32_le", tgif_arg_dynamic_float_binary32_le(float32
.f
, tgif_attr_list())),
1045 tgif_arg_dynamic_field("binary32_be", tgif_arg_dynamic_float_binary32_be(2.2, tgif_attr_list())),
1049 tgif_arg_dynamic_field("binary64", tgif_arg_dynamic_float_binary64(3.3, tgif_attr_list())),
1050 # if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN
1051 tgif_arg_dynamic_field("binary64_le", tgif_arg_dynamic_float_binary64_le(3.3, tgif_attr_list())),
1052 tgif_arg_dynamic_field("binary64_be", tgif_arg_dynamic_float_binary64_be(float64
.f
, tgif_attr_list())),
1054 tgif_arg_dynamic_field("binary64_le", tgif_arg_dynamic_float_binary64_le(float64
.f
, tgif_attr_list())),
1055 tgif_arg_dynamic_field("binary64_be", tgif_arg_dynamic_float_binary64_be(3.3, tgif_attr_list())),
1059 tgif_arg_dynamic_field("binary128", tgif_arg_dynamic_float_binary128(4.4, tgif_attr_list())),
1060 # if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN
1061 tgif_arg_dynamic_field("binary128_le", tgif_arg_dynamic_float_binary128_le(4.4, tgif_attr_list())),
1062 tgif_arg_dynamic_field("binary128_be", tgif_arg_dynamic_float_binary128_be(float128
.f
, tgif_attr_list())),
1064 tgif_arg_dynamic_field("binary128_le", tgif_arg_dynamic_float_binary128_le(float128
.f
, tgif_attr_list())),
1065 tgif_arg_dynamic_field("binary128_be", tgif_arg_dynamic_float_binary128_be(4.4, tgif_attr_list())),
1073 static tgif_define_enum(myenum
,
1074 tgif_enum_mapping_list(
1075 tgif_enum_mapping_range("one-ten", 1, 10),
1076 tgif_enum_mapping_range("100-200", 100, 200),
1077 tgif_enum_mapping_value("200", 200),
1078 tgif_enum_mapping_value("300", 300),
1083 tgif_static_event(my_provider_event_enum
, "myprovider", "myeventenum", TGIF_LOGLEVEL_DEBUG
,
1085 tgif_field_enum("5", &myenum
, tgif_elem(tgif_type_u32(tgif_attr_list()))),
1086 tgif_field_enum("400", &myenum
, tgif_elem(tgif_type_u64(tgif_attr_list()))),
1087 tgif_field_enum("200", &myenum
, tgif_elem(tgif_type_u8(tgif_attr_list()))),
1088 tgif_field_enum("-100", &myenum
, tgif_elem(tgif_type_s8(tgif_attr_list()))),
1089 tgif_field_enum("6_be", &myenum
, tgif_elem(tgif_type_u32_be(tgif_attr_list()))),
1090 tgif_field_enum("6_le", &myenum
, tgif_elem(tgif_type_u32_le(tgif_attr_list()))),
1096 void test_enum(void)
1098 tgif_event(my_provider_event_enum
,
1104 #if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN
1105 tgif_arg_u32(tgif_bswap_32(6)),
1109 tgif_arg_u32(tgif_bswap_32(6)),
1115 /* A bitmap enum maps bits to labels. */
1116 static tgif_define_enum_bitmap(myenum_bitmap
,
1117 tgif_enum_bitmap_mapping_list(
1118 tgif_enum_bitmap_mapping_value("0", 0),
1119 tgif_enum_bitmap_mapping_range("1-2", 1, 2),
1120 tgif_enum_bitmap_mapping_range("2-4", 2, 4),
1121 tgif_enum_bitmap_mapping_value("3", 3),
1122 tgif_enum_bitmap_mapping_value("30", 30),
1123 tgif_enum_bitmap_mapping_value("63", 63),
1124 tgif_enum_bitmap_mapping_range("158-160", 158, 160),
1125 tgif_enum_bitmap_mapping_value("159", 159),
1126 tgif_enum_bitmap_mapping_range("500-700", 500, 700),
1131 tgif_static_event(my_provider_event_enum_bitmap
, "myprovider", "myeventenumbitmap", TGIF_LOGLEVEL_DEBUG
,
1133 tgif_field_enum_bitmap("bit_0", &myenum_bitmap
, tgif_elem(tgif_type_u32(tgif_attr_list()))),
1134 tgif_field_enum_bitmap("bit_1", &myenum_bitmap
, tgif_elem(tgif_type_u32(tgif_attr_list()))),
1135 tgif_field_enum_bitmap("bit_2", &myenum_bitmap
, tgif_elem(tgif_type_u8(tgif_attr_list()))),
1136 tgif_field_enum_bitmap("bit_3", &myenum_bitmap
, tgif_elem(tgif_type_u8(tgif_attr_list()))),
1137 tgif_field_enum_bitmap("bit_30", &myenum_bitmap
, tgif_elem(tgif_type_u32(tgif_attr_list()))),
1138 tgif_field_enum_bitmap("bit_31", &myenum_bitmap
, tgif_elem(tgif_type_u32(tgif_attr_list()))),
1139 tgif_field_enum_bitmap("bit_63", &myenum_bitmap
, tgif_elem(tgif_type_u64(tgif_attr_list()))),
1140 tgif_field_enum_bitmap("bits_1+63", &myenum_bitmap
, tgif_elem(tgif_type_u64(tgif_attr_list()))),
1141 tgif_field_enum_bitmap("byte_bit_2", &myenum_bitmap
, tgif_elem(tgif_type_byte(tgif_attr_list()))),
1142 tgif_field_enum_bitmap("bit_159", &myenum_bitmap
,
1143 tgif_elem(tgif_type_array(tgif_elem(tgif_type_u32(tgif_attr_list())), 5, tgif_attr_list()))),
1144 tgif_field_enum_bitmap("bit_159", &myenum_bitmap
,
1145 tgif_elem(tgif_type_vla(tgif_elem(tgif_type_u32(tgif_attr_list())), tgif_attr_list()))),
1146 tgif_field_enum_bitmap("bit_2_be", &myenum_bitmap
, tgif_elem(tgif_type_u32_be(tgif_attr_list()))),
1147 tgif_field_enum_bitmap("bit_2_le", &myenum_bitmap
, tgif_elem(tgif_type_u32_le(tgif_attr_list()))),
1153 void test_enum_bitmap(void)
1155 tgif_event_cond(my_provider_event_enum_bitmap
) {
1156 tgif_arg_define_vec(myarray
,
1162 tgif_arg_u32(0x80000000), /* bit 159 */
1165 tgif_event_call(my_provider_event_enum_bitmap
,
1167 tgif_arg_u32(1U << 0),
1168 tgif_arg_u32(1U << 1),
1169 tgif_arg_u8(1U << 2),
1170 tgif_arg_u8(1U << 3),
1171 tgif_arg_u32(1U << 30),
1172 tgif_arg_u32(1U << 31),
1173 tgif_arg_u64(1ULL << 63),
1174 tgif_arg_u64((1ULL << 1) | (1ULL << 63)),
1175 tgif_arg_byte(1U << 2),
1176 tgif_arg_array(&myarray
),
1177 tgif_arg_vla(&myarray
),
1178 #if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN
1179 tgif_arg_u32(tgif_bswap_32(1U << 2)),
1180 tgif_arg_u32(1U << 2),
1182 tgif_arg_u32(1U << 2),
1183 tgif_arg_u32(tgif_bswap_32(1U << 2)),
1190 tgif_static_event_variadic(my_provider_event_blob
, "myprovider", "myeventblob", TGIF_LOGLEVEL_DEBUG
,
1192 tgif_field_byte("blobfield", tgif_attr_list()),
1193 tgif_field_array("arrayblob", tgif_elem(tgif_type_byte(tgif_attr_list())), 3, tgif_attr_list()),
1199 void test_blob(void)
1201 tgif_event_cond(my_provider_event_blob
) {
1202 tgif_arg_define_vec(myarray
, tgif_arg_list(tgif_arg_byte(1), tgif_arg_byte(2), tgif_arg_byte(3)));
1203 tgif_arg_dynamic_define_vec(myvla
,
1205 tgif_arg_dynamic_byte(0x22, tgif_attr_list()),
1206 tgif_arg_dynamic_byte(0x33, tgif_attr_list()),
1210 tgif_event_call_variadic(my_provider_event_blob
,
1212 tgif_arg_byte(0x55),
1213 tgif_arg_array(&myarray
),
1216 tgif_arg_dynamic_field("varblobfield",
1217 tgif_arg_dynamic_byte(0x55, tgif_attr_list())
1219 tgif_arg_dynamic_field("varblobvla", tgif_arg_dynamic_vla(&myvla
)),
1226 tgif_static_event_variadic(my_provider_event_format_string
,
1227 "myprovider", "myeventformatstring", TGIF_LOGLEVEL_DEBUG
,
1229 tgif_field_string("fmt", tgif_attr_list()),
1232 tgif_attr("lang.c.format_string", tgif_attr_bool(true)),
1237 void test_fmt_string(void)
1239 tgif_event_cond(my_provider_event_format_string
) {
1240 tgif_arg_dynamic_define_vec(args
,
1242 tgif_arg_dynamic_string("blah", tgif_attr_list()),
1243 tgif_arg_dynamic_s32(123, tgif_attr_list()),
1247 tgif_event_call_variadic(my_provider_event_format_string
,
1249 tgif_arg_string("This is a formatted string with str: %s int: %d"),
1252 tgif_arg_dynamic_field("arguments", tgif_arg_dynamic_vla(&args
)),
1259 tgif_static_event_variadic(my_provider_event_endian
, "myprovider", "myevent_endian", TGIF_LOGLEVEL_DEBUG
,
1261 tgif_field_u16_le("u16_le", tgif_attr_list()),
1262 tgif_field_u32_le("u32_le", tgif_attr_list()),
1263 tgif_field_u64_le("u64_le", tgif_attr_list()),
1264 tgif_field_s16_le("s16_le", tgif_attr_list()),
1265 tgif_field_s32_le("s32_le", tgif_attr_list()),
1266 tgif_field_s64_le("s64_le", tgif_attr_list()),
1267 tgif_field_u16_be("u16_be", tgif_attr_list()),
1268 tgif_field_u32_be("u32_be", tgif_attr_list()),
1269 tgif_field_u64_be("u64_be", tgif_attr_list()),
1270 tgif_field_s16_be("s16_be", tgif_attr_list()),
1271 tgif_field_s32_be("s32_be", tgif_attr_list()),
1272 tgif_field_s64_be("s64_be", tgif_attr_list()),
1278 void test_endian(void)
1280 tgif_event_variadic(my_provider_event_endian
,
1282 #if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN
1289 tgif_arg_u16(tgif_bswap_16(1)),
1290 tgif_arg_u32(tgif_bswap_32(1)),
1291 tgif_arg_u64(tgif_bswap_64(1)),
1292 tgif_arg_s16(tgif_bswap_16(1)),
1293 tgif_arg_s32(tgif_bswap_32(1)),
1294 tgif_arg_s64(tgif_bswap_64(1)),
1296 tgif_arg_u16(tgif_bswap_16(1)),
1297 tgif_arg_u32(tgif_bswap_32(1)),
1298 tgif_arg_u64(tgif_bswap_64(1)),
1299 tgif_arg_s16(tgif_bswap_16(1)),
1300 tgif_arg_s32(tgif_bswap_32(1)),
1301 tgif_arg_s64(tgif_bswap_64(1)),
1311 #if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN
1312 tgif_arg_dynamic_field("u16_le", tgif_arg_dynamic_u16_le(1, tgif_attr_list())),
1313 tgif_arg_dynamic_field("u32_le", tgif_arg_dynamic_u32_le(1, tgif_attr_list())),
1314 tgif_arg_dynamic_field("u64_le", tgif_arg_dynamic_u64_le(1, tgif_attr_list())),
1315 tgif_arg_dynamic_field("s16_le", tgif_arg_dynamic_s16_le(1, tgif_attr_list())),
1316 tgif_arg_dynamic_field("s32_le", tgif_arg_dynamic_s32_le(1, tgif_attr_list())),
1317 tgif_arg_dynamic_field("s64_le", tgif_arg_dynamic_s64_le(1, tgif_attr_list())),
1318 tgif_arg_dynamic_field("u16_be", tgif_arg_dynamic_u16_be(tgif_bswap_16(1), tgif_attr_list())),
1319 tgif_arg_dynamic_field("u32_be", tgif_arg_dynamic_u32_be(tgif_bswap_32(1), tgif_attr_list())),
1320 tgif_arg_dynamic_field("u64_be", tgif_arg_dynamic_u64_be(tgif_bswap_64(1), tgif_attr_list())),
1321 tgif_arg_dynamic_field("s16_be", tgif_arg_dynamic_s16_be(tgif_bswap_16(1), tgif_attr_list())),
1322 tgif_arg_dynamic_field("s32_be", tgif_arg_dynamic_s32_be(tgif_bswap_32(1), tgif_attr_list())),
1323 tgif_arg_dynamic_field("s64_be", tgif_arg_dynamic_s64_be(tgif_bswap_64(1), tgif_attr_list())),
1325 tgif_arg_dynamic_field("u16_le", tgif_arg_dynamic_u16_le(tgif_bswap_16(1), tgif_attr_list())),
1326 tgif_arg_dynamic_field("u32_le", tgif_arg_dynamic_u32_le(tgif_bswap_32(1), tgif_attr_list())),
1327 tgif_arg_dynamic_field("u64_le", tgif_arg_dynamic_u64_le(tgif_bswap_64(1), tgif_attr_list())),
1328 tgif_arg_dynamic_field("s16_le", tgif_arg_dynamic_s16_le(tgif_bswap_16(1), tgif_attr_list())),
1329 tgif_arg_dynamic_field("s32_le", tgif_arg_dynamic_s32_le(tgif_bswap_32(1), tgif_attr_list())),
1330 tgif_arg_dynamic_field("s64_le", tgif_arg_dynamic_s64_le(tgif_bswap_64(1), tgif_attr_list())),
1331 tgif_arg_dynamic_field("u16_be", tgif_arg_dynamic_u16_be(1, tgif_attr_list())),
1332 tgif_arg_dynamic_field("u32_be", tgif_arg_dynamic_u32_be(1, tgif_attr_list())),
1333 tgif_arg_dynamic_field("u64_be", tgif_arg_dynamic_u64_be(1, tgif_attr_list())),
1334 tgif_arg_dynamic_field("s16_be", tgif_arg_dynamic_s16_be(1, tgif_attr_list())),
1335 tgif_arg_dynamic_field("s32_be", tgif_arg_dynamic_s32_be(1, tgif_attr_list())),
1336 tgif_arg_dynamic_field("s64_be", tgif_arg_dynamic_s64_be(1, tgif_attr_list())),
1343 tgif_static_event(my_provider_event_base
, "myprovider", "myevent_base", TGIF_LOGLEVEL_DEBUG
,
1345 tgif_field_u8("u8base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))),
1346 tgif_field_u8("u8base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))),
1347 tgif_field_u8("u8base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1348 tgif_field_u8("u8base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1349 tgif_field_u16("u16base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))),
1350 tgif_field_u16("u16base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))),
1351 tgif_field_u16("u16base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1352 tgif_field_u16("u16base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1353 tgif_field_u32("u32base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))),
1354 tgif_field_u32("u32base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))),
1355 tgif_field_u32("u32base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1356 tgif_field_u32("u32base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1357 tgif_field_u64("u64base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))),
1358 tgif_field_u64("u64base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))),
1359 tgif_field_u64("u64base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1360 tgif_field_u64("u64base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1361 tgif_field_s8("s8base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))),
1362 tgif_field_s8("s8base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))),
1363 tgif_field_s8("s8base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1364 tgif_field_s8("s8base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1365 tgif_field_s16("s16base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))),
1366 tgif_field_s16("s16base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))),
1367 tgif_field_s16("s16base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1368 tgif_field_s16("s16base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1369 tgif_field_s32("s32base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))),
1370 tgif_field_s32("s32base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))),
1371 tgif_field_s32("s32base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1372 tgif_field_s32("s32base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1373 tgif_field_s64("s64base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))),
1374 tgif_field_s64("s64base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))),
1375 tgif_field_s64("s64base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1376 tgif_field_s64("s64base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1382 void test_base(void)
1384 tgif_event(my_provider_event_base
,
1437 static tgif_define_struct(mystructgatherdef
,
1439 tgif_field_gather_unsigned_integer("a", offsetof(struct test
, a
),
1440 tgif_struct_field_sizeof(struct test
, a
), 0, 0,
1441 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1442 tgif_field_gather_signed_integer("d", offsetof(struct test
, d
),
1443 tgif_struct_field_sizeof(struct test
, d
), 0, 0,
1444 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1445 tgif_field_gather_unsigned_integer("e", offsetof(struct test
, e
),
1446 tgif_struct_field_sizeof(struct test
, e
), 8, 4,
1447 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1448 tgif_field_gather_signed_integer("f", offsetof(struct test
, f
),
1449 tgif_struct_field_sizeof(struct test
, f
), 1, 4,
1450 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1451 tgif_field_gather_signed_integer("g", offsetof(struct test
, g
),
1452 tgif_struct_field_sizeof(struct test
, g
), 11, 4,
1453 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1454 tgif_field_gather_signed_integer("h", offsetof(struct test
, h
),
1455 tgif_struct_field_sizeof(struct test
, h
), 1, 31,
1456 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1457 tgif_field_gather_signed_integer("i", offsetof(struct test
, i
),
1458 tgif_struct_field_sizeof(struct test
, i
), 33, 20,
1459 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1460 tgif_field_gather_signed_integer("j", offsetof(struct test
, j
),
1461 tgif_struct_field_sizeof(struct test
, j
), 63, 1,
1462 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1463 tgif_field_gather_signed_integer("k", offsetof(struct test
, k
),
1464 tgif_struct_field_sizeof(struct test
, k
), 1, 63,
1465 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1466 tgif_field_gather_unsigned_integer_le("test", offsetof(struct test
, test
),
1467 tgif_struct_field_sizeof(struct test
, test
), 0, 64,
1468 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1469 tgif_field_gather_unsigned_integer_le("test_le", offsetof(struct test
, test
),
1470 tgif_struct_field_sizeof(struct test
, test
), 0, 64,
1471 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1472 tgif_field_gather_unsigned_integer_be("test_be", offsetof(struct test
, test
),
1473 tgif_struct_field_sizeof(struct test
, test
), 0, 64,
1474 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))),
1479 tgif_static_event(my_provider_event_structgather
, "myprovider", "myeventstructgather", TGIF_LOGLEVEL_DEBUG
,
1481 tgif_field_gather_struct("structgather", &mystructgatherdef
, 0, sizeof(struct test
),
1482 TGIF_TYPE_GATHER_ACCESS_DIRECT
),
1483 tgif_field_gather_signed_integer("intgather", 0, sizeof(int32_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
,
1484 tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))),
1486 tgif_field_gather_float("f32", 0, sizeof(_Float32
), TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1493 void test_struct_gather(void)
1495 tgif_event_cond(my_provider_event_structgather
) {
1496 struct test mystruct
= {
1514 tgif_event_call(my_provider_event_structgather
,
1516 tgif_arg_gather_struct(&mystruct
),
1517 tgif_arg_gather_integer(&val
),
1519 tgif_arg_gather_float(&f32
),
1532 struct testnest2
*nest
;
1537 struct testnest1
*nest
;
1540 static tgif_define_struct(mystructgathernest2
,
1542 tgif_field_gather_unsigned_integer("c", offsetof(struct testnest2
, c
),
1543 tgif_struct_field_sizeof(struct testnest2
, c
), 0, 0,
1544 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1549 static tgif_define_struct(mystructgathernest1
,
1551 tgif_field_gather_unsigned_integer("b", offsetof(struct testnest1
, b
),
1552 tgif_struct_field_sizeof(struct testnest1
, b
), 0, 0,
1553 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1554 tgif_field_gather_struct("nest2", &mystructgathernest2
,
1555 offsetof(struct testnest1
, nest
), sizeof(struct testnest2
),
1556 TGIF_TYPE_GATHER_ACCESS_POINTER
),
1561 static tgif_define_struct(mystructgathernest0
,
1563 tgif_field_gather_unsigned_integer("a", offsetof(struct testnest0
, a
),
1564 tgif_struct_field_sizeof(struct testnest0
, a
), 0, 0,
1565 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1566 tgif_field_gather_struct("nest1", &mystructgathernest1
,
1567 offsetof(struct testnest0
, nest
), sizeof(struct testnest1
),
1568 TGIF_TYPE_GATHER_ACCESS_POINTER
),
1573 tgif_static_event(my_provider_event_structgather_nest
,
1574 "myprovider", "myeventstructgathernest", TGIF_LOGLEVEL_DEBUG
,
1576 tgif_field_gather_struct("nest0", &mystructgathernest0
, 0,
1577 sizeof(struct testnest0
), TGIF_TYPE_GATHER_ACCESS_DIRECT
),
1583 void test_struct_gather_nest_ptr(void)
1585 tgif_event_cond(my_provider_event_structgather_nest
) {
1586 struct testnest2 mystruct2
= {
1589 struct testnest1 mystruct1
= {
1593 struct testnest0 mystruct
= {
1597 tgif_event_call(my_provider_event_structgather_nest
,
1599 tgif_arg_gather_struct(&mystruct
),
1620 static tgif_define_struct(mystructgatherfloat
,
1623 tgif_field_gather_float("f16", offsetof(struct testfloat
, f16
), tgif_struct_field_sizeof(struct testfloat
, f16
),
1624 TGIF_TYPE_GATHER_ACCESS_DIRECT
,
1628 tgif_field_gather_float("f32", offsetof(struct testfloat
, f32
), tgif_struct_field_sizeof(struct testfloat
, f32
),
1629 TGIF_TYPE_GATHER_ACCESS_DIRECT
,
1633 tgif_field_gather_float("f64", offsetof(struct testfloat
, f64
), tgif_struct_field_sizeof(struct testfloat
, f64
),
1634 TGIF_TYPE_GATHER_ACCESS_DIRECT
,
1638 tgif_field_gather_float("f128", offsetof(struct testfloat
, f128
), tgif_struct_field_sizeof(struct testfloat
, f128
),
1639 TGIF_TYPE_GATHER_ACCESS_DIRECT
,
1646 tgif_static_event(my_provider_event_structgatherfloat
,
1647 "myprovider", "myeventstructgatherfloat", TGIF_LOGLEVEL_DEBUG
,
1649 tgif_field_gather_struct("structgatherfloat", &mystructgatherfloat
, 0,
1650 sizeof(struct testfloat
), TGIF_TYPE_GATHER_ACCESS_DIRECT
),
1656 void test_struct_gather_float(void)
1658 tgif_event_cond(my_provider_event_structgatherfloat
) {
1659 struct testfloat mystruct
= {
1673 tgif_event_call(my_provider_event_structgatherfloat
,
1675 tgif_arg_gather_struct(&mystruct
),
1681 uint32_t mygatherarray
[] = { 1, 2, 3, 4, 5 };
1683 uint16_t mygatherarray2
[] = { 6, 7, 8, 9 };
1690 static tgif_define_struct(mystructgatherarray
,
1692 tgif_field_gather_array("array",
1693 tgif_elem(tgif_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
1694 TGIF_ARRAY_SIZE(mygatherarray
),
1695 offsetof(struct testarray
, ptr
),
1696 TGIF_TYPE_GATHER_ACCESS_POINTER
,
1702 tgif_static_event(my_provider_event_structgatherarray
,
1703 "myprovider", "myeventstructgatherarray", TGIF_LOGLEVEL_DEBUG
,
1705 tgif_field_gather_struct("structgatherarray", &mystructgatherarray
, 0,
1706 sizeof(struct testarray
), TGIF_TYPE_GATHER_ACCESS_DIRECT
),
1707 tgif_field_gather_array("array2",
1708 tgif_elem(tgif_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
1709 TGIF_ARRAY_SIZE(mygatherarray2
), 0,
1710 TGIF_TYPE_GATHER_ACCESS_DIRECT
,
1718 void test_array_gather(void)
1720 tgif_event_cond(my_provider_event_structgatherarray
) {
1721 struct testarray mystruct
= {
1723 .ptr
= mygatherarray
,
1725 tgif_event_call(my_provider_event_structgatherarray
,
1727 tgif_arg_gather_struct(&mystruct
),
1728 tgif_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 tgif_define_struct(mystructgatherstructnest1
,
1748 tgif_field_gather_signed_integer("b", offsetof(struct testgatherstructnest1
, b
),
1749 tgif_struct_field_sizeof(struct testgatherstructnest1
, b
), 0, 0,
1750 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1751 tgif_field_gather_array("c",
1753 tgif_type_gather_signed_integer(0, sizeof(uint32_t), 0, 0,
1754 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1756 TESTSGNESTARRAY_LEN
,
1757 offsetof(struct testgatherstructnest1
, c
),
1758 TGIF_TYPE_GATHER_ACCESS_DIRECT
,
1764 static tgif_define_struct(mystructgatherstructnest0
,
1766 tgif_field_gather_signed_integer("a", offsetof(struct testgatherstructnest0
, a
),
1767 tgif_struct_field_sizeof(struct testgatherstructnest0
, a
), 0, 0,
1768 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1769 tgif_field_gather_struct("structnest0", &mystructgatherstructnest1
,
1770 offsetof(struct testgatherstructnest0
, nest
),
1771 sizeof(struct testgatherstructnest1
),
1772 TGIF_TYPE_GATHER_ACCESS_DIRECT
),
1773 tgif_field_gather_array("nestarray",
1775 tgif_type_gather_struct(&mystructgatherstructnest1
,
1777 sizeof(struct testgatherstructnest1
),
1778 TGIF_TYPE_GATHER_ACCESS_DIRECT
),
1781 offsetof(struct testgatherstructnest0
, nestarray
),
1782 TGIF_TYPE_GATHER_ACCESS_DIRECT
,
1788 tgif_static_event(my_provider_event_gatherstructnest
,
1789 "myprovider", "myeventgatherstructnest", TGIF_LOGLEVEL_DEBUG
,
1791 tgif_field_gather_struct("structgather", &mystructgatherstructnest0
, 0,
1792 sizeof(struct testgatherstructnest0
), TGIF_TYPE_GATHER_ACCESS_DIRECT
),
1798 void test_gather_structnest(void)
1800 tgif_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 tgif_event_call(my_provider_event_gatherstructnest
,
1820 tgif_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 tgif_define_struct(mystructgathervla
,
1837 tgif_field_gather_signed_integer("a", offsetof(struct testgathervla
, a
),
1838 tgif_struct_field_sizeof(struct testgathervla
, a
), 0, 0,
1839 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()
1841 tgif_field_gather_vla("nestvla",
1842 tgif_elem(tgif_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
1843 offsetof(struct testgathervla
, p
),
1844 TGIF_TYPE_GATHER_ACCESS_POINTER
,
1845 tgif_length(tgif_type_gather_unsigned_integer(offsetof(struct testgathervla
, len
),
1846 sizeof(uint16_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
1853 tgif_static_event(my_provider_event_gathervla
,
1854 "myprovider", "myeventgathervla", TGIF_LOGLEVEL_DEBUG
,
1856 tgif_field_gather_struct("structgathervla", &mystructgathervla
, 0,
1857 sizeof(struct testgathervla
), TGIF_TYPE_GATHER_ACCESS_DIRECT
),
1858 tgif_field_gather_vla("vla",
1859 tgif_elem(tgif_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
1860 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
,
1861 tgif_length(tgif_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
1869 void test_gather_vla(void)
1871 tgif_event_cond(my_provider_event_gathervla
) {
1872 struct testgathervla mystruct
= {
1874 .len
= TGIF_ARRAY_SIZE(gathervla
),
1877 uint16_t vla2_len
= 5;
1878 tgif_event_call(my_provider_event_gathervla
,
1880 tgif_arg_gather_struct(&mystruct
),
1881 tgif_arg_gather_vla(gathervla2
, &vla2_len
),
1887 struct testgathervlaflex
{
1889 uint32_t otherfield
;
1893 static tgif_define_struct(mystructgathervlaflex
,
1895 tgif_field_gather_vla("vlaflex",
1896 tgif_elem(tgif_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
1897 offsetof(struct testgathervlaflex
, array
),
1898 TGIF_TYPE_GATHER_ACCESS_DIRECT
,
1899 tgif_length(tgif_type_gather_unsigned_integer(offsetof(struct testgathervlaflex
, len
),
1900 tgif_struct_field_sizeof(struct testgathervlaflex
, len
), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
1907 tgif_static_event(my_provider_event_gathervlaflex
,
1908 "myprovider", "myeventgathervlaflex", TGIF_LOGLEVEL_DEBUG
,
1910 tgif_field_gather_struct("structgathervlaflex", &mystructgathervlaflex
, 0,
1911 sizeof(struct testgathervlaflex
), TGIF_TYPE_GATHER_ACCESS_DIRECT
),
1916 #define VLAFLEXLEN 6
1918 void test_gather_vla_flex(void)
1920 tgif_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 tgif_event_call(my_provider_event_gathervlaflex
,
1934 tgif_arg_gather_struct(mystruct
),
1941 tgif_static_event(my_provider_event_gatherbyte
,
1942 "myprovider", "myeventgatherbyte", TGIF_LOGLEVEL_DEBUG
,
1944 tgif_field_gather_byte("byte", 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1945 tgif_field_gather_array("array",
1946 tgif_elem(tgif_type_gather_byte(0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
1947 3, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()
1954 void test_gather_byte(void)
1956 tgif_event_cond(my_provider_event_gatherbyte
) {
1958 uint8_t array
[3] = { 0x1, 0x2, 0x3 };
1960 tgif_event_call(my_provider_event_gatherbyte
,
1962 tgif_arg_gather_byte(&v
),
1963 tgif_arg_gather_array(array
),
1969 #define ARRAYBOOLLEN 4
1970 static bool arraybool
[ARRAYBOOLLEN
] = { false, true, false, true };
1972 tgif_static_event(my_provider_event_gatherbool
,
1973 "myprovider", "myeventgatherbool", TGIF_LOGLEVEL_DEBUG
,
1975 tgif_field_gather_bool("v1_true", 0, sizeof(bool), 0, 0,
1976 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1977 tgif_field_gather_bool("v2_false", 0, sizeof(bool), 0, 0,
1978 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1979 tgif_field_gather_bool("v3_true", 0, sizeof(uint16_t), 1, 1,
1980 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1981 tgif_field_gather_bool("v4_false", 0, sizeof(uint16_t), 1, 1,
1982 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
1983 tgif_field_gather_array("arraybool",
1984 tgif_elem(tgif_type_gather_bool(0, sizeof(bool), 0, 0,
1985 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
1986 ARRAYBOOLLEN
, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()
1993 void test_gather_bool(void)
1995 tgif_event_cond(my_provider_event_structgatherarray
) {
1998 uint16_t v3
= 1U << 1;
1999 uint16_t v4
= 1U << 2;
2001 tgif_event_call(my_provider_event_gatherbool
,
2003 tgif_arg_gather_bool(&v1
),
2004 tgif_arg_gather_bool(&v2
),
2005 tgif_arg_gather_bool(&v3
),
2006 tgif_arg_gather_bool(&v4
),
2007 tgif_arg_gather_array(arraybool
),
2013 tgif_static_event(my_provider_event_gatherpointer
,
2014 "myprovider", "myeventgatherpointer", TGIF_LOGLEVEL_DEBUG
,
2016 tgif_field_gather_pointer("ptr", 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
2017 tgif_field_gather_array("array",
2018 tgif_elem(tgif_type_gather_pointer(0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
2019 3, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()
2026 void test_gather_pointer(void)
2028 tgif_event_cond(my_provider_event_structgatherarray
) {
2029 void *v
= (void *)0x44;
2030 void *array
[3] = { (void *)0x1, (void *)0x2, (void *)0x3 };
2032 tgif_event_call(my_provider_event_gatherpointer
,
2034 tgif_arg_gather_pointer(&v
),
2035 tgif_arg_gather_array(array
),
2041 static tgif_define_enum(myenumgather
,
2042 tgif_enum_mapping_list(
2043 tgif_enum_mapping_range("one-ten", 1, 10),
2044 tgif_enum_mapping_range("100-200", 100, 200),
2045 tgif_enum_mapping_value("200", 200),
2046 tgif_enum_mapping_value("300", 300),
2051 tgif_static_event(my_provider_event_enum_gather
, "myprovider", "myeventenumgather", TGIF_LOGLEVEL_DEBUG
,
2053 tgif_field_gather_enum("5", &myenumgather
,
2055 tgif_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0,
2056 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())
2059 tgif_field_gather_enum("400", &myenumgather
,
2061 tgif_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0,
2062 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())
2065 tgif_field_gather_enum("200", &myenumgather
,
2067 tgif_type_gather_unsigned_integer(0, sizeof(uint8_t), 0, 0,
2068 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())
2071 tgif_field_gather_enum("-100", &myenumgather
,
2073 tgif_type_gather_signed_integer(0, sizeof(int8_t), 0, 0,
2074 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())
2077 tgif_field_gather_enum("6_be", &myenumgather
,
2079 tgif_type_gather_unsigned_integer_be(0, sizeof(uint32_t), 0, 0,
2080 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())
2083 tgif_field_gather_enum("6_le", &myenumgather
,
2085 tgif_type_gather_unsigned_integer_le(0, sizeof(uint32_t), 0, 0,
2086 TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())
2094 void test_gather_enum(void)
2100 #if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN
2101 uint32_t v5
= tgif_bswap_32(6);
2105 uint32_t v6
= tgif_bswap_32(6);
2108 tgif_event(my_provider_event_enum_gather
,
2110 tgif_arg_gather_integer(&v1
),
2111 tgif_arg_gather_integer(&v2
),
2112 tgif_arg_gather_integer(&v3
),
2113 tgif_arg_gather_integer(&v4
),
2114 tgif_arg_gather_integer(&v5
),
2115 tgif_arg_gather_integer(&v6
),
2120 tgif_static_event(my_provider_event_gatherstring
,
2121 "myprovider", "myeventgatherstring", TGIF_LOGLEVEL_DEBUG
,
2123 tgif_field_gather_string("string", 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()),
2124 tgif_field_gather_array("arrayptr",
2125 tgif_elem(tgif_type_gather_string(0, TGIF_TYPE_GATHER_ACCESS_POINTER
, tgif_attr_list())),
2126 3, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()
2128 tgif_field_gather_array("array",
2129 tgif_elem(tgif_type_gather_string(0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list())),
2130 3, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_attr_list()
2137 void test_gather_string(void)
2139 tgif_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 tgif_event_call(my_provider_event_gatherstring
,
2150 tgif_arg_gather_string(str1
),
2151 tgif_arg_gather_array(ptrarray
),
2152 tgif_arg_gather_array(flatarray
),
2158 tgif_static_event(my_provider_event_str_utf
, "myprovider", "myevent_str_utf", TGIF_LOGLEVEL_DEBUG
,
2160 tgif_field_string("utf8", tgif_attr_list()),
2161 tgif_field_string32("utf32", tgif_attr_list()),
2162 tgif_field_string16("utf16", tgif_attr_list()),
2163 tgif_field_string32_le("utf32_le", tgif_attr_list()),
2164 tgif_field_string16_le("utf16_le", tgif_attr_list()),
2165 tgif_field_string32_be("utf32_be", tgif_attr_list()),
2166 tgif_field_string16_be("utf16_be", tgif_attr_list()),
2167 tgif_field_dynamic("dynamic_utf32"),
2168 tgif_field_gather_string32("gather_utf32", 0, TGIF_TYPE_GATHER_ACCESS_DIRECT
, tgif_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 TGIF_BYTE_ORDER == TGIF_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
[] = { tgif_bswap_32(0x000000ae), tgif_bswap_32('a'), tgif_bswap_32('b'), tgif_bswap_32('c'), 0 };
2189 uint16_t str16_be
[] = { tgif_bswap_16(0x00ae), tgif_bswap_16('a'), tgif_bswap_16('b'), tgif_bswap_16('c'), 0 };
2191 uint32_t str32_le
[] = { tgif_bswap_32(0x000000ae), tgif_bswap_32('a'), tgif_bswap_32('b'), tgif_bswap_32('c'), 0 };
2192 uint16_t str16_le
[] = { tgif_bswap_16(0x00ae), tgif_bswap_16('a'), tgif_bswap_16('b'), tgif_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 tgif_event(my_provider_event_str_utf
,
2199 tgif_arg_string(str8
),
2200 tgif_arg_string32(str32
),
2201 tgif_arg_string16(str16
),
2202 tgif_arg_string32(str32_le
),
2203 tgif_arg_string16(str16_le
),
2204 tgif_arg_string32(str32_be
),
2205 tgif_arg_string16(str16_be
),
2206 tgif_arg_dynamic_string32(str32
, tgif_attr_list()),
2207 tgif_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();