Commit | Line | Data |
---|---|---|
016a4d97 PP |
1 | = What's new in barectf{nbsp}3? |
2 | ||
3 | barectf{nbsp}3 is a major update of the project. | |
4 | ||
c24e3f21 | 5 | This page presents the main, user-visible changes. |
016a4d97 | 6 | |
c24e3f21 | 7 | == Support for user-defined static and dynamic array field types |
016a4d97 | 8 | |
c24e3f21 PP |
9 | You can now use your own xref:yaml:static-array-ft-obj.adoc[static] and |
10 | xref:yaml:dyn-array-ft-obj.adoc[dynamic array field types] within your | |
11 | xref:yaml:dst-obj.adoc[data stream type] or | |
12 | xref:yaml:ert-obj.adoc[event record type] root field types. | |
13 | ||
14 | ==== | |
15 | This xref:yaml:index.adoc[YAML configuration] has static and dynamic | |
16 | array field type objects: | |
17 | ||
18 | [source,yaml] | |
19 | ---- | |
20 | --- !<tag:barectf.org,2020/3/config> | |
21 | trace: | |
22 | type: | |
23 | $include: | |
24 | - stdint.yaml | |
25 | - stdmisc.yaml | |
26 | native-byte-order: little-endian | |
27 | data-stream-types: | |
28 | my_stream: | |
29 | event-record-common-context-field-type: | |
30 | class: structure | |
31 | members: | |
32 | - src_ip_addr: | |
33 | field-type: | |
34 | class: static-array | |
35 | length: 4 | |
36 | element-field-type: uint8 | |
37 | event-record-types: | |
38 | my_event: | |
39 | payload-field-type: | |
40 | class: structure | |
41 | members: | |
42 | - message_id: uint32 | |
43 | - messages: | |
44 | field-type: | |
45 | class: dynamic-array | |
46 | element-field-type: string | |
47 | ---- | |
48 | ||
49 | barectf generates the following | |
50 | C{nbsp}xref:tracing-funcs:index.adoc[tracing function] for the | |
51 | `my_event` event record type: | |
52 | ||
53 | [source,c] | |
54 | ---- | |
55 | void barectf_my_stream_trace_my_event(struct barectf_my_stream_ctx *sctx, | |
56 | const uint8_t *cc_src_ip_addr, | |
57 | uint32_t p_message_id, | |
58 | uint32_t p___messages_len, | |
59 | const char * const *p_messages); | |
60 | ---- | |
61 | ==== | |
62 | ||
63 | [[api]] | |
64 | == Reworked Python API | |
65 | ||
66 | The `barectf` Python API was revamped to: | |
67 | ||
68 | * Match the recent CTF terminology and model | |
69 | (like https://babeltrace.org/[Babeltrace{nbsp}2] and the | |
016a4d97 PP |
70 | upcoming CTF{nbsp}2). |
71 | ||
c24e3f21 PP |
72 | * Remove unneeded properties from some classes, like the encoding of an |
73 | integer field type object or the byte order of any field type object | |
74 | (barectf{nbsp}3.0 always uses the configured native byte order). | |
75 | ||
76 | * Have a better object model. | |
77 | + | |
78 | For example, a `barectf.SignedEnumerationFieldType` object is a | |
79 | `barectf.SignedIntegerFieldType` object, which is a | |
80 | `barectf._BitArrayFieldType` object, which is a | |
81 | `barectf._FieldType` object. | |
82 | ||
83 | * Decouple the xref:yaml:index.adoc#stages[effective YAML | |
84 | configuration object] printing operation from the parsing operation. | |
85 | + | |
86 | Now, `barectf.configuration_from_file()` returns a configuration object | |
87 | from a YAML configuration while `barectf.effective_configuration_file()` | |
88 | returns the effective version of a YAML configuration. | |
89 | ||
90 | * Make the `barectf.configuration_from_file()`, | |
91 | `barectf.effective_configuration_file()`, and | |
92 | `barectf.configuration_file_major_version()` functions accept a | |
93 | https://docs.python.org/3/glossary.html#term-file-object[file object] | |
94 | instead of a file system path. | |
95 | + | |
96 | Those three functions can process barectf{nbsp}2 and{nbsp}<<yaml,3>> | |
97 | YAML configurations. | |
98 | ||
99 | * Offer all the API from the `barectf` package itself. | |
016a4d97 | 100 | + |
c24e3f21 PP |
101 | From which modules are the names exactly is now an implementation |
102 | detail: you only need to import `barectf`. | |
103 | ||
104 | NOTE: The `barectf` Python package's documentation is not available yet. | |
105 | ||
106 | [[yaml]] | |
107 | == New YAML configuration schema | |
108 | ||
109 | barectf{nbsp}3.0 comes with a new YAML configuration schema to | |
110 | parallel the <<api,new Python API>>. | |
111 | ||
112 | Rest assured that both the barectf Python API and the | |
113 | <<cli,`barectf` CLI tool>> can still process a | |
114 | barectf{nbsp}2 YAML configuration. | |
115 | ||
116 | The most significant changes are: | |
117 | ||
118 | * An updated terminology for property names and values. | |
119 | ||
120 | * The xref:yaml:cfg-obj.adoc[configuration object] mapping (the YAML | |
121 | document) must be | |
122 | xref:yaml:yaml-primer.adoc#tag[tagged] with | |
123 | `tag:barectf.org,2020/3/config`: | |
016a4d97 | 124 | + |
c24e3f21 PP |
125 | .Configuration object |
126 | [source,yaml] | |
127 | ---- | |
128 | --- !<tag:barectf.org,2020/3/config> | |
129 | # ... | |
130 | ---- | |
016a4d97 | 131 | + |
c24e3f21 PP |
132 | This is how barectf identifies a barectf{nbsp}3 YAML configuration. |
133 | + | |
134 | This YAML tag also makes it possible to insert a barectf configuration | |
135 | object within another, unrelated YAML document if need be. | |
136 | ||
137 | * The configuration object contains a xref:yaml:trace-obj.adoc[trace | |
138 | object] which itself contains a xref:yaml:trace-type-obj.adoc[trace | |
139 | type object]: | |
140 | + | |
141 | .Configuration object | |
142 | [source,yaml] | |
143 | ---- | |
144 | --- !<tag:barectf.org,2020/3/config> | |
145 | trace: | |
146 | type: | |
147 | native-byte-order: big-endian | |
148 | uuid: 296e1e04-91e4-4b54-b77c-19e776f1d3a7 | |
149 | # ... | |
150 | environment: | |
151 | sys_id: 1983 | |
152 | node_id: 17 | |
153 | sys_name: tel/long-can | |
154 | ---- | |
016a4d97 PP |
155 | + |
156 | A trace can have an environment while a trace type can have a UUID. | |
157 | ||
c24e3f21 PP |
158 | * You can specify _two_ independent |
159 | xref:yaml:cfg-obj.adoc#prefix-obj[prefixes] instead of a single one: a | |
160 | file name prefix and an identifier prefix: | |
161 | + | |
162 | .Configuration object | |
163 | [source,yaml] | |
164 | ---- | |
165 | --- !<tag:barectf.org,2020/3/config> | |
166 | options: | |
167 | code-generation: | |
168 | prefix: | |
169 | file-name: my-system | |
170 | identifier: msys_ | |
171 | trace: | |
172 | type: | |
173 | # ... | |
174 | ---- | |
016a4d97 | 175 | + |
c24e3f21 PP |
176 | With barectf{nbsp}2, the single prefix `my_app_` used to become the file |
177 | name prefix `my_app` and the identifier prefix `my_app_`. | |
016a4d97 | 178 | |
c24e3f21 PP |
179 | * You don't need to specify special CTF structure field type members, |
180 | like `magic`, `stream_id`, and `timestamp`. | |
181 | + | |
182 | Instead, you specify xref:yaml:trace-type-obj.adoc#features-obj[trace | |
183 | type] and xref:yaml:dst-obj.adoc#features-obj[data stream type | |
184 | features]: | |
185 | + | |
186 | .Trace type object | |
187 | [source,yaml] | |
188 | ---- | |
189 | $features: | |
190 | magic-field-type: true | |
191 | uuid-field-type: true | |
192 | data-stream-types: | |
193 | my_stream: | |
194 | $features: | |
195 | packet: | |
196 | beginning-timestamp-field-type: true | |
197 | end-timestamp-field-type: false | |
198 | discarded-event-records-counter-snapshot-field-type: true | |
199 | event-record: | |
200 | timestamp-field-type: true | |
201 | # ... | |
202 | # ... | |
203 | # ... | |
204 | ---- | |
205 | + | |
206 | You can still control the exact field type of a feature: | |
016a4d97 | 207 | + |
c24e3f21 PP |
208 | .Trace type object |
209 | [source,yaml] | |
210 | ---- | |
211 | $features: | |
212 | data-stream-type-id-field-type: uint8 | |
213 | # ... | |
214 | ---- | |
016a4d97 | 215 | |
c24e3f21 PP |
216 | * A data stream type can have zero or one |
217 | xref:yaml:dst-obj.adoc#def-clk-type-name-prop[default clock type]: | |
218 | + | |
219 | .Trace type object | |
220 | [source,yaml] | |
221 | ---- | |
222 | clock-types: | |
223 | sys23: | |
224 | description: System clock (pin 23) | |
225 | frequency: 8000000 | |
226 | origin-is-unix-epoch: false | |
227 | data-stream-types: | |
228 | my_stream: | |
229 | $default-clock-type-name: sys23 | |
230 | # ... | |
231 | # ... | |
232 | # ... | |
233 | ---- | |
016a4d97 PP |
234 | + |
235 | When a data stream type has a default clock type, its timestamp integer | |
236 | field types (packet beginning, packet end, and event record) | |
237 | automatically refer to this specific clock type, effectively removing | |
c24e3f21 PP |
238 | the xref:yaml:int-ft-obj.adoc[integer field type object]'s |
239 | `property-mappings` property. | |
016a4d97 | 240 | |
c24e3f21 PP |
241 | * The only way to make a data stream type the default one is with its |
242 | xref:yaml:dst-obj.adoc#is-def-prop[`$is-default` boolean property]. | |
243 | + | |
244 | .Trace type object | |
245 | [source,yaml] | |
246 | ---- | |
247 | data-stream-types: | |
248 | my_stream: | |
249 | $is-default: true | |
250 | # ... | |
251 | # ... | |
252 | # ... | |
253 | ---- | |
016a4d97 | 254 | |
c24e3f21 PP |
255 | * You cannot specify custom |
256 | xref:how-barectf-works:ctf-primer.adoc#pkt[packet] header and | |
257 | xref:how-barectf-works:ctf-primer.adoc#er[event record] header field | |
258 | type members anymore. | |
016a4d97 PP |
259 | + |
260 | The header field types only exist for the trace format itself. | |
261 | + | |
c24e3f21 PP |
262 | Instead, xref:yaml:dst-obj.adoc#pkt-ctx-ft-extra-members-prop[append |
263 | user-defined members to the packet context field type] and use the | |
016a4d97 PP |
264 | xref:yaml:dst-obj.adoc#er-common-ctx-ft-prop[event record common context |
265 | field type]. | |
266 | ||
c24e3f21 PP |
267 | * You don't need to define |
268 | xref:yaml:trace-type-obj.adoc#ft-aliases-prop[field type aliases] | |
269 | in any specific order: | |
270 | + | |
271 | .Trace type object | |
272 | [source,yaml] | |
273 | ---- | |
274 | $field-type-aliases: | |
275 | user-id: | |
276 | $inherit: base-id | |
277 | size: 16 | |
278 | base-id: | |
279 | class: unsigned-integer | |
280 | preferred-display-base: hexadecimal | |
281 | # ... | |
282 | ---- | |
283 | + | |
284 | This is also the case within a barectf{nbsp}2 YAML metadata object. | |
285 | ||
286 | * An xref:yaml:int-ft-obj.adoc[integer field type] _is_ (conceptually | |
287 | inherits) a bit array field type. | |
016a4d97 PP |
288 | + |
289 | A bit array field type has size and alignment properties. It doesn't | |
290 | have a byte order property: as of barectf{nbsp}3.0, the generated tracer | |
c24e3f21 PP |
291 | always uses the configured |
292 | xref:yaml:trace-type-obj.adoc#native-bo-prop[native byte order]. | |
293 | ||
294 | * An integer field type object doesn't have a `signed` property: | |
295 | unsigned and signed integer field types are two different classes: | |
296 | + | |
297 | .xref:yaml:struct-ft-obj.adoc[Structure field type object] | |
298 | [source,yaml] | |
299 | ---- | |
300 | class: structure | |
301 | members: | |
302 | - unsigned_int: | |
303 | field-type: | |
304 | class: unsigned-integer | |
305 | size: 32 | |
306 | - signed_int: | |
307 | field-type: | |
308 | class: signed-integer | |
309 | size: 16 | |
310 | ---- | |
311 | ||
312 | * An xref:yaml:enum-ft-obj.adoc[enumeration field type] _is_ an integer | |
313 | field type; it doesn't have a `value-type` property anymore: | |
314 | + | |
315 | .Signed enumeration field type object | |
316 | [source,yaml] | |
317 | ---- | |
318 | class: signed-enumeration | |
319 | size: 16 | |
320 | alignment: 32 | |
321 | preferred-display-base: octal | |
322 | # ... | |
323 | ---- | |
324 | ||
325 | * The xref:yaml:enum-ft-obj.adoc#mappings-prop[mappings] of an | |
326 | enumeration field type are now a YAML mapping of labels to sequences | |
327 | of integer ranges: | |
328 | + | |
329 | .Signed enumeration field type object | |
330 | [source,yaml] | |
331 | ---- | |
332 | class: signed-enumeration | |
333 | size: 16 | |
334 | mappings: | |
335 | Poly: | |
336 | - -23 | |
337 | - [45, 1001] | |
338 | UdeM: | |
339 | - [2000, 3000] | |
340 | UQÀM: | |
341 | - [1, 5] | |
342 | - -40 | |
343 | ---- | |
344 | ||
345 | * A xref:yaml:real-ft-obj.adoc[real field type] _is_ a bit array field | |
346 | type. Its `size` property indicates if it's single-precision | |
347 | or a double-precision: | |
348 | + | |
349 | .Real field type object | |
350 | [source,yaml] | |
351 | ---- | |
352 | class: real | |
353 | size: 64 | |
354 | ---- | |
355 | ||
356 | * The xref:yaml:struct-ft-obj.adoc#members-prop[members] of a structure | |
357 | field type are a sequence instead of a mapping (YAML mappings are | |
358 | _not_ ordered): | |
359 | + | |
360 | .Structure field type object | |
361 | [source,yaml] | |
362 | ---- | |
363 | class: structure | |
364 | members: | |
365 | - msg: string | |
366 | - msg_id: uint8 | |
367 | - exceptions: | |
368 | field-type: | |
369 | class: dynamic-array | |
370 | element-field-type: string | |
371 | ---- | |
016a4d97 PP |
372 | + |
373 | This sequence is considered to be an _ordered mapping_, similar to | |
374 | YAML's https://yaml.org/type/omap.html[`+!!omap+`] type. | |
375 | ||
c24e3f21 PP |
376 | The xref:yaml:include.adoc#std[standard partial YAML files] were updated |
377 | to honour the new YAML configuration schema when a barectf{nbsp}3 YAML | |
378 | configuration includes them. | |
379 | ||
380 | [[cli]] | |
381 | == Upgraded command-line interface | |
382 | ||
383 | The xref:cli:usage.adoc[`barectf` CLI tool] now has a | |
384 | https://git-scm.com/[Git]-like user interface with the following commands | |
385 | ||
386 | xref:cli:usage.adoc#generate-command[`generate`]:: | |
387 | Exactly the barectf{nbsp}2 command-line interface: generates | |
388 | the C{nbsp}source and CTF metadata stream files of a tracer | |
389 | from a xref:yaml:index.adoc[YAML configuration file]. | |
390 | ||
391 | xref:cli:usage.adoc#show-effective-configuration-command[`show-effective-configuration`]:: | |
392 | Prints the xref:yaml:index.adoc#stages[_effective_] version of | |
393 | a YAML configuration file. | |
394 | ||
395 | xref:cli:usage.adoc#show-configuration-version-command[`show-configuration-version`]:: | |
396 | Prints the major version (2 or 3) of a YAML configuration file. | |
397 | ||
398 | The `barectf` CLI tool remains backward compatible with its | |
399 | barectf{nbsp}2 counterpart: the default command is `generate`. | |
016a4d97 | 400 | |
c24e3f21 PP |
401 | == Improved generated C{nbsp}code |
402 | ||
403 | The generated C{nbsp}code is now ``const``-correct. | |
404 | ||
405 | There are a few new public definition and function aliases to match the | |
406 | <<api,Python API>>'s updated terminology: | |
407 | ||
408 | * `_BARECTF_IDENTIFIER_PREFIX` is defined to the same value as | |
409 | `_BARECTF_PREFIX`. | |
016a4d97 | 410 | + |
c24e3f21 PP |
411 | See the code generation header options object's |
412 | xref:yaml:cfg-obj.adoc#iden-prefix-def-prop[`identifier-prefix-definition` | |
413 | property]. | |
414 | ||
415 | * `_BARECTF_DEFAULT_DATA_STREAM_TYPE_NAME` is defined to the same | |
416 | value as `_BARECTF_DEFAULT_STREAM`. | |
417 | + | |
418 | See the code generation header options object's | |
419 | xref:yaml:cfg-obj.adoc#def-dst-name-def-prop[`default-data-stream-type-name-definition` | |
420 | property]. | |
421 | ||
422 | * xref:platform:api.adoc#barectf-disc-er-count-func[`+barectf_discarded_event_records_count()+`] | |
423 | returns the same thing as `+barectf_packet_events_discarded()+`. | |
424 | ||
425 | * xref:platform:api.adoc#barectf-pkt-buf-addr-func[`+barectf_packet_buf_addr()+`] | |
426 | returns the same thing as `+barectf_packet_buf()+`. | |
016a4d97 | 427 | |
c24e3f21 PP |
428 | The `barectf-bitfield.h` header only contains what's needed by the |
429 | target's xref:yaml:trace-type-obj.adoc#native-bo-prop[native byte | |
430 | order]. Also, only `barectf.c` includes this header now, not leaking its | |
431 | definitions through the public `barectf.h` header. |