Commit | Line | Data |
---|---|---|
8424ff79 MD |
1 | #include <side/trace.h> |
2 | ||
3 | static | |
4 | const char *mystr[] = { | |
5 | "abc", | |
6 | "def", | |
7 | "ghi", | |
8 | }; | |
9 | ||
10 | static | |
11 | int myint[] = { | |
12 | 0, 1, 2, 3, 4, 5, | |
13 | }; | |
14 | ||
15 | side_static_event(my_provider_event_dump1, "myprovider", "myevent_dump1", SIDE_LOGLEVEL_DEBUG, | |
16 | side_field_list(side_field_string("mystatestring")) | |
17 | ); | |
18 | ||
19 | side_static_event(my_provider_event_dump2, "myprovider", "myevent_dump2", SIDE_LOGLEVEL_DEBUG, | |
20 | side_field_list(side_field_s32("mystateint")) | |
21 | ); | |
22 | ||
23 | side_static_event(my_provider_event, "myprovider", "myevent", SIDE_LOGLEVEL_DEBUG, | |
24 | side_field_list(side_field_s32("myfield")) | |
25 | ); | |
26 | ||
27 | static struct side_statedump_request_handle *statedump_request_handle; | |
28 | ||
29 | static | |
3da13b2c | 30 | void statedump_cb(void *statedump_request_key) |
8424ff79 MD |
31 | { |
32 | size_t i; | |
33 | ||
34 | printf("Executing application state dump callback\n"); | |
35 | side_event_cond(my_provider_event_dump1) { | |
36 | for (i = 0; i < SIDE_ARRAY_SIZE(mystr); i++) { | |
37 | side_statedump_event_call(my_provider_event_dump1, | |
3da13b2c | 38 | statedump_request_key, |
8424ff79 MD |
39 | side_arg_list(side_arg_string(mystr[i]))); |
40 | } | |
41 | } | |
42 | side_event_cond(my_provider_event_dump2) { | |
43 | for (i = 0; i < SIDE_ARRAY_SIZE(myint); i++) { | |
44 | side_statedump_event_call(my_provider_event_dump2, | |
3da13b2c | 45 | statedump_request_key, |
8424ff79 MD |
46 | side_arg_list(side_arg_s32(myint[i]))); |
47 | } | |
48 | } | |
49 | } | |
50 | ||
51 | static void my_constructor(void) | |
52 | __attribute((constructor)); | |
53 | static void my_constructor(void) | |
54 | { | |
55 | side_event_description_ptr_init(); | |
bffe9ae3 MD |
56 | statedump_request_handle = side_statedump_request_notification_register("mystatedump", |
57 | statedump_cb, SIDE_STATEDUMP_MODE_AGENT_THREAD); | |
8424ff79 MD |
58 | if (!statedump_request_handle) |
59 | abort(); | |
60 | } | |
61 | ||
62 | static void my_destructor(void) | |
63 | __attribute((destructor)); | |
64 | static void my_destructor(void) | |
65 | { | |
66 | side_statedump_request_notification_unregister(statedump_request_handle); | |
67 | side_event_description_ptr_exit(); | |
68 | } | |
69 | ||
70 | int main() | |
71 | { | |
72 | side_event(my_provider_event, side_arg_list(side_arg_s32(42))); | |
73 | return 0; | |
74 | } |