Commit | Line | Data |
---|---|---|
8b9d5b5e | 1 | |
a030d084 | 2 | typealias integer { size = 32; align = 32; signed = true; } := int; |
152a5771 | 3 | typealias integer { size = 32; align = 32; signed = false; } := uint; |
a030d084 MD |
4 | typealias integer { size = 64; align = 64; signed = true; } := long; |
5 | typealias integer { size = 64; align = 64; } := unsigned long; | |
5039b4cc | 6 | |
0fbb34a5 | 7 | enum name1 : int { |
8b9d5b5e MD |
8 | ZERO, |
9 | ONE, | |
10 | TWO, | |
11 | TEN = 10, | |
12 | ELEVEN, | |
13 | }; | |
14 | ||
0fbb34a5 | 15 | enum name2 : long { ONE, TWO }; |
8b9d5b5e | 16 | |
0fbb34a5 | 17 | enum name3 : unsigned long { ONE, TWO }; |
8b9d5b5e | 18 | |
0fbb34a5 | 19 | enum name4 : unsigned long { |
8b9d5b5e MD |
20 | string = 1 ... 2, |
21 | "other string" = 3...4, | |
22 | yet_another_string, /* will be assigned to end_value2 + 1 */ | |
23 | "some other string" = 10, | |
24 | }; | |
25 | ||
0fbb34a5 | 26 | enum name5 : long { "int" = 1, }; |
8b9d5b5e | 27 | |
6743829a MD |
28 | enum name6 { "int" = 1, }; |
29 | ||
8b9d5b5e MD |
30 | typealias floating_point { |
31 | exp_dig = 8; /* sizeof(float) * CHAR_BIT - FLT_MANT_DIG */ | |
32 | mant_dig = 24; /* FLT_MANT_DIG */ | |
33 | byte_order = native; | |
a030d084 | 34 | } := float; |
8b9d5b5e MD |
35 | |
36 | typealias integer { | |
37 | size = 32; | |
38 | align = 32; | |
5039b4cc | 39 | signed = false; |
a030d084 | 40 | } := struct page *; |
8b9d5b5e | 41 | |
f0751d06 MD |
42 | struct event_packet_header { |
43 | typealias integer { size = 32; align = 32; signed = false; } := uint32_t; | |
44 | typealias integer { size = 8; align = 8; signed = false; } := uint8_t; | |
45 | ||
46 | uint32_t magic; | |
b4c19c1e | 47 | uint8_t uuid[16]; |
f0751d06 MD |
48 | uint32_t stream_id; |
49 | }; | |
50 | ||
5039b4cc MD |
51 | trace { |
52 | major = 66; | |
53 | minor = 2; | |
98df1c9f | 54 | byte_order = le; |
5039b4cc | 55 | uuid = "1123fcea-706e-11e0-a38b-f3c28a683a3d"; |
f0751d06 | 56 | packet.header := struct event_packet_header; |
5039b4cc MD |
57 | }; |
58 | ||
8b9d5b5e | 59 | stream { |
a030d084 MD |
60 | typealias integer { size = 64; align = 64; signed = false; } := uint64_t; |
61 | typealias integer { size = 16; align = 16; signed = false; } := uint16_t; | |
62 | typealias integer { size = 32; align = 32; signed = true; } := int; | |
8b9d5b5e MD |
63 | typedef int pid_t; |
64 | ||
65 | id = 5; | |
66 | /* Type 1 - Few event IDs; Type 2 - Many event IDs. See section 6.2. */ | |
67 | event.header := struct { uint64_t timestamp; uint16_t id; }; | |
68 | event.context := struct { pid_t pid; }; | |
69 | }; | |
70 | ||
71 | struct example { | |
5039b4cc MD |
72 | /* TODO gcc bitfields not supported yet. */ |
73 | /* short a:12; | |
74 | short b:5; */ | |
8b9d5b5e MD |
75 | }; |
76 | ||
77 | struct name { | |
a030d084 MD |
78 | typealias integer { size = 64; align = 64; signed = false; } := uint64_t; |
79 | typealias integer { size = 32; align = 32; signed = false; } := uint32_t; | |
80 | typealias integer { size = 32; align = 32; signed = true; } := int32_t; | |
81 | typealias integer { size = 2; align = 8; signed = false; } := uint2_t; | |
82 | typealias integer { size = 16; align = 16; signed = true; } := short; | |
83 | typealias uint32_t := unsigned int; | |
8b9d5b5e | 84 | |
0fbb34a5 | 85 | enum : uint2_t { a, b, c, d } choice; |
8b9d5b5e MD |
86 | /* Unrelated fields can be added between the variant and its tag */ |
87 | int32_t somevalue; | |
88 | variant <choice> { | |
89 | uint32_t a; | |
90 | uint64_t b; | |
91 | short c; | |
92 | struct { | |
93 | unsigned int field1; | |
94 | uint64_t field2; | |
95 | } d; | |
96 | } s; | |
97 | }; | |
98 | ||
99 | typealias integer { | |
100 | size = 32; | |
101 | signed = false; | |
102 | align = 32; | |
a030d084 | 103 | } := uint32_t; |
8b9d5b5e | 104 | |
a030d084 | 105 | typealias string { encoding = UTF8; } := test; |
8b9d5b5e | 106 | |
8b9d5b5e | 107 | struct event_packet_context { |
a030d084 MD |
108 | typealias integer { size = 64; align = 64; signed = false; } := uint64_t; |
109 | typealias integer { size = 32; align = 32; signed = false; } := uint32_t; | |
110 | typealias integer { size = 16; align = 16; signed = false; } := uint16_t; | |
111 | typealias integer { size = 8; align = 8; signed = false; } := uint8_t; | |
8b9d5b5e MD |
112 | |
113 | uint64_t timestamp_begin; | |
114 | uint64_t timestamp_end; | |
115 | uint32_t checksum; | |
116 | uint32_t stream_packet_count; | |
117 | uint32_t events_discarded; | |
118 | uint32_t cpu_id; | |
119 | uint16_t content_size; | |
120 | uint16_t packet_size; | |
121 | uint8_t stream_packet_count_bits; /* Significant counter bits */ | |
122 | uint8_t compression_scheme; | |
123 | uint8_t encryption_scheme; | |
124 | uint8_t checksum_scheme; | |
125 | }; | |
126 | ||
127 | struct event_header_1 { | |
a030d084 MD |
128 | typealias integer { size = 64; align = 64; signed = false; } := uint64_t; |
129 | typealias integer { size = 32; align = 32; signed = false; } := uint32_t; | |
130 | typealias integer { size = 5; align = 1; signed = false; } := uint5_t; | |
131 | typealias integer { size = 27; align = 1; signed = false; } := uint27_t; | |
8b9d5b5e MD |
132 | |
133 | /* | |
134 | * id: range: 0 - 30. | |
135 | * id 31 is reserved to indicate an extended header. | |
136 | */ | |
0fbb34a5 | 137 | enum : uint5_t { compact = 0 ... 30, extended = 31 } id; |
8b9d5b5e MD |
138 | variant <id> { |
139 | struct { | |
140 | uint27_t timestamp; | |
141 | } compact; | |
142 | struct { | |
143 | uint32_t id; /* 32-bit event IDs */ | |
144 | uint64_t timestamp; /* 64-bit timestamps */ | |
145 | } extended; | |
146 | } v; | |
147 | }; | |
148 | ||
149 | struct event_header_2 { | |
a030d084 MD |
150 | typealias integer { size = 64; align = 64; signed = false; } := uint64_t; |
151 | typealias integer { size = 32; align = 32; signed = false; } := uint32_t; | |
152 | typealias integer { size = 16; align = 16; signed = false; } := uint16_t; | |
8b9d5b5e MD |
153 | |
154 | /* | |
155 | * id: range: 0 - 65534. | |
156 | * id 65535 is reserved to indicate an extended header. | |
157 | */ | |
0fbb34a5 | 158 | enum : uint16_t { compact = 0 ... 65534, extended = 65535 } id; |
8b9d5b5e MD |
159 | variant <id> { |
160 | struct { | |
161 | uint32_t timestamp; | |
162 | } compact; | |
163 | struct { | |
164 | uint32_t id; /* 32-bit event IDs */ | |
165 | uint64_t timestamp; /* 64-bit timestamps */ | |
166 | } extended; | |
167 | } v; | |
168 | }; | |
169 | ||
64b829c0 MD |
170 | typedef int rootscopetest; |
171 | ||
5039b4cc MD |
172 | /* parser level only: event { a.b.c.d.e = f.g.h->i->j; }; */ |
173 | ||
174 | event { | |
175 | name = test_event; | |
176 | id = 0; | |
177 | stream_id = 5; | |
178 | context := struct {}; | |
98df1c9f | 179 | fields := struct {}; |
5039b4cc | 180 | }; |
48a01768 | 181 | |
a030d084 | 182 | typealias integer { size = 32; align = 32; signed = false; } := unsigned long long *; |
152a5771 MD |
183 | |
184 | variant vardecl { | |
185 | int a; | |
186 | int b; | |
187 | }; | |
188 | ||
189 | event { | |
98df1c9f MD |
190 | typealias integer { size = 8; align = 8; signed = true; } := char; |
191 | typealias integer { size = 32; align = 32; signed = false; } := unsigned int; | |
192 | ||
152a5771 MD |
193 | name = test_event2; |
194 | id = 1; | |
195 | stream_id = 5; | |
98df1c9f | 196 | fields := struct { |
152a5771 MD |
197 | enum : char { a = 0, b = 1, } tag; |
198 | variant vardecl <tag> myvariant; | |
98df1c9f MD |
199 | unsigned int seqlen; |
200 | int myseq[seqlen]; | |
152a5771 MD |
201 | }; |
202 | }; | |
203 | ||
204 | typedef int myarray[10]; |