File: ft-obj.adoc

package info (click to toggle)
barectf 3.1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,840 kB
  • sloc: python: 3,781; ansic: 1,585; makefile: 45; sh: 11
file content (371 lines) | stat: -rw-r--r-- 7,572 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
= YAML field type object

A _**field type object**_ is the type of data field, found in
xref:how-barectf-works:ctf-primer.adoc#ds[data streams].

A field type object describes what a CTF consumer needs to decode a data
field.

You can use a xref:trace-type-obj.adoc#ft-aliases-prop[field type alias]
name (a string) anywhere a field type object is expected.

== Expected usage locations

A field type object is expected at the following locations:

Within another field type object::
+
--
* The xref:struct-ft-obj.adoc#member-ft-prop[`field-type` property]
  of a structure field type member object.

* The `element-field-type` property of a
  xref:static-array-ft-obj.adoc#element-ft-prop[static] or
  xref:dyn-array-ft-obj.adoc#element-ft-prop[dynamic field type object].
--

Within a xref:trace-type-obj.adoc[trace type object]::
+
--
* A value of a xref:trace-type-obj.adoc#ft-aliases-prop[field type
  alias] mapping entry.

* Any property of a
  xref:trace-type-obj.adoc#features-obj[features object].
--

Within a xref:dst-obj.adoc[data stream type object]::
+
--
* Any property of a
  xref:dst-obj.adoc#pkt-features-obj[packet features object].

* Any property of an
  xref:dst-obj.adoc#er-features-obj[event record features object].

* The
  xref:dst-obj.adoc#er-common-ctx-ft-prop[`event-record-common-context-field-type`
  property].
--

Within an xref:ert-obj.adoc[event record type object]::
+
--
* The xref:ert-obj.adoc#spec-ctx-ft-prop[`specific-context-field-type`
  property].

* The xref:ert-obj.adoc#payload-ft-prop[`payload-field-type`
  property].
--

== Available field type objects

As of barectf{nbsp}{page-component-version}, the available field type
objects are:

xref:int-ft-obj.adoc[Integer field type objects]::
    Describes unsigned and signed integer data fields.

xref:enum-ft-obj.adoc[Enumeration field type objects]::
    Describes unsigned and signed enumeration data fields.

xref:real-ft-obj.adoc[Real field type object]::
    Describes single-precision and double-precision real data fields.

xref:str-ft-obj.adoc[String field type object]::
    Describes null-terminated string data fields.

xref:struct-ft-obj.adoc[Structure field type object]::
    Describes structure data fields.

xref:static-array-ft-obj.adoc[Static array field type object]::
    Describes array data fields with a static length.

xref:dyn-array-ft-obj.adoc[Dynamic array field type object]::
    Describes array data fields with a dynamic (variable) length.

[[gen-c-types]]
== Generated C{nbsp}types

barectf uses configured field types to generate user data parameters of
packet opening and tracing functions.

Each field type object page indicates the field type's corresponding
C{nbsp}type(s).

Here's a summary:

[%autowidth.stretch, cols="d,a"]
|===
|Field type |C type

|Unsigned
xref:int-ft-obj.adoc[integer]/xref:enum-ft-obj.adoc[enumeration field
type]
|Depending on the `size` property:

[1,{nbsp}8]::
  `uint8_t`

[9,{nbsp}16]::
  `uint16_t`

[17,{nbsp}32]::
  `uint32_t`

[33,{nbsp}64]::
  `uint64_t`

|Signed
 xref:int-ft-obj.adoc[integer]/xref:enum-ft-obj.adoc[enumeration field
 type]
|Depending on the `size` property:

[1,{nbsp}8]::
  `int8_t`

[9,{nbsp}16]::
  `int16_t`

[17,{nbsp}32]::
  `int32_t`

[33,{nbsp}64]::
  `int64_t`

|xref:real-ft-obj.adoc[Real field type]
|Depending on the xref:real-ft-obj.adoc#size-prop[`size` property]:

32::
  `float`

64::
  `double`

|xref:str-ft-obj.adoc[String field type]
|`const char *`

|xref:static-array-ft-obj.adoc[Static array field type]
|Pointer to `const __T__`, where `__T__` is the generated C{nbsp}type
 for the field type object of the
 xref:static-array-ft-obj.adoc#element-ft-prop[`element-field-type`
 property].

|xref:dyn-array-ft-obj.adoc[Dynamic array field type]
|Two adjacent parameters:

Dynamic length::
    `uint32_t`

Element::
    Pointer to `const __T__`, where `__T__` is the generated C{nbsp}type
    for the field type object of the
    xref:dyn-array-ft-obj.adoc#element-ft-prop[`element-field-type`
    property].
|===

[[inherit]]
== Inherit a field type object

A field type object can _inherit_ the properties of another field type
object with the common <<inherit-prop,`$inherit` property>>.

When a field type object __**A**__ inherits another field type object
__**B**__, the _effective_ field type object is __**A**__ "`patching`"
__**B**__.

include::partial$patching-rules-table.adoc[]

=== Examples

In the examples below, the name of the base field type object's alias is
`base`.

.Override scalar property.
====
.Base field type object
[source,yaml]
----
class: unsigned-integer
size: 32
alignment: 8
----

.Overlay field type object
[source,yaml]
----
$inherit: base
size: 16
----

.Effective field type object
[source,yaml]
----
class: unsigned-integer
size: 16
alignment: 8
----
====

.Add and override scalar properties.
====
.Base field type object
[source,yaml]
----
class: unsigned-integer
size: 32
alignment: 8
----

.Overlay field type object
[source,yaml]
----
$inherit: base
size: 16
preferred-display-base: hexadecimal
----

.Effective field type object
[source,yaml]
----
class: unsigned-integer
size: 16
alignment: 8
preferred-display-base: hexadecimal
----
====

.Append to sequence property.
====
.Base field type object
[source,yaml]
----
class: signed-enumeration
mappings:
  COMPOSE:
    - 56
    - [100, 299]
  DIRTY: [0]
----

.Overlay field type object
[source,yaml]
----
$inherit: base
size: 16
mappings:
  COMPOSE:
    - -22
----

.Effective field type object
[source,yaml]
----
class: signed-enumeration
size: 16
mappings:
  COMPOSE:
    - 56
    - [100, 299]
    - -22
  DIRTY: [0]
----
====

.Add to nested mapping property.
====
.Base field type object
[source,yaml]
----
class: structure
members:
  - msg: string
  - user_id: uint16
----

.Overlay field type object
[source,yaml]
----
$inherit: base
members:
  - src_ip_addr:
      field-type:
        class: static-array
        length: 4
        element-field-type: uint8
  - user_id: int8
----

.Effective field type object
[source,yaml]
----
class: structure
members:
  - msg: string
  - user_id: int8
  - src_ip_addr:
      field-type:
        class: static-array
        length: 4
        element-field-type: uint8
----
====

[[props]]
== Common properties

All field type objects require that the <<class-prop,`class`>> _or_ the
<<inherit-prop,`$inherit` property>> be set, but not both.

[%autowidth.stretch, cols="d,d,a,d"]
|===
|Name |Type |Description |Required?

|[[class-prop]]`class`
|String
|Class of this field type amongst:

`unsigned-integer`::
`unsigned-int`::
`uint`::
    Unsigned xref:int-ft-obj.adoc[integer field type]

`signed-integer`::
`signed-int`::
`sint`::
    Signed xref:int-ft-obj.adoc[integer field type]

`unsigned-enumeration`::
`unsigned-enum`::
`uenum`::
    Unsigned xref:enum-ft-obj.adoc[enumeration field type]

`signed-enumeration`::
`signed-enum`::
`senum`::
    Signed xref:enum-ft-obj.adoc[enumeration field type]

`real`::
    xref:real-ft-obj.adoc[Real field type]

`string`::
`str`::
    xref:str-ft-obj.adoc[String field type]

`structure`::
`struct`::
    xref:struct-ft-obj.adoc[Structure field type]

`static-array`::
    xref:static-array-ft-obj.adoc[Static array field type]

`dynamic-array`::
    xref:dyn-array-ft-obj.adoc[Dynamic array field type]
|Yes if the <<inherit-prop,`$inherit`>> property is not set.

|[[inherit-prop]]`$inherit`
|String
|Name of a xref:trace-type-obj.adoc#ft-aliases-prop[field type alias]
from which to <<inherit,inherit>>.
|Yes if the <<class-prop,`class`>> property is not set.
|===