Skip to content

Metadata object

Philippe Proulx edited this page Sep 10, 2020 · 5 revisions

A metadata object defines the desired layout of the CTF trace to be produced by the generated C code. It is used by barectf to generate C code, as well as a corresponding CTF metadata file.

A metadata object is used as the metadata property of the configuration object.

Properties

Property Type Description Required? Default value
type-aliases Associative array of strings (alias names) to Type objects or strings (previous alias names) Type aliases to be used in trace, stream, and event objects Optional {}
$log-levels Associative array of strings (log level names) to log level constant integers Log levels to be used in event objects Optional {}
$default-stream String Default stream name Optional No default stream name
clocks Associative array of strings (clock names) to Clock objects Trace clocks Optional {}
env Associative array of strings (names) to strings or integers (values) Trace environment variables Optional {}
trace Trace object Metadata common to the whole trace Required N/A
streams Associative array of strings (stream names) to Stream objects Trace streams Required N/A
$include (Including external YAML files) String or array of strings Include base properties from external YAML file(s) Optional []

All the properties which have a default value can also be set to null to force this default value. This is especially useful when including external YAML files.

The $default-stream property, if set, must be set to the name of an existing stream amongst the entries in the streams property. Note that a default stream can also be set at the stream object level using the $default property.

Each clock name of the clocks property must be a valid C identifier.

The streams property must contain at least one entry. Each stream name must be a valid C identifier.

Each environment variable name in the env property must be a valid C identifier. Those variables will be appended to some environment variables set by barectf itself.

The order of the type-aliases entries is important: a type alias may only inherit from another type alias if the latter is defined before.

Example

type-aliases:
  uint8:
    class: integer
    size: 8
  uint16:
    class: integer
    size: 16
  uint32:
    class: integer
    size: 32
  uint64:
    class: integer
    size: 64
  clock-int:
    $inherit: uint64
    property-mappings:
      - type: clock
        name: my_clock
        property: value
  byte: uint8
  uuid:
    class: array
    length: 16
    element-type: byte
$log-levels:
  emerg: 0
  alert: 1
  critical: 2
  error: 3
  warning: 4
  notice: 5
  info: 6
clocks:
  my_clock:
    freq: 1000000000
    offset:
      seconds: 1434072888
    $return-ctype: uint64_t
env:
  my_system_version: '0.3.2-2015.03'
  bID: 15
trace:
  byte-order: le
  uuid: auto
  packet-header-type:
    class: struct
    min-align: 8
    fields:
      magic: uint32
      uuid: uuid
      stream_id: uint8
$default-stream: my_stream
streams:
  my_stream:
    packet-context-type:
      class: struct
      fields:
        timestamp_begin: clock-int
        timestamp_end: clock-int
        packet_size: uint32
        something: float
        content_size: uint32
        events_discarded: uint32
    event-header-type:
      class: struct
      fields:
        timestamp: clock-int
        id: uint16
    events:
      simple_uint32:
        log-level: error
        payload-type:
          class: struct
          fields:
            value: uint32
      simple_int16:
        payload-type:
          class: struct
          fields:
            value:
              $inherit: uint16
              signed: true