Commit | Line | Data |
---|---|---|
fdbf8740 PP |
1 | {# |
2 | # The MIT License (MIT) | |
3 | # | |
4 | # Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com> | |
5 | # | |
6 | # Permission is hereby granted, free of charge, to any person obtaining | |
7 | # a copy of this software and associated documentation files (the | |
8 | # "Software"), to deal in the Software without restriction, including | |
9 | # without limitation the rights to use, copy, modify, merge, publish, | |
10 | # distribute, sublicense, and/or sell copies of the Software, and to | |
11 | # permit persons to whom the Software is furnished to do so, subject to | |
12 | # the following conditions: | |
13 | # | |
14 | # The above copyright notice and this permission notice shall be | |
15 | # included in all copies or substantial portions of the Software. | |
16 | # | |
17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
20 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
21 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
22 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
23 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
24 | #} | |
1b49c7b8 | 25 | {% import 'common.j2' as common %} |
de49021e PP |
26 | /* CTF 1.8 */ |
27 | ||
e72875eb PP |
28 | {% include 'licence-header.j2' %} |
29 | ||
30 | ||
de49021e | 31 | {# |
8f0d81a0 PP |
32 | # Generates a root field type string named `name` for the field type |
33 | # `rft` with all the lines except the first one indented with a single | |
34 | # tab. | |
35 | #} | |
ba6905ab | 36 | {% macro root_ft(name, rft) %} |
de49021e PP |
37 | {{ name }} := {{ rft | ft_str | indent_tab }}; |
38 | {%- endmacro %} | |
de49021e PP |
39 | trace { |
40 | major = 1; | |
41 | minor = 8; | |
42 | byte_order = {{ cfg.trace.type.default_byte_order | bo_str }}; | |
d6483c83 | 43 | {% if cfg.trace.type.uuid %} |
de49021e | 44 | uuid = "{{ cfg.trace.type.uuid }}"; |
d6483c83 PP |
45 | {% endif %} |
46 | {% if cfg.trace.type._pkt_header_ft %} | |
de49021e | 47 | {{ root_ft('packet.header', cfg.trace.type._pkt_header_ft) }} |
d6483c83 | 48 | {% endif %} |
de49021e PP |
49 | }; |
50 | ||
51 | env { | |
52 | {% for name, value in cfg.trace.environment.items() %} | |
53 | {{ name }} = {{ value if value is number else '"{}"'.format(value | escape_dq) }}; | |
54 | {% endfor %} | |
55 | }; | |
56 | ||
57 | {# all clock types (stream types's default clock types) #} | |
58 | {% for clk_type in cfg.trace.type.clock_types | sort %} | |
59 | clock { | |
60 | name = {{ clk_type.name }}; | |
61 | {% if clk_type.description %} | |
62 | description = "{{ clk_type.description | escape_dq }}"; | |
63 | {% endif %} | |
64 | {% if clk_type.uuid %} | |
65 | uuid = "{{ clk_type.uuid }}"; | |
66 | {% endif %} | |
67 | freq = {{ clk_type.frequency }}; | |
68 | precision = {{ clk_type.precision }}; | |
69 | offset_s = {{ clk_type.offset.seconds }}; | |
70 | offset = {{ clk_type.offset.cycles }}; | |
71 | absolute = {{ 'true' if clk_type.origin_is_unix_epoch else 'false' }}; | |
72 | }; | |
73 | ||
74 | {% endfor %} | |
75 | {# stream types and their event types #} | |
ba6905ab | 76 | {% for stream_type in cfg.trace.type.stream_types | sort %} |
de49021e PP |
77 | /* Stream type `{{ stream_type.name }}` */ |
78 | stream { | |
79 | id = {{ stream_type.id }}; | |
80 | {{ root_ft('packet.context', stream_type._pkt_ctx_ft) }} | |
81 | {% if stream_type._ev_header_ft %} | |
82 | {{ root_ft('event.header', stream_type._ev_header_ft) }} | |
83 | {% endif %} | |
84 | {% if stream_type.event_common_context_field_type %} | |
85 | {{ root_ft('event.context', stream_type.event_common_context_field_type) }} | |
86 | {% endif %} | |
87 | }; | |
88 | ||
d6483c83 PP |
89 | {# stream type's event types #} |
90 | {% for ev_type in stream_type.event_types | sort %} | |
de49021e | 91 | event { |
de49021e | 92 | stream_id = {{ stream_type.id }}; |
ba6905ab | 93 | id = {{ ev_type.id }}; |
de49021e | 94 | name = "{{ ev_type.name }}"; |
d6483c83 | 95 | {% if ev_type.log_level %} |
de49021e | 96 | loglevel = {{ ev_type.log_level }}; |
d6483c83 PP |
97 | {% endif %} |
98 | {% if ev_type.specific_context_field_type %} | |
de49021e | 99 | {{ root_ft('context', ev_type.specific_context_field_type) }} |
d6483c83 PP |
100 | {% endif %} |
101 | {% if ev_type.payload_field_type %} | |
de49021e | 102 | {{ root_ft('fields', ev_type.payload_field_type) }} |
d6483c83 | 103 | {% endif %} |
de49021e PP |
104 | }; |
105 | ||
d6483c83 | 106 | {% endfor %} |
de49021e | 107 | {% endfor %} |